From ac7f8ef19b645af5afe8f5f8044868a0cf25a620 Mon Sep 17 00:00:00 2001 From: Nathan Reiner Date: Sat, 28 Sep 2024 15:17:50 +0200 Subject: nixvim: refactor --- common/home/programs/nixvim/plugins/cmp.nix | 45 +++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 common/home/programs/nixvim/plugins/cmp.nix (limited to 'common/home/programs/nixvim/plugins/cmp.nix') diff --git a/common/home/programs/nixvim/plugins/cmp.nix b/common/home/programs/nixvim/plugins/cmp.nix new file mode 100644 index 0000000..27cca04 --- /dev/null +++ b/common/home/programs/nixvim/plugins/cmp.nix @@ -0,0 +1,45 @@ +{ ... }: +{ + enable = true; + autoEnableSources = true; + settings = { + mapping = { + "" = "cmp.mapping.scroll_docs(-4)"; + "" = "cmp.mapping.scroll_docs(4)"; + "" = "cmp.mapping.complete()"; + "" = "cmp.mapping.abort()"; + "" = "cmp.mapping.confirm({ select = true })"; + "" = '' + 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" }) + ''; + }; + snippet = { + expand = '' + function(args) + require('luasnip').lsp_expand(args.body) + end + ''; + }; + sources = [ + { name = "nvim_lsp"; } + { name = "luasnip"; } + { name = "path"; } + { name = "buffer"; } + ]; + }; +} -- cgit v1.2.3-70-g09d2