diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-05-04 21:48:49 +0200 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-05-04 21:49:51 +0200 |
commit | 4bc050f3e2b4220404db18a8878c1a2f1a598d66 (patch) | |
tree | 7e1cf2fdb7b3a82d972d53d8d7993710f5823c1d /modules/by-name/nv/nvim/plgs/nvim-cmp/default.nix | |
parent | modules/nvim/options/completeopt: Move to `plgs/nvim-cmp` (diff) | |
download | nixos-config-4bc050f3e2b4220404db18a8878c1a2f1a598d66.zip |
modules/nvim/plgs/nvim-cmp: Unify key mappings by moving to the global module
This makes it possible, to use the `options.desc` field to add a which-key description. I also used this chance to unify the `cmp` related key mappings in one file.
Diffstat (limited to 'modules/by-name/nv/nvim/plgs/nvim-cmp/default.nix')
-rw-r--r-- | modules/by-name/nv/nvim/plgs/nvim-cmp/default.nix | 52 |
1 files changed, 46 insertions, 6 deletions
diff --git a/modules/by-name/nv/nvim/plgs/nvim-cmp/default.nix b/modules/by-name/nv/nvim/plgs/nvim-cmp/default.nix index f0754bd3..d3a20300 100644 --- a/modules/by-name/nv/nvim/plgs/nvim-cmp/default.nix +++ b/modules/by-name/nv/nvim/plgs/nvim-cmp/default.nix @@ -21,6 +21,50 @@ in { "noselect" # Do not pre select one of the completions ]; + keymaps = [ + { + key = "hh"; + mode = ["i"]; + action.__raw = '' + function() + require('cmp').select_next_item() + end + ''; + options.desc = "go forward in completion menu"; + } + { + key = "uu"; + mode = ["i"]; + action.__raw = '' + function() + require('cmp').confirm() + end + ''; + options.desc = "confirm the selected item"; + } + + { + key = "<C-d>"; + mode = ["i"]; + action.__raw = '' + function() + require('cmp').mapping.scroll_docs(-4) + end + ''; + options.desc = "Scroll up by four lines"; + } + { + key = "<C-f>"; + mode = ["i"]; + action.__raw = '' + function() + require('cmp').mapping.scroll_docs(4) + end + ''; + options.desc = "Scroll down by four lines"; + } + ]; + plugins.cmp = { /* TODO: integrate this: @@ -43,13 +87,9 @@ in { */ enable = true; autoEnableSources = true; + settings = { - mapping = { - # TODO: add support for desc and which key here - "<C-d>" = "cmp.mapping.scroll_docs(-4)"; # desc = "Scroll up by four lines" - "<C-f>" = "cmp.mapping.scroll_docs(4)"; # desc = "Scroll down by four lines" - "HH" = "cmp.mapping.complete()"; # desc = "Confirm snipped" - }; + mapping = {}; snippet.expand = "function(args) require('luasnip').lsp_expand(args.body) end"; |