diff --git a/config/default.nix b/config/default.nix index 0d49d84..3dd9bf6 100644 --- a/config/default.nix +++ b/config/default.nix @@ -10,6 +10,12 @@ # Completion ./plugins/cmp/cmp.nix + # Debug Adapter Protocol + ./plugins/dap/dap.nix + ./plugins/dap/dap-ui.nix + ./plugins/dap/dap-virtual-text.nix + ./plugins/dap/dap-python.nix + # Editor plugins and configurations ./plugins/editor/buffers.nix ./plugins/editor/comment.nix 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..e26e2a2 --- /dev/null +++ b/config/plugins/dap/dap-ui.nix @@ -0,0 +1,18 @@ +{...}: { + plugins.dap-ui = { + enable = true; + }; + + keymaps = [ + { + 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..67cc2ea --- /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" "v"]; + key = "dc"; + action = "DapContinue"; + options = { + silent = true; + }; + } + + { + mode = ["n"]; + key = "dd"; + action = "DapDisconnect"; + options = { + silent = true; + }; + } + + { + mode = ["n"]; + key = "dn"; + action = "DapNew"; + options = { + silent = true; + }; + } + + { + mode = ["n"]; + key = "dt"; + 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; + }; + } + ]; +} diff --git a/config/plugins/editor/buffers.nix b/config/plugins/editor/buffers.nix index 6a629d4..ccff402 100644 --- a/config/plugins/editor/buffers.nix +++ b/config/plugins/editor/buffers.nix @@ -17,7 +17,7 @@ { # goto next buffer mode = ["n"]; - key = "bn"; + key = "]b"; action = ":bnext"; options = { silent = true; @@ -27,7 +27,7 @@ { # goto previous buffer mode = ["n"]; - key = "bp"; + key = "[b"; action = ":bprevious"; options = { silent = true; diff --git a/config/plugins/editor/treesitter.nix b/config/plugins/editor/treesitter.nix index 6cdeea8..67a5e4e 100644 --- a/config/plugins/editor/treesitter.nix +++ b/config/plugins/editor/treesitter.nix @@ -19,25 +19,23 @@ grammarPackages = pkgs.vimPlugins.nvim-treesitter.allGrammars; }; + # Refactor modules for nvim-treesitter plugins.treesitter-refactor = { enable = true; + # Highlights definitions and usages. highlightDefinitions = { enable = true; }; + # Provides "go to usage" navigation = { enable = true; - keymaps = { - gotoNextUsage = "n"; - gotoPreviousUsage = "N"; - }; - }; - smartRename = { - enable = true; + # Go to the next / previous usage. keymaps = { - smartRename = "r"; + gotoNextUsage = "]u"; + gotoPreviousUsage = "[u"; }; }; }; diff --git a/config/plugins/git/lazygit.nix b/config/plugins/git/lazygit.nix index c0c982b..6f92f92 100644 --- a/config/plugins/git/lazygit.nix +++ b/config/plugins/git/lazygit.nix @@ -6,7 +6,7 @@ keymaps = [ { mode = "n"; - key = "g"; + key = "gL"; action = "LazyGit"; options = { desc = "Open LazyGit"; @@ -16,7 +16,9 @@ { mode = "n"; key = "glr"; - action = "lua require(\"telescope\").extensions.lazygit.lazygit()"; + action = { + __raw = "require('telescope').extensions.lazygit.lazygit"; + }; options = { desc = "List repositories"; }; diff --git a/config/plugins/lsp/conform.nix b/config/plugins/lsp/conform.nix index 520bdfd..aa542cf 100644 --- a/config/plugins/lsp/conform.nix +++ b/config/plugins/lsp/conform.nix @@ -55,7 +55,7 @@ # Keymaps for conform.nvim keymaps = [ { - mode = ""; + mode = ["n"]; key = "F"; action.__raw = '' function() diff --git a/config/plugins/lsp/lsp.nix b/config/plugins/lsp/lsp.nix index befd4fe..4fdcbe6 100644 --- a/config/plugins/lsp/lsp.nix +++ b/config/plugins/lsp/lsp.nix @@ -1,6 +1,7 @@ {...}: { plugins.lsp = { enable = true; # Enable neovim's built-in LSP. + inlayHints = true; # Configure our language servers servers = { @@ -53,7 +54,66 @@ gi = "implementation"; # Lists all the implementations¹ gt = "type_definition"; # Jumps to the definition of the type¹ # ¹ for the symbol under the cursor + + # Renames all references to the symbol under the cursor. + "r" = { + action = "rename"; + desc = "Rename"; + }; }; + + # Extra keymaps to register when an LSP is attached + extra = [ + { + mode = ["n"]; + key = "l"; + action = ""; + options = { + silent = true; + desc = "+lsp"; + }; + } + + { + mode = ["n"]; + key = "lc"; + action = "LspStop"; + options = { + silent = true; + desc = "Stop server"; + }; + } + + { + mode = ["n"]; + key = "ls"; + action = "LspStart"; + options = { + silent = true; + desc = "Start server"; + }; + } + + { + mode = ["n"]; + key = "lr"; + action = "LspRestart"; + options = { + desc = "Restart server"; + }; + } + + { + mode = ["n"]; + key = "fd"; + action = { + __raw = "require('telescope.builtin').lsp_definitions"; + }; + options = { + desc = "Find definitions"; + }; + } + ]; }; }; } diff --git a/config/plugins/ui/nvim-tree.nix b/config/plugins/ui/nvim-tree.nix index e283662..49535b5 100644 --- a/config/plugins/ui/nvim-tree.nix +++ b/config/plugins/ui/nvim-tree.nix @@ -26,6 +26,15 @@ }; keymaps = [ + { + mode = ["n"]; + key = "n"; + action = "NvimTreeToggle"; + options = { + desc = "Toggle NvimTree"; + }; + } + { mode = ["n"]; key = "e"; diff --git a/config/plugins/ui/whichkey.nix b/config/plugins/ui/whichkey.nix index 480ffb7..a34510b 100644 --- a/config/plugins/ui/whichkey.nix +++ b/config/plugins/ui/whichkey.nix @@ -9,16 +9,7 @@ # Prefixes, No operation. keymaps = [ { - mode = "n"; - key = "s"; - action = ""; - options = { - desc = "+search"; - }; - } - - { - mode = "n"; + mode = ["n" "v"]; key = "g"; action = ""; options = { @@ -27,7 +18,7 @@ } { - mode = "n"; + mode = ["n"]; key = "gl"; action = ""; options = { @@ -36,7 +27,7 @@ } { - mode = "n"; + mode = ["n"]; key = "gt"; action = ""; options = {