From ec81bcfa73b5ad57009578a776c76151fd81302f Mon Sep 17 00:00:00 2001 From: Martin Larsson Date: Thu, 23 May 2024 11:00:28 +0200 Subject: [PATCH] Remove snippets and buffer completion from nvim cmp, Copilot does a great job of this, now we only have completions for defined variables, functions, and keywords etc --- home/.config/nvim/lua/plugs/cmp.lua | 18 ++++++++---------- home/.config/nvim/lua/plugs/mason_lsp.lua | 1 + 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/home/.config/nvim/lua/plugs/cmp.lua b/home/.config/nvim/lua/plugs/cmp.lua index 09a3b76..ce4ee98 100644 --- a/home/.config/nvim/lua/plugs/cmp.lua +++ b/home/.config/nvim/lua/plugs/cmp.lua @@ -7,15 +7,10 @@ return { "hrsh7th/cmp-cmdline", }, config = function() - -- Set up nvim-cmp. local cmp = require("cmp") + cmp.setup({ - snippet = { - expand = function(args) - vim.snippet.expand(args.body) -- For native neovim snippets (Neovim v0.10+) - end, - }, window = { completion = cmp.config.window.bordered(), documentation = cmp.config.window.bordered(), @@ -26,11 +21,14 @@ return { [""] = cmp.mapping.complete(), [""] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. }), - sources = cmp.config.sources({ - { name = "nvim_lsp" }, - }, + sources = cmp.config.sources( { - { name = "buffer" }, + { + name = "nvim_lsp", + entry_filter = function(entry) + return cmp.lsp.CompletionItemKind.Snippet ~= entry:get_kind() + end, + }, }) }) diff --git a/home/.config/nvim/lua/plugs/mason_lsp.lua b/home/.config/nvim/lua/plugs/mason_lsp.lua index 7ff4895..640250a 100644 --- a/home/.config/nvim/lua/plugs/mason_lsp.lua +++ b/home/.config/nvim/lua/plugs/mason_lsp.lua @@ -7,6 +7,7 @@ local function setup_lsp(server_names) local server = lspconfig[server_name] if server then local server_table = require("language_servers/" .. server_name) + capabilities.textDocument.completion.completionItem.snippetSupport = false server_table.capabilities = capabilities server_table.on_attach = function(client, bufnr) vim.lsp.inlay_hint.enable(true, { bufnr = bufnr })