summaryrefslogtreecommitdiff
path: root/nixvim/plugins/cmp.nix
diff options
context:
space:
mode:
authorseth <[email protected]>2024-07-16 19:04:27 -0400
committerseth <[email protected]>2024-07-16 22:24:21 -0400
commit2e7e1ce219b43bb74f67875200dd4b68758ffd27 (patch)
tree11ca91f55aa47c5b341aaf65f3626c9681a22b07 /nixvim/plugins/cmp.nix
parent255e7c40af44aeedf19a3ca682cfc8a098266e8a (diff)
back to nixvim againnixvim-again
Diffstat (limited to 'nixvim/plugins/cmp.nix')
-rw-r--r--nixvim/plugins/cmp.nix47
1 files changed, 47 insertions, 0 deletions
diff --git a/nixvim/plugins/cmp.nix b/nixvim/plugins/cmp.nix
new file mode 100644
index 0000000..6793435
--- /dev/null
+++ b/nixvim/plugins/cmp.nix
@@ -0,0 +1,47 @@
+{ helpers, ... }:
+{
+ plugins.cmp = {
+ enable = true;
+
+ settings = {
+ completion.completeopt = "menu,menuone,insert";
+
+ snippet.expand = ''
+ function(args)
+ require('luasnip').lsp_expand(args.body)
+ end
+ '';
+
+ mapping = {
+ "<C-n>" = "cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert })";
+ "<C-p>" = "cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert })";
+ "<C-b>" = "cmp.mapping.scroll_docs(-4)";
+ "<C-f>" = "cmp.mapping.scroll_docs(4)";
+ "<C-Space>" = "cmp.mapping.complete()";
+ "<C-e>" = "cmp.mapping.abort()";
+ "<CR>" = helpers.mkRaw ''
+ cmp.mapping({
+ i = function(fallback)
+ if cmp.visible() and cmp.get_active_entry() then
+ cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false })
+ else
+ fallback()
+ end
+ end,
+
+ s = cmp.mapping.confirm({ select = true }),
+ c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }),
+ })
+ '';
+ };
+
+ sources = map (name: { inherit name; }) [
+ "nvim_lsp"
+ "luasnip"
+ "async_path"
+ "buffer"
+ "rg"
+ ];
+ };
+ };
+}