diff --git a/modules/nix/nvim/cmp.nix b/modules/nix/nvim/cmp.nix index 56e5385..5c2de05 100644 --- a/modules/nix/nvim/cmp.nix +++ b/modules/nix/nvim/cmp.nix @@ -7,33 +7,42 @@ cmp = { enable = true; autoEnableSources = true; - sources = [ - {name = "nvim_lsp";} - {name = "path";} - {name = "buffer";} - {name = "luasnip";} - ]; - mapping = { - "" = "cmp.mapping.confirm({ select = true })"; - "" = { - action = '' - function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.expandable() then - luasnip.expand() - elseif luasnip.expand_or_jumpable() then - luasnip.expand_or_jump() - elseif check_backspace() then - fallback() - else - fallback() - end - end - ''; - modes = [ "i" "s" ]; - }; - }; - }; + settings = { + sources = [ + {name = "nvim_lsp";} + {name = "path";} + {name = "buffer";} + {name = "luasnip";} + ]; + mapping = { + __raw = '' + mapping = cmp.mapping.preset.insert({ + [""] = 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.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.abort(), + [""] = cmp.mapping.abort(), + [""] = cmp.mapping.confirm({ select = false }), + }), + ''; + }; + }; + }; }; } diff --git a/modules/nix/nvim/default.nix b/modules/nix/nvim/default.nix index f778d79..ef67bb5 100644 --- a/modules/nix/nvim/default.nix +++ b/modules/nix/nvim/default.nix @@ -3,7 +3,7 @@ imports = [ nixvim.homeManagerModules.nixvim ./cmp.nix - #./lsp.nix + ./lsp.nix ]; programs.nixvim = { enable = true;