From e20f8b6ea2e89e7d027fc7cfab7f4df24cd4f071 Mon Sep 17 00:00:00 2001 From: Keule2 Date: Sun, 20 Oct 2024 18:22:16 +0200 Subject: [PATCH] Nvim config update --- roles/nvim/files/init.lua | 142 ++++++++++++++++++++++++++++--- roles/system/tasks/Archlinux.yml | 11 +++ roles/yazi/files/keymap.toml | 5 ++ 3 files changed, 148 insertions(+), 10 deletions(-) diff --git a/roles/nvim/files/init.lua b/roles/nvim/files/init.lua index 5e53b15..7578b66 100644 --- a/roles/nvim/files/init.lua +++ b/roles/nvim/files/init.lua @@ -18,9 +18,6 @@ vim.opt.rtp:prepend(lazypath) -- Add Plugins require("lazy").setup({ - -- Stats - { 'wakatime/vim-wakatime', lazy = false }, - -- Theme { "catppuccin/nvim", @@ -31,11 +28,14 @@ require("lazy").setup({ end, }, - -- Syntax highlighting support - -- "fladson/vim-kitty", + -- Stats + { 'wakatime/vim-wakatime', lazy = false }, + + -- Highlight + { "RRethy/vim-illuminate" }, -- Comment visual regions/lines - "numToStr/Comment.nvim", + { "numToStr/Comment.nvim", opts = {} }, -- Autoclose brackets { "m4xshen/autoclose.nvim", opts = {} }, @@ -64,6 +64,17 @@ require("lazy").setup({ }, }, + -- Debug + { + "rcarriga/nvim-dap-ui", + dependencies = { + "mfussenegger/nvim-dap", + "nvim-neotest/nvim-nio" + }, + opts = {} + }, + { "theHamsta/nvim-dap-virtual-text", opts = {} }, + -- LSP { "neovim/nvim-lspconfig", @@ -73,7 +84,6 @@ require("lazy").setup({ "williamboman/mason-lspconfig.nvim", -- Useful status updates for LSP - -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` { "j-hui/fidget.nvim", tag = "legacy", opts = {} }, -- Additional lua configuration, makes nvim stuff amazing! @@ -94,8 +104,12 @@ require("lazy").setup({ -- Adds a number of user-friendly snippets 'rafamadriz/friendly-snippets', + + -- Ai cmp + 'tzachar/cmp-ai' }, }, + { 'tzachar/cmp-ai', dependencies = 'nvim-lua/plenary.nvim' }, -- Show available command { @@ -238,6 +252,72 @@ vim.keymap.set("n", "", "j") vim.keymap.set("n", "", "k") vim.keymap.set("n", "", "l") +--- Debug +local dap, dapui, dapvs = require("dap"), require("dapui"), require('dap.ext.vscode') +vim.keymap.set("n", "b", dap.toggle_breakpoint, { desc = "[b] Debug toggle breakpoint" }) +vim.keymap.set("n", "dc", dap.continue, { desc = "[c] Debug Continue/Start" }) +vim.keymap.set("n", "n", dap.step_over, { desc = "[n] Debug step over" }) +vim.keymap.set("n", "N", dap.step_into, { desc = "[N] Debug step into" }) +vim.keymap.set("n", "m", dap.step_out, { desc = "[m] Debug step out" }) +vim.keymap.set("n", "dt", dapui.toggle, { desc = "[t] Debug toggle view" }) +vim.keymap.set("n", "dl", function() + dapvs.load_launchjs("launch.json", { cppdbg = { 'c', 'cpp' } }) + end, + { desc = "[l] Debug load launch config" }) + +dap.listeners.before.attach.dapui_config = function() + dapui.open() +end + +dap.listeners.before.launch.dapui_config = function() + dapui.open() +end + +-- dap.listeners.before.event_terminated.dapui_config = function() +-- dapui.close() +-- end +-- +-- dap.listeners.before.event_exited.dapui_config = function() +-- dapui.close() +-- end +dap.adapters.cppdbg = { + id = "cppdbg", + type = "executable", + command = "/home/pa/dap/c/extension/debugAdapters/bin/OpenDebugAD7", +} +dap.configurations.c = { + { + name = "Launch file", + type = "cppdbg", + request = "launch", + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + end, + args = function() + local s = vim.fn.input('Args: ') + local t = {} + for word in s:gmatch("%S+") do + table.insert(t, word) + end + return t + end, + cwd = '${workspaceFolder}', + stopAtEntry = true, + }, + -- { + -- name = 'Attach to gdbserver :1234', + -- type = 'cppdbg', + -- request = 'launch', + -- MIMode = 'gdb', + -- miDebuggerServerAddress = 'localhost:1234', + -- miDebuggerPath = '/usr/bin/gdb', + -- cwd = '${workspaceFolder}', + -- program = function() + -- return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + -- end, + -- }, +} + --- [[ Highlight on yank ]] -- See `:help vim.highlight.on_yank()` local highlight_group = vim.api.nvim_create_augroup("YankHighlight", { clear = true }) @@ -377,8 +457,8 @@ local on_attach = function(_, bufnr) nmap("gd", vim.lsp.buf.definition, "[G]oto [D]efinition") nmap("gr", require("telescope.builtin").lsp_references, "[G]oto [R]eferences") nmap("gI", require("telescope.builtin").lsp_implementations, "[G]oto [I]mplementation") + nmap("ds", require("telescope.builtin").lsp_document_symbols, "[D]ocument [S]ymbols") nmap("D", vim.lsp.buf.type_definition, "Type [D]efinition") - nmap("ds", require("telescope.builtin").lsp_document_symbols, "[D]ocument [S]ymbols") nmap("ws", require("telescope.builtin").lsp_dynamic_workspace_symbols, "[W]orkspace [S]ymbols") -- See `:help K` for why this keymap @@ -389,6 +469,7 @@ local on_attach = function(_, bufnr) nmap("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration") nmap("wa", vim.lsp.buf.add_workspace_folder, "[W]orkspace [A]dd Folder") nmap("wr", vim.lsp.buf.remove_workspace_folder, "[W]orkspace [R]emove Folder") + nmap("f", vim.lsp.buf.format, "[F]ormat") nmap("wl", function() print(vim.inspect(vim.lsp.buf.list_workspace_folders())) end, "[W]orkspace [L]ist Folders") @@ -425,12 +506,22 @@ local servers = { jsonls = {}, clangd = {}, cssls = {}, - jdtls = {}, + jdtls = { + java = { + maven = { downloadSources = true } + } + }, html = {}, lua_ls = { Lua = { - workspace = { checkThirdParty = false }, + workspace = { + library = vim.api.nvim_get_runtime_file('', true), + checkThirdParty = false + }, telemetry = { enable = false }, + diagnostics = { + globals = { "vim" } + } }, }, } @@ -505,8 +596,39 @@ cmp.setup { sources = { { name = "nvim_lsp" }, { name = "luasnip" }, + -- { name = "cmp_ai" }, }, } +-- local cmp_ai = require('cmp_ai.config') +-- cmp_ai:setup({ +-- max_lines = 100, +-- provider = 'Ollama', +-- provider_options = { +-- model = 'mistral', +-- }, +-- notify = true, +-- notify_callback = function(msg) +-- vim.notify(msg) +-- end, +-- run_on_every_keystroke = true, +-- ignored_file_types = { +-- -- default is not to ignore +-- -- uncomment to ignore in lua: +-- -- lua = true +-- }, +-- }) +-- The line beneath this is called `modeline`. See `:help modeline` +-- vim: ts=2 sts=2 sw=2 et +-- notify_callback = function(msg) +-- vim.notify(msg) +-- end, +-- run_on_every_keystroke = true, +-- ignored_file_types = { +-- -- default is not to ignore +-- -- uncomment to ignore in lua: +-- -- lua = true +-- }, +-- }) -- The line beneath this is called `modeline`. See `:help modeline` -- vim: ts=2 sts=2 sw=2 et diff --git a/roles/system/tasks/Archlinux.yml b/roles/system/tasks/Archlinux.yml index a0cdb38..3d984d1 100644 --- a/roles/system/tasks/Archlinux.yml +++ b/roles/system/tasks/Archlinux.yml @@ -146,6 +146,7 @@ - nemo - nemo-fileroller - gvfs-smb + - gvfs-mtp - mpv # Device configuration #- openrazer-daemon @@ -271,3 +272,13 @@ - desktop_services when: "system == 'desktop'" become: true + +- name: "Set makepkg threads" + ansible.builtin.lineinfile: + path: /etc/makepkg.conf + regexp: '^#MAKEFLAGS=' + line: 'MAKEFLAGS="-j10"' + state: present + tags: + - makepkg + become: true diff --git a/roles/yazi/files/keymap.toml b/roles/yazi/files/keymap.toml index c2ac77e..26c1f3d 100644 --- a/roles/yazi/files/keymap.toml +++ b/roles/yazi/files/keymap.toml @@ -14,6 +14,11 @@ on = [ "b", "d" ] run = "cd ~/.dotfiles/" desc = "DOTFILES" +[[manager.prepend_keymap]] +on = [ "b", "u" ] +run = "cd ~/uni/" +desc = "UNI" + [[manager.prepend_keymap]] on = [ "b", "s" ] run = "plugin bookmark --args=save"