From 7209d0eb3b390c128757968e0d6873c1bccfca02 Mon Sep 17 00:00:00 2001 From: Anthony Rodriguez Date: Thu, 29 Aug 2024 14:42:51 +0200 Subject: [PATCH] move nixvim keybinds to their own file when possible --- home/base/programs/nixvim/default.nix | 1 + home/base/programs/nixvim/keymaps.nix | 61 +------------------ home/base/programs/nixvim/plugins/lsp.nix | 56 ++++++++++++++--- .../programs/nixvim/plugins/telescope.nix | 39 ++++++++++++ .../programs/nixvim/plugins/which-key.nix | 2 +- 5 files changed, 90 insertions(+), 69 deletions(-) create mode 100644 home/base/programs/nixvim/plugins/telescope.nix diff --git a/home/base/programs/nixvim/default.nix b/home/base/programs/nixvim/default.nix index 826507d..29b554f 100644 --- a/home/base/programs/nixvim/default.nix +++ b/home/base/programs/nixvim/default.nix @@ -13,6 +13,7 @@ ./plugins/which-key.nix ./plugins/project-nvim.nix ./plugins/smart-splits.nix + ./plugins/telescope.nix ./plugins/misc.nix ]; diff --git a/home/base/programs/nixvim/keymaps.nix b/home/base/programs/nixvim/keymaps.nix index 80d8e62..2279d8a 100644 --- a/home/base/programs/nixvim/keymaps.nix +++ b/home/base/programs/nixvim/keymaps.nix @@ -2,69 +2,12 @@ { programs.nixvim.keymaps = [ - { - action = "Telescope find_files"; - key = "ff"; - options = { - desc = "Find files"; - }; - } - { - action = "Telescope projects"; - key = "fp"; - options = { - desc = "Find projects"; - }; - } - { - action = "Telescope buffers"; - key = "fb"; - options = { - desc = "Find buffers"; - }; - } { action = "Neotree toggle"; - key = "ft"; + key = "t"; options = { - desc = "Toggle neo-tree"; + desc = "Neotree"; }; } - { - action = '' - lua vim.lsp.buf.code_action({ apply = true }) - ''; - key = "lc"; - options = { - desc = "Apply code actions"; - }; - } - { - action = '' - lua vim.lsp.buf.format() - ''; - key = "lf"; - options = { - desc = "Format buffer"; - }; - } - { - action = '' - Telescope lsp_definitions - ''; - key = "gd"; - options = { - desc = "Go to definitions"; - }; - } - { - action = '' - Telescope lsp_references - ''; - key = "gr"; - options = { - desc = "Go to references"; - }; - } ]; } diff --git a/home/base/programs/nixvim/plugins/lsp.nix b/home/base/programs/nixvim/plugins/lsp.nix index 8f733cb..181b7e0 100644 --- a/home/base/programs/nixvim/plugins/lsp.nix +++ b/home/base/programs/nixvim/plugins/lsp.nix @@ -11,15 +11,6 @@ custom_captures = { }; enable = true; }; - incremental_selection = { - enable = true; - keymaps = { - init_selection = false; - node_decremental = "grm"; - node_incremental = "grn"; - scope_incremental = "grc"; - }; - }; indent = { enable = true; }; @@ -37,6 +28,53 @@ nixd.enable = true; lua-ls.enable = true; }; + keymaps = { + lspBuf = { + K = "hover"; + gr = { + action = "references"; + desc = "Go to references"; + }; + gi = { + action = "implementation"; + desc = "Go to implementation"; + }; + gt = { + action = "type_definition"; + desc = "Go to type definition"; + }; + }; + extra = [ + { + action = "LspStop"; + key = "lx"; + options = { + desc = "Stop LSP"; + }; + } + { + action = "LspStart"; + key = "ls"; + options = { + desc = "Start LSP"; + }; + } + { + action = "LspRestart"; + key = "lr"; + options = { + desc = "Restart LSP"; + }; + } + { + action = "Telescope lsp_definitions"; + key = "gd"; + options = { + desc = "Go to definitions"; + }; + } + ]; + }; }; cmp = { enable = true; diff --git a/home/base/programs/nixvim/plugins/telescope.nix b/home/base/programs/nixvim/plugins/telescope.nix new file mode 100644 index 0000000..ddc7854 --- /dev/null +++ b/home/base/programs/nixvim/plugins/telescope.nix @@ -0,0 +1,39 @@ +{ ... }: + +{ + programs.nixvim.plugins.telescope = { + enable = true; + keymaps = { + "" = { + action = "git_files"; + options = { + desc = "Telescope Git Files"; + }; + }; + "fg" = { + action = "live_grep"; + options = { + desc = "Live grep"; + }; + }; + "ff" = { + action = "find_files"; + options = { + desc = "Find files"; + }; + }; + "fp" = { + action = "projects"; + options = { + desc = "Find projects"; + }; + }; + "fb" = { + action = "buffers"; + options = { + desc = "Find buffers"; + }; + }; + }; + }; +} diff --git a/home/base/programs/nixvim/plugins/which-key.nix b/home/base/programs/nixvim/plugins/which-key.nix index c80ecfd..7409568 100644 --- a/home/base/programs/nixvim/plugins/which-key.nix +++ b/home/base/programs/nixvim/plugins/which-key.nix @@ -20,7 +20,7 @@ spec = [ { __unkeyed = "f"; - group = "Find"; + group = "Telescope"; } { __unkeyed = "l";