[nvim] replace cmp with blink.cmp

This commit is contained in:
Afonso Franco 2024-12-18 22:51:27 +00:00
parent 94dc8458d0
commit 778e388288
Signed by: afonso
SSH key fingerprint: SHA256:PQTRDHPH3yALEGtHXnXBp3Orfcn21pK20t0tS1kHg54
5 changed files with 73 additions and 173 deletions

View file

@ -1,22 +1,14 @@
{ {
"LuaSnip": { "branch": "master", "commit": "33b06d72d220aa56a7ce80a0dd6f06c70cd82b9d" },
"blame.nvim": { "branch": "main", "commit": "39bb4cda9e658d053a43919b10ca52c0a4d738e1" }, "blame.nvim": { "branch": "main", "commit": "39bb4cda9e658d053a43919b10ca52c0a4d738e1" },
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "blink.cmp": { "branch": "main", "commit": "046a2af7580ba90cda9ffebbab3f1fe68ca1fa59" },
"cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" },
"cmp-nvim-lsp": { "branch": "main", "commit": "99290b3ec1322070bcfb9e846450a46f6efa50f0" },
"cmp-nvim-lsp-signature-help": { "branch": "main", "commit": "031e6ba70b0ad5eee49fd2120ff7a2e325b17fa7" },
"cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" },
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" },
"conform.nvim": { "branch": "master", "commit": "f4e8837878fc5712d053ba3091a73d27d96a09e2" }, "conform.nvim": { "branch": "master", "commit": "f4e8837878fc5712d053ba3091a73d27d96a09e2" },
"friendly-snippets": { "branch": "main", "commit": "efff286dd74c22f731cdec26a70b46e5b203c619" }, "friendly-snippets": { "branch": "main", "commit": "efff286dd74c22f731cdec26a70b46e5b203c619" },
"fzf-lua": { "branch": "main", "commit": "8330321fa135f7fa9e4855099026c4ad622a0c85" }, "fzf-lua": { "branch": "main", "commit": "0527d79322da97375e6d6aa7da9f841adb704918" },
"gruvbox-material": { "branch": "master", "commit": "fca2ff9ba627bbf172548eb52fcbb03f99ba34e9" }, "gruvbox-material": { "branch": "master", "commit": "b95c102f683d6402f84c8e492d3b0641c2d273e4" },
"harpoon": { "branch": "harpoon2", "commit": "a84ab829eaf3678b586609888ef52f7779102263" }, "harpoon": { "branch": "harpoon2", "commit": "a84ab829eaf3678b586609888ef52f7779102263" },
"inc-rename.nvim": { "branch": "main", "commit": "1871ca49ae6ee3e9ebee37955ba10c7b1425974f" }, "inc-rename.nvim": { "branch": "main", "commit": "f4e13df6e2d0b3177a7305dbc1cc7f7ea44b94f1" },
"lazy.nvim": { "branch": "main", "commit": "7e6c863bc7563efbdd757a310d17ebc95166cef3" }, "lazy.nvim": { "branch": "main", "commit": "7e6c863bc7563efbdd757a310d17ebc95166cef3" },
"lazydev.nvim": { "branch": "main", "commit": "f59bd14a852ca43db38e3662395354cb2a9b13e0" }, "lazydev.nvim": { "branch": "main", "commit": "f59bd14a852ca43db38e3662395354cb2a9b13e0" },
"lspkind.nvim": { "branch": "master", "commit": "d79a1c3299ad0ef94e255d045bed9fa26025dab6" },
"ltex-extra.nvim": { "branch": "master", "commit": "24acd044ce7a26b3cdb537cbd094de37c3e1ac45" }, "ltex-extra.nvim": { "branch": "master", "commit": "24acd044ce7a26b3cdb537cbd094de37c3e1ac45" },
"lua-async-await": { "branch": "main", "commit": "652d94df34e97abe2d4a689edbc4270e7ead1a98" }, "lua-async-await": { "branch": "main", "commit": "652d94df34e97abe2d4a689edbc4270e7ead1a98" },
"markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" },
@ -27,7 +19,6 @@
"nui.nvim": { "branch": "main", "commit": "53e907ffe5eedebdca1cd503b00aa8692068ca46" }, "nui.nvim": { "branch": "main", "commit": "53e907ffe5eedebdca1cd503b00aa8692068ca46" },
"nvim-autopairs": { "branch": "master", "commit": "b464658e9b880f463b9f7e6ccddd93fb0013f559" }, "nvim-autopairs": { "branch": "master", "commit": "b464658e9b880f463b9f7e6ccddd93fb0013f559" },
"nvim-bqf": { "branch": "main", "commit": "1b24dc6050c34e8cd377b6b4cd6abe40509e0187" }, "nvim-bqf": { "branch": "main", "commit": "1b24dc6050c34e8cd377b6b4cd6abe40509e0187" },
"nvim-cmp": { "branch": "perf", "commit": "6c3d595f3223c1ae7392d4fde1626355439af6c1" },
"nvim-dap": { "branch": "master", "commit": "567da83810dd9da32f9414d941bc6848715fc102" }, "nvim-dap": { "branch": "master", "commit": "567da83810dd9da32f9414d941bc6848715fc102" },
"nvim-dap-ui": { "branch": "master", "commit": "ffa89839f97bad360e78428d5c740fdad9a0ff02" }, "nvim-dap-ui": { "branch": "master", "commit": "ffa89839f97bad360e78428d5c740fdad9a0ff02" },
"nvim-java": { "branch": "main", "commit": "a36f50c82f922f352d4ce7ac6a3c6b238b3e0a36" }, "nvim-java": { "branch": "main", "commit": "a36f50c82f922f352d4ce7ac6a3c6b238b3e0a36" },
@ -35,24 +26,24 @@
"nvim-java-dap": { "branch": "main", "commit": "55f239532f7a3789d21ea68d1e795abc77484974" }, "nvim-java-dap": { "branch": "main", "commit": "55f239532f7a3789d21ea68d1e795abc77484974" },
"nvim-java-refactor": { "branch": "main", "commit": "ea1420fed5463c9cc976c2b4175f434b3646f0f7" }, "nvim-java-refactor": { "branch": "main", "commit": "ea1420fed5463c9cc976c2b4175f434b3646f0f7" },
"nvim-java-test": { "branch": "main", "commit": "7f0f40e9c5b7eab5096d8bec6ac04251c6e81468" }, "nvim-java-test": { "branch": "main", "commit": "7f0f40e9c5b7eab5096d8bec6ac04251c6e81468" },
"nvim-lspconfig": { "branch": "master", "commit": "ae8a01bb40848490548e5d07b97ed972ed43c2f9" }, "nvim-lspconfig": { "branch": "master", "commit": "9f2c279cf9abe584f03bfeb37c6658d68e3ff49d" },
"nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" }, "nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" },
"nvim-treesitter": { "branch": "master", "commit": "5cf3434c694a94fccfca79588654e57053a68572" }, "nvim-treesitter": { "branch": "master", "commit": "102bc74e093ef54aab57a368db15befeb9ba9d58" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "ad8f0a472148c3e0ae9851e26a722ee4e29b1595" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "ad8f0a472148c3e0ae9851e26a722ee4e29b1595" },
"nvim-ufo": { "branch": "main", "commit": "95cbe2e99901135704aabdc8732d722cf68b12c9" }, "nvim-ufo": { "branch": "main", "commit": "270ca542dae992ffe40274718c63645217ebc8bf" },
"nvim-web-devicons": { "branch": "master", "commit": "1736cb81bdc42e1ee206081a161bdb2af68fb7a1" }, "nvim-web-devicons": { "branch": "master", "commit": "0eb18da56e2ba6ba24de7130a12bcc4e31ad11cb" },
"obsidian.nvim": { "branch": "main", "commit": "ae1f76a75c7ce36866e1d9342a8f6f5b9c2caf9b" }, "obsidian.nvim": { "branch": "main", "commit": "ae1f76a75c7ce36866e1d9342a8f6f5b9c2caf9b" },
"oil.nvim": { "branch": "master", "commit": "dba037598843973b8c54bc5ce0318db4a0da439d" }, "oil.nvim": { "branch": "master", "commit": "dba037598843973b8c54bc5ce0318db4a0da439d" },
"plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" }, "plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" },
"promise-async": { "branch": "main", "commit": "119e8961014c9bfaf1487bf3c2a393d254f337e2" }, "promise-async": { "branch": "main", "commit": "119e8961014c9bfaf1487bf3c2a393d254f337e2" },
"refactoring.nvim": { "branch": "master", "commit": "2db6d378e873de31d18ade549c2edba64ff1c2e3" }, "refactoring.nvim": { "branch": "master", "commit": "2db6d378e873de31d18ade549c2edba64ff1c2e3" },
"rustaceanvim": { "branch": "master", "commit": "25aab238aad3e58f864274449456bdc339981750" }, "rustaceanvim": { "branch": "master", "commit": "0a618c1d1c05a8059880076feccb15301da6993d" },
"smart-splits.nvim": { "branch": "master", "commit": "1e8fa136f1be004c75b4f794f86a7103e077b6ca" }, "smart-splits.nvim": { "branch": "master", "commit": "1e8fa136f1be004c75b4f794f86a7103e077b6ca" },
"snacks.nvim": { "branch": "main", "commit": "33253de59260d40f38ee47faf5c8a7e81f91f42e" }, "snacks.nvim": { "branch": "main", "commit": "282be8bfa8e6f46d6994ff46638d1c155b90753f" },
"spring-boot.nvim": { "branch": "main", "commit": "218c0c26c14d99feca778e4d13f5ec3e8b1b60f0" }, "spring-boot.nvim": { "branch": "main", "commit": "218c0c26c14d99feca778e4d13f5ec3e8b1b60f0" },
"todo-comments.nvim": { "branch": "main", "commit": "ae0a2afb47cf7395dc400e5dc4e05274bf4fb9e0" }, "todo-comments.nvim": { "branch": "main", "commit": "ae0a2afb47cf7395dc400e5dc4e05274bf4fb9e0" },
"undotree": { "branch": "master", "commit": "78b5241191852ffa9bb5da5ff2ee033160798c3b" }, "undotree": { "branch": "master", "commit": "78b5241191852ffa9bb5da5ff2ee033160798c3b" },
"vim-fugitive": { "branch": "master", "commit": "320b18fba2a4f2fe3c8225c778c687e0d2620384" }, "vim-fugitive": { "branch": "master", "commit": "fcb4db52e7f65b95705aa58f0f2df1312c1f2df2" },
"vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" }, "vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" },
"vim-tpipeline": { "branch": "master", "commit": "72a624f97730059bab359cb0b58a23433bfec308" }, "vim-tpipeline": { "branch": "master", "commit": "72a624f97730059bab359cb0b58a23433bfec308" },
"vimtex": { "branch": "master", "commit": "b8bb79b5fb27e9030ade92e75cd9375416f2c666" }, "vimtex": { "branch": "master", "commit": "b8bb79b5fb27e9030ade92e75cd9375416f2c666" },

View file

@ -1,152 +1,59 @@
return { return {
{ {
"yioneko/nvim-cmp", 'saghen/blink.cmp',
branch = "perf", lazy = false,
event = "VeryLazy", dependencies = 'rafamadriz/friendly-snippets',
dependencies = { build = 'cargo build --release',
"hrsh7th/cmp-nvim-lsp", -- lsp opts = {
"hrsh7th/cmp-nvim-lua", -- Nvim API completions keymap = {
"hrsh7th/cmp-nvim-lsp-signature-help", -- Show function signatures preset = 'default',
"hrsh7th/cmp-buffer", --buffer completions ['<C-u>'] = { 'scroll_documentation_up', 'fallback' },
"hrsh7th/cmp-path", --path completions ['<C-d>'] = { 'scroll_documentation_down', 'fallback' },
"hrsh7th/cmp-cmdline", --cmdline completions },
"L3MON4D3/LuaSnip", appearance = {
"rafamadriz/friendly-snippets", use_nvim_cmp_as_default = true,
"saadparwaiz1/cmp_luasnip", nerd_font_variant = 'mono'
"onsails/lspkind.nvim", --lspkind icons },
}, sources = {
config = function() default = { 'lsp', 'path', 'snippets', 'buffer' },
local cmp = require("cmp") providers = {
lazydev = { name = "LazyDev", module = "lazydev.integrations.blink", fallbacks = { "lsp" } },
local luasnip = require("luasnip")
require("luasnip/loaders/from_vscode").lazy_load()
vim.opt.pumheight = 15
local lspkind = require("lspkind")
-- `/` cmdline setup.
cmp.setup.cmdline("/", {
mapping = cmp.mapping.preset.cmdline(),
sources = {
{ name = "buffer" },
}, },
}) },
signature = {
-- `:` cmdline setup. enabled = true,
cmp.setup.cmdline(":", {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = "path" },
}, {
{
name = "cmdline",
option = {
ignore_cmds = { "Man", "!" },
},
},
}),
})
cmp.setup({
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
performance = {
debounce = 0,
throttle = 0,
},
mapping = {
["<C-n>"] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }),
["<C-p>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }),
["<C-u>"] = cmp.mapping.scroll_docs(-4),
["<C-d>"] = cmp.mapping.scroll_docs(4),
["<C-y>"] = cmp.mapping(
cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Insert,
select = true,
}),
{ "i", "c" }
),
["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }),
["<C-l>"] = cmp.mapping(function()
if luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
end
end),
["<C-h>"] = cmp.mapping(function()
if luasnip.jumpable(-1) then
luasnip.jump(-1)
end
end),
},
formatting = {
fields = { "kind", "abbr" },
format = function(entry, vim_item)
local formatted_entry = lspkind.cmp_format({
mode = "symbol",
maxwidth = {
menu = 0
},
show_labelDetails = false
})(entry, vim_item)
formatted_entry.kind = (formatted_entry.kind or "") .. " "
return formatted_entry
end
},
preselect = cmp.PreselectMode.None,
sorting = {
priority_weight = 2,
comparators = {
cmp.config.compare.offset,
cmp.config.compare.exact,
cmp.config.compare.score,
--Make entries that start with underline appear after
function(entry1, entry2)
local _, entry1_under = entry1.completion_item.label:find("^_+")
local _, entry2_under = entry2.completion_item.label:find("^_+")
entry1_under = entry1_under or 0
entry2_under = entry2_under or 0
if entry1_under > entry2_under then
return false
elseif entry1_under < entry2_under then
return true
end
end,
cmp.config.compare.kind,
cmp.config.compare.sort_text,
cmp.config.compare.length,
cmp.config.compare.order,
},
},
sources = cmp.config.sources({
{ name = "nvim_lua" },
{ name = "nvim_lsp" },
--{ name = "luasnip" },
{ name = "path" },
}, {
{ name = "buffer", keyword_length = 5 },
}),
window = { window = {
completion = { max_width = 160,
border = "rounded", max_height = 30,
winhighlight = "Normal:Normal,FloatBorder:Normal,CursorLine:Visual,Search:None", scrollbar = true,
}, }
documentation = { },
border = "rounded", completion = {
winhighlight = "Normal:Normal,FloatBorder:Normal,CursorLine:Visual,Search:None", accept = {
}, auto_brackets = {
enabled = true
}
}, },
experimental = { menu = {
native_menu = false, border = "single",
ghost_text = false, winhighlight = "Normal:Normal,FloatBorder:Normal,CursorLine:Visual,Search:None",
winblend = 0,
draw = {
treesitter = { 'lsp' },
columns = { { 'kind_icon'}, { 'label' } },
}
}, },
}) documentation = {
auto_show = true,
local cmp_autopairs = require("nvim-autopairs.completion.cmp") window = {
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done()) border = 'single',
end max_width = 160,
} max_height = 30,
winblend = 0,
winhighlight = "Normal:Normal,FloatBorder:Normal,CursorLine:Visual,Search:None",
}
},
},
},
},
} }

View file

@ -42,7 +42,7 @@ return {
}, },
}, },
completion = { completion = {
nvim_cmp = true, nvim_cmp = false,
min_chars = 2, min_chars = 2,
}, },
picker = { picker = {

View file

@ -10,13 +10,12 @@ return {
}, },
{ {
'nvim-java/nvim-java', 'nvim-java/nvim-java',
priority = 500, ft = "java",
config = function() config = function()
require('java').setup() require('java').setup()
local lspconfig = require("lspconfig") local lspconfig = require("lspconfig")
local lsp_defaults = lspconfig.util.default_config local lsp_defaults = lspconfig.util.default_config
local capabilities = local capabilities = require('blink.cmp').get_lsp_capabilities(lsp_defaults.capabilities)
vim.tbl_deep_extend("force", lsp_defaults.capabilities, require("cmp_nvim_lsp").default_capabilities())
capabilities.textDocument.foldingRange = { capabilities.textDocument.foldingRange = {
dynamicRegistration = false, dynamicRegistration = false,
lineFoldingOnly = true lineFoldingOnly = true
@ -50,6 +49,9 @@ return {
}, },
{ {
"neovim/nvim-lspconfig", "neovim/nvim-lspconfig",
dependencies = {
'saghen/blink.cmp'
},
event = { "BufReadPost", "BufNewFile" }, event = { "BufReadPost", "BufNewFile" },
config = function() config = function()
local lspconfig = require("lspconfig") local lspconfig = require("lspconfig")
@ -94,10 +96,8 @@ return {
vim.keymap.set("n", "<space>fo", function() conform.format({ lsp_fallback = true }) end, bufopts) vim.keymap.set("n", "<space>fo", function() conform.format({ lsp_fallback = true }) end, bufopts)
end, end,
}) })
local lsp_defaults = lspconfig.util.default_config local lsp_defaults = lspconfig.util.default_config
local capabilities = local capabilities = require('blink.cmp').get_lsp_capabilities(lsp_defaults.capabilities)
vim.tbl_deep_extend("force", lsp_defaults.capabilities, require("cmp_nvim_lsp").default_capabilities())
capabilities.textDocument.foldingRange = { capabilities.textDocument.foldingRange = {
dynamicRegistration = false, dynamicRegistration = false,
lineFoldingOnly = true lineFoldingOnly = true

View file

@ -27,8 +27,10 @@ return {
override = { override = {
["vim.lsp.util.convert_input_to_markdown_lines"] = true, ["vim.lsp.util.convert_input_to_markdown_lines"] = true,
["vim.lsp.util.stylize_markdown"] = true, ["vim.lsp.util.stylize_markdown"] = true,
["cmp.entry.get_documentation"] = true,
}, },
signature = {
enabled = false
}
}, },
presets = { presets = {
inc_rename = true, inc_rename = true,