diff --git a/home/modules/cli/nixvim/keymaps.nix b/home/modules/cli/nixvim/keymaps.nix index de0f08b..9eb0620 100644 --- a/home/modules/cli/nixvim/keymaps.nix +++ b/home/modules/cli/nixvim/keymaps.nix @@ -82,6 +82,12 @@ action = "Telescope buffers"; options.desc = "Telescope: List Buffers"; } + { + mode = ["n" "v"]; + key = "ca"; + action = "lua vim.lsp.buf.code_action()"; + options.desc = "LSP Code Action"; + } ]; }; } diff --git a/home/modules/cli/nixvim/plugins/cmp.nix b/home/modules/cli/nixvim/plugins/cmp.nix index e003c9c..58c501b 100644 --- a/home/modules/cli/nixvim/plugins/cmp.nix +++ b/home/modules/cli/nixvim/plugins/cmp.nix @@ -2,10 +2,34 @@ programs.nixvim.plugins.cmp = { enable = true; autoEnableSources = true; - settings.sources = [ - { name = "nvim_lsp"; } - { name = "path"; } - { name = "buffer"; } - ]; + settings = { + sources = [ + { name = "nvim_lsp"; } + { name = "path"; } + { name = "buffer"; } + ]; + mapping = { + "" = '' + cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + else + fallback() + end + end, { "i", "s" }) + ''; + "" = '' + cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + else + fallback() + end + end, { "i", "s" }) + ''; + "" = "cmp.mapping.complete()"; + "" = "cmp.mapping.confirm({ select = true })"; + }; + }; }; }