From ae48758b68e9e29a65713e7279c6b4d3d8ce417c Mon Sep 17 00:00:00 2001 From: Etienne Robert Date: Wed, 8 Apr 2026 00:44:22 +0200 Subject: [PATCH] neovim: remove cmp plugin and enable LSP completion --- nix/pkgs/neovim-wrapped/default.nix | 1 - .../neovim-wrapped/plugins/cmp/config.lua | 85 ------------------- .../neovim-wrapped/plugins/cmp/default.nix | 31 ------- nvim/.config/nvim/init.lua | 13 +++ 4 files changed, 13 insertions(+), 117 deletions(-) delete mode 100644 nix/pkgs/neovim-wrapped/plugins/cmp/config.lua delete mode 100644 nix/pkgs/neovim-wrapped/plugins/cmp/default.nix diff --git a/nix/pkgs/neovim-wrapped/default.nix b/nix/pkgs/neovim-wrapped/default.nix index 97b75a15..116cfd7f 100644 --- a/nix/pkgs/neovim-wrapped/default.nix +++ b/nix/pkgs/neovim-wrapped/default.nix @@ -40,7 +40,6 @@ let # ./plugins/workspace-diagnostics ./plugins/lspconfig ./plugins/harpoon - ./plugins/cmp ./plugins/treesitter ./plugins/surround ./plugins/hardtime diff --git a/nix/pkgs/neovim-wrapped/plugins/cmp/config.lua b/nix/pkgs/neovim-wrapped/plugins/cmp/config.lua deleted file mode 100644 index 859665e6..00000000 --- a/nix/pkgs/neovim-wrapped/plugins/cmp/config.lua +++ /dev/null @@ -1,85 +0,0 @@ --- See `:help cmp` -local cmp = require("cmp") -local luasnip = require("luasnip") -luasnip.config.setup({}) - -local lsp_capabilities = require("cmp_nvim_lsp").default_capabilities() - -vim.lsp.config("*", { capabilities = lsp_capabilities }) - -require("luasnip.loaders.from_vscode").lazy_load() - --- Load custom snippets -require("luasnip.loaders.from_lua").load({ paths = vim.fn.stdpath("config") .. "/lua/snippets" }) - -cmp.setup({ - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - completion = { completeopt = "menu,menuone,noinsert" }, - - window = { - completion = cmp.config.window.bordered(), - documentation = cmp.config.window.bordered(), - }, - - -- For an understanding of why these mappings were - -- chosen, you will need to read `:help ins-completion` - -- - -- No, but seriously. Please read `:help ins-completion`, it is really good! - mapping = cmp.mapping.preset.insert({ - -- Select the [n]ext item - [""] = cmp.mapping.select_next_item(), - -- Select the [p]revious item - [""] = cmp.mapping.select_prev_item(), - - -- Scroll the documentation window [b]ack / [f]orward - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - - -- Accept ([y]es) the completion. - -- This will auto-import if your LSP supports it. - -- This will expand snippets if the LSP sent a snippet. - [""] = cmp.mapping.confirm({ select = true }), - - -- Manually trigger a completion from nvim-cmp. - -- Generally you don't need this, because nvim-cmp will display - -- completions whenever it has completion options available. - [""] = cmp.mapping.complete({}), - - -- Think of as moving to the right of your snippet expansion. - -- So if you have a snippet that's like: - -- function $name($args) - -- $body - -- end - -- - -- will move you to the right of each of the expansion locations. - -- is similar, except moving you backwards. - [""] = cmp.mapping(function() - if luasnip.expand_or_locally_jumpable() then - luasnip.expand_or_jump() - end - end, { "i", "s" }), - [""] = cmp.mapping(function() - if luasnip.locally_jumpable(-1) then - luasnip.jump(-1) - end - end, { "i", "s" }), - - -- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see: - -- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps - }), - sources = { - { name = "luasnip" }, - { name = "emoji" }, - { name = "path" }, - { name = "nvim_lsp" }, - { name = "nvim_lsp_signature_help" }, - { name = "lazydev", group_index = 0 }, - }, - formatting = { - format = require("tailwindcss-colorizer-cmp").formatter, - }, -}) diff --git a/nix/pkgs/neovim-wrapped/plugins/cmp/default.nix b/nix/pkgs/neovim-wrapped/plugins/cmp/default.nix deleted file mode 100644 index 6a7b0cea..00000000 --- a/nix/pkgs/neovim-wrapped/plugins/cmp/default.nix +++ /dev/null @@ -1,31 +0,0 @@ -{ pkgs, ... }: -let - tailwindcss-colorizer-cmp-nvim = pkgs.vimUtils.buildVimPlugin { - pname = "tailwindcss-colorizer-cmp-nvim"; - version = "2024-01-01"; - src = pkgs.fetchFromGitHub { - owner = "roobert"; - repo = "tailwindcss-colorizer-cmp.nvim"; - rev = "3d3cd95e4a4135c250faf83dd5ed61b8e5502b86"; - hash = "sha256-PIkfJzLt001TojAnE/rdRhgVEwSvCvUJm/vNPLSWjpY="; - }; - }; -in -{ - plugins = [ - { - plugin = pkgs.vimPlugins.nvim-cmp; - luaConfig = builtins.readFile ./config.lua; - } - { plugin = pkgs.vimPlugins.cmp-nvim-lsp; } - { plugin = pkgs.vimPlugins.cmp-buffer; } - { plugin = pkgs.vimPlugins.cmp-path; } - { plugin = pkgs.vimPlugins.cmp-cmdline; } - { plugin = pkgs.vimPlugins.cmp_luasnip; } - { plugin = pkgs.vimPlugins.luasnip; } - { plugin = pkgs.vimPlugins.cmp-nvim-lsp-signature-help; } - { plugin = tailwindcss-colorizer-cmp-nvim; } - { plugin = pkgs.vimPlugins.friendly-snippets; } - { plugin = pkgs.vimPlugins.cmp-emoji; } - ]; -} diff --git a/nvim/.config/nvim/init.lua b/nvim/.config/nvim/init.lua index 6d0d89cc..21ad0f12 100644 --- a/nvim/.config/nvim/init.lua +++ b/nvim/.config/nvim/init.lua @@ -5,6 +5,19 @@ vim.loader.enable() require("etrobert") +vim.api.nvim_create_autocmd("LspAttach", { + group = vim.api.nvim_create_augroup("my.lsp", {}), + callback = function(args) + local client = assert(vim.lsp.get_client_by_id(args.data.client_id)) + if client:supports_method("textDocument/completion") then + vim.lsp.completion.enable(true, client.id, args.buf, { autotrigger = true }) + end + end, +}) + +vim.opt.autocomplete = true +vim.opt.completeopt = { "menuone", "menu", "popup", "noinsert" } + vim.cmd.packadd("nvim.undotree") -- TODO: Fix this is injected before plugins are loaded