chore(nvim): replace cmp with blink.cmp
This commit is contained in:
parent
795eabab7b
commit
7bb2561224
4 changed files with 62 additions and 153 deletions
|
@ -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",
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ return {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
completion = {
|
completion = {
|
||||||
nvim_cmp = true,
|
nvim_cmp = false,
|
||||||
min_chars = 2,
|
min_chars = 2,
|
||||||
},
|
},
|
||||||
picker = {
|
picker = {
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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,
|
||||||
|
|
Loading…
Add table
Reference in a new issue