From 6d0b7a0ed7cd373b8c4c6a46b5eaf391123e1700 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jalil=20David=20Salam=C3=A9=20Messina?= Date: Fri, 8 Mar 2024 23:14:18 +0100 Subject: [PATCH] fix(nvim): Update cmp config due to rewrite --- nvim/nixvim.nix | 14 ----- nvim/plugins.nix | 147 ++++++++++++++++++++++------------------------- 2 files changed, 68 insertions(+), 93 deletions(-) diff --git a/nvim/nixvim.nix b/nvim/nixvim.nix index d9f699e..a4ae190 100644 --- a/nvim/nixvim.nix +++ b/nvim/nixvim.nix @@ -73,20 +73,6 @@ in end -- END: Lua Pre Config ''; - extraConfigLuaPost = '' - -- Lua Post Config - do -- Setup cmp-cmdline - local cmp = require "cmp" - cmp.setup.cmdline("/", { - mapping = cmp.mapping.preset.cmdline(), - sources = cmp.config.sources { {name = "rg" }, { name = "buffer" } }, - }) - cmp.setup.cmdline(":", { - mapping = cmp.mapping.preset.cmdline(), - sources = cmp.config.sources({ { name = "path" } }, { { name = "cmdline" } }) - }) - end - ''; }) ]; } diff --git a/nvim/plugins.nix b/nvim/plugins.nix index e44d702..94b0289 100644 --- a/nvim/plugins.nix +++ b/nvim/plugins.nix @@ -1,15 +1,72 @@ { lib }: { - cmp-buffer.enable = true; - cmp-clippy.enable = true; - cmp-cmdline.enable = true; - cmp-nvim-lsp.enable = true; - cmp-nvim-lsp-document-symbol.enable = true; - cmp-nvim-lsp-signature-help.enable = true; - cmp-path.enable = true; - cmp-rg.enable = true; - cmp-spell.enable = true; - cmp-treesitter.enable = true; - cmp-zsh.enable = true; + cmp = { + enable = true; + cmdline = { + "/" = { + mapping.__raw = "cmp.mapping.preset.cmdline()"; + sources = [{ name = "rg"; } { name = "buffer"; }]; + }; + ":" = { + mapping.__raw = "cmp.mapping.preset.cmdline()"; + sources = [{ name = "path"; } { name = "cmdline"; }]; + }; + }; + settings = { + # Snippets + snippet.expand = "function(args) require('luasnip').lsp_expand(args.body) end"; + # Completion Sources + sources = [ + { name = "buffer"; groupIndex = 3; } + { name = "calc"; groupIndex = 2; } + { name = "conventionalcommits"; groupIndex = 1; } + { name = "crates"; groupIndex = 1; } + { name = "luasnip"; groupIndex = 1; } + { name = "nvim_lsp"; groupIndex = 1; } + { name = "nvim_lsp_document_symbol"; groupIndex = 1; } + { name = "nvim_lsp_signature_help"; groupIndex = 1; } + { name = "path"; groupIndex = 2; } + { name = "spell"; groupIndex = 2; } + { name = "treesitter"; groupIndex = 2; } + { name = "zsh"; groupIndex = 1; } + ]; + mapping.__raw = '' + cmp.mapping.preset.insert({ + [""] = function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif require("luasnip").expand_or_jumpable() then + require("luasnip").expand_or_jump() + elseif has_words_before() then + cmp.complete() + else + fallback() + end + end, + [""] = function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif require("luasnip").jumpable(-1) then + require("luasnip").jump(-1) + else + fallback() + end + end, + [""] = cmp.mapping(function(fallback) + if require("luasnip").choice_active() then + require("luasnip").next_choice() + else + fallback() + end + end), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete { }, + [""] = cmp.mapping.close(), + [""] = cmp.mapping.confirm { select = true }, + }) + ''; + }; + }; conform-nvim = { enable = true; formattersByFt = { @@ -77,74 +134,6 @@ lsp_doc_border = false; }; }; - nvim-cmp = { - enable = true; - # Snippets - snippet.expand = "luasnip"; - # Completion Sources - sources = [ - { name = "buffer"; groupIndex = 3; } - { name = "calc"; groupIndex = 2; } - { name = "conventionalcommits"; groupIndex = 1; } - { name = "crates"; groupIndex = 1; } - { name = "luasnip"; groupIndex = 1; } - { name = "nvim_lsp"; groupIndex = 1; } - { name = "nvim_lsp_document_symbol"; groupIndex = 1; } - { name = "nvim_lsp_signature_help"; groupIndex = 1; } - { name = "path"; groupIndex = 2; } - { name = "spell"; groupIndex = 2; } - { name = "treesitter"; groupIndex = 2; } - { name = "zsh"; groupIndex = 1; } - ]; - # Menu Icons - mappingPresets = [ "insert" ]; - mapping = { - "" = { - modes = [ "i" "s" ]; - action = '' - function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif require("luasnip").expand_or_jumpable() then - require("luasnip").expand_or_jump() - elseif has_words_before() then - cmp.complete() - else - fallback() - end - end - ''; - }; - "" = { - modes = [ "i" "s" ]; - action = '' - function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif require("luasnip").jumpable(-1) then - require("luasnip").jump(-1) - else - fallback() - end - end - ''; - }; - "" = '' - cmp.mapping(function(fallback) - if require("luasnip").choice_active() then - require("luasnip").next_choice() - else - fallback() - end - end) - ''; - "" = "cmp.mapping.scroll_docs(-4)"; - "" = "cmp.mapping.scroll_docs(4)"; - "" = "cmp.mapping.complete {}"; - "" = "cmp.mapping.close()"; - "" = "cmp.mapping.confirm { select = true }"; - }; - }; nvim-colorizer = { enable = true; userDefaultOptions = {