diff --git a/config/default.nix b/config/default.nix index ed1e517..a2315b0 100644 --- a/config/default.nix +++ b/config/default.nix @@ -11,13 +11,15 @@ ./plugins/collections/mini.nix ./plugins/collections/snacks.nix - # LSP and Formatting - ./plugins/lsp/conform.nix - ./plugins/lsp/lsp.nix - # Completion & AI Assistancee ./plugins/cmp/cmp.nix + # Debugging (DAP) + ./plugins/dap/dap.nix + ./plugins/dap/dap-ui.nix + ./plugins/dap/dap-virtual-text.nix + ./plugins/dap/dap-python.nix + # Editor Enhancements ./plugins/editor/commentary.nix ./plugins/editor/harpoon.nix @@ -32,6 +34,10 @@ ./plugins/ui/web-devicons.nix ./plugins/ui/whichkey.nix + # LSP and Formatting + ./plugins/lsp/conform.nix + ./plugins/lsp/lsp.nix + # Git Integration ./plugins/git/fugitive.nix ./plugins/git/gitsigns.nix diff --git a/config/plugins/cmp/cmp.nix b/config/plugins/cmp/cmp.nix index 6db0159..73a9348 100644 --- a/config/plugins/cmp/cmp.nix +++ b/config/plugins/cmp/cmp.nix @@ -6,76 +6,47 @@ # Options provided to the require('cmp').setup function. settings = { - # Disable autocompletion by default - completion.autocomplete = false; - # The sources to use sources = [ - # Language Server Protocol - { name = "nvim_lsp"; } + { # Language Server Protocol + name = "nvim_lsp"; + } - # Buffer Words - { name = "buffer"; } + { # Buffer Words + name = "buffer"; + } - # Filesystem paths - { name = "path"; } + { # Filesystem paths + name = "path"; + } - # Markdown - { name = "render_markdown"; } + { # Markdown + name = "render_markdown"; + } - # VimTex - { name = "vimtex"; } + { # VimTex + name = "vimtex"; + } - # Neorg - { name = "neorg"; } + { # Neorg + name = "neorg"; + } ]; # Key mappings for the completion menu. mapping = { - # Confirm candidate on TAB immediately when there's only one completion entry - "" = /* lua */ '' - cmp.mapping(function(fallback) - local line, col = unpack(vim.api.nvim_win_get_cursor(0)) - - -- When the selection menu is open select the next item - if cmp.visible() then - cmp.select_next_item({behavior = cmp.SelectBehavior.Select}) - -- Ensure we are mid word - elseif col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil then - -- Open the selection menu - cmp.complete() - -- Autocomplete when there is only 1 selection available - if #cmp.get_entries() == 1 then - cmp.confirm({ select = true }) - end - -- Select the firt item - cmp.select_next_item({behavior = cmp.SelectBehavior.Select}) - -- Keep regular functionality of tab - else - fallback() - end - end, {'i', 's'}) - ''; - - # Confirm selection - "" = /* lua */ '' - cmp.mapping.confirm({ select = true }) - ''; - - # Select the next item in the menu - "" = /* lua */ '' - cmp.mapping(cmp.mapping.select_next_item({behavior = cmp.SelectBehavior.Select}), {'i', 's'}) - ''; - - # Select the prev item in the menu - "" = /* lua */ '' - cmp.mapping(cmp.mapping.select_prev_item({behavior = cmp.SelectBehavior.Select}), {'i', 's'}) - ''; - - # Exit the completion menu - "" = /* lua */ '' - cmp.mapping.close() - ''; + "" = + # Lua + "cmp.mapping.close()"; + "" = + # Lua + "cmp.mapping(cmp.mapping.select_next_item({behavior = cmp.SelectBehavior.Select}), {'i', 's'})"; + "" = + # Lua + "cmp.mapping(cmp.mapping.select_prev_item({behavior = cmp.SelectBehavior.Select}), {'i', 's'})"; + "" = + # Lua + "cmp.mapping.confirm({ select = true })"; }; }; }; diff --git a/config/plugins/dap/dap-python.nix b/config/plugins/dap/dap-python.nix new file mode 100644 index 0000000..d71888f --- /dev/null +++ b/config/plugins/dap/dap-python.nix @@ -0,0 +1,53 @@ +{ ... }: { + plugins.dap-python = { + enable = true; + }; + + keymaps = [ + { + mode = ["n" "v"]; + key = "dP"; + action = ""; + options = { + silent = true; + desc = "+python"; + }; + } + + { + mode = ["n"]; + key = "dPm"; + action = { + __raw = "require('dap-python').test_method"; + }; + options = { + silent = true; + desc = "Test method"; + }; + } + + { + mode = ["n"]; + key = "dPc"; + action = { + __raw = "require('dap-python').test_class"; + }; + options = { + silent = true; + desc = "Test Class"; + }; + } + + { + mode = ["v"]; + key = "dPs"; + action = { + __raw = "require('dap-python').debug_selection"; + }; + options = { + silent = true; + desc = "Debug selection"; + }; + } + ]; +} diff --git a/config/plugins/dap/dap-ui.nix b/config/plugins/dap/dap-ui.nix new file mode 100644 index 0000000..48cc272 --- /dev/null +++ b/config/plugins/dap/dap-ui.nix @@ -0,0 +1,19 @@ +{...}: { + plugins.dap-ui = { + enable = true; + }; + + keymaps = [ + { + mode = ["n"]; + key = "du"; + action = { + __raw = "require('dapui').toggle"; + }; + options = { + silent = true; + desc = "Toggle UI"; + }; + } + ]; +} diff --git a/config/plugins/dap/dap-virtual-text.nix b/config/plugins/dap/dap-virtual-text.nix new file mode 100644 index 0000000..9f7b378 --- /dev/null +++ b/config/plugins/dap/dap-virtual-text.nix @@ -0,0 +1,5 @@ +{ ... }: { + plugins.dap-virtual-text = { + enable = true; + }; +} diff --git a/config/plugins/dap/dap.nix b/config/plugins/dap/dap.nix new file mode 100644 index 0000000..a9dcd94 --- /dev/null +++ b/config/plugins/dap/dap.nix @@ -0,0 +1,143 @@ +{...}: { + plugins.dap = { + enable = true; + }; + + keymaps = [ + # Prefix: dap + { + mode = ["n" "v"]; + key = "d"; + action = ""; + options = { + silent = true; + desc = "+dap"; + }; + } + + + # Session management: + { + mode = ["n"]; + key = "dc"; + action = "DapContinue"; + options = { + silent = true; + }; + } + + { + mode = ["n"]; + key = "dq"; + action = "DapDisconnect"; + options = { + silent = true; + }; + } + + { + mode = ["n"]; + key = "dn"; + action = "DapNew"; + options = { + silent = true; + }; + } + + { + mode = ["n"]; + key = "dQ"; + action = "DapTerminate"; + options = { + silent = true; + }; + } + + + # Stepping: + { + mode = ["n"]; + key = "dr"; + action = "DapRestartFrame"; + options = { + silent = true; + }; + } + + { + mode = ["n"]; + key = "di"; + action = "DapStepInto"; + options = { + silent = true; + }; + } + + { + mode = ["n"]; + key = "dO"; + action = "DapStepOut"; + options = { + silent = true; + }; + } + + { + mode = ["n"]; + key = "do"; + action = "DapStepOver"; + options = { + silent = true; + }; + } + + { + mode = ["n"]; + key = "dp"; + action = "DapPause"; + options = { + silent = true; + }; + } + + + # Repl: + { + mode = ["n"]; + key = "dE"; + action = "DapEval"; + options = { + silent = true; + }; + } + + { + mode = ["n"]; + key = "dR"; + action = "DapToggleRepl"; + options = { + silent = true; + }; + } + + + # Breakpoints: + { + mode = ["n"]; + key = "dB"; + action = "DapClearBreakpoints"; + options = { + silent = true; + }; + } + + { + mode = ["n"]; + key = "db"; + action = "DapToggleBreakpoint"; + options = { + silent = true; + }; + } + ]; +}