Created
March 31, 2025 13:29
-
-
Save Saghen/e731f6f6e30a4c01f6bc7cdaa389d463 to your computer and use it in GitHub Desktop.
blink.cmp vs nvim-cmp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"saghen/blink.cmp", | |
dependencies = { | |
"rafamadriz/friendly-snippets", | |
"Kaiser-Yang/blink-cmp-dictionary", | |
}, | |
version = "1.*", | |
opts = { | |
keymap = { preset = "super-tab" }, | |
completion = { | |
ghost_text = { enabled = true }, | |
list = { selection = { auto_insert = false } }, | |
documentation = { auto_show = true, window = { border = "rounded" } }, | |
menu = { | |
draw = { | |
padding = 0, | |
columns = { { "kind_icon", gap = 1 }, { gap = 1, "label" }, { "kind", gap = 2 } }, | |
components = { | |
kind_icon = { | |
text = function(ctx) | |
return " " .. ctx.kind_icon .. " " | |
end, | |
highlight = function(ctx) | |
return "BlinkCmpKindIcon" .. ctx.kind | |
end, | |
}, | |
kind = { | |
text = function(ctx) | |
return " " .. ctx.kind .. " " | |
end, | |
}, | |
}, | |
}, | |
}, | |
}, | |
sources = { | |
default = { "lsp", "path", "snippets", "buffer", "dictionary" }, | |
providers = { | |
dictionary = { | |
module = "blink-cmp-dictionary", | |
min_keyword_length = 3, | |
}, | |
} | |
}, | |
fuzzy = { implementation = "prefer_rust" }, | |
}, | |
opts_extend = { "sources.default" }, | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
'hrsh7th/nvim-cmp', | |
dependencies = { | |
'hrsh7th/cmp-nvim-lsp', | |
'hrsh7th/cmp-nvim-lsp-signature-help', | |
'f3fora/cmp-spell', | |
'L3MON4D3/LuaSnip', | |
'rafamadriz/friendly-snippets', | |
}, | |
config = function() | |
local cmp = require('nvim-cmp') | |
cmp.setup({ | |
experimental = { ghost_text = true }, | |
completion = { | |
completeopt = 'menu,menuone,noinsert' | |
}, | |
snippet = { | |
expand = function(args) | |
luasnip.lsp_expand(args.body) | |
end, | |
}, | |
mapping = { | |
["<Tab>"] = cmp.mapping(function(fallback) | |
if cmp.visible() then | |
cmp.confirm({ | |
behavior = cmp.ConfirmBehavior.Insert, | |
select = true, | |
}) | |
else | |
fallback() | |
end | |
end), | |
["<CR>"] = cmp.mapping(function(fallback) | |
if cmp.visible() then | |
cmp.confirm({ | |
behavior = cmp.ConfirmBehavior.Insert, | |
select = true, | |
}) | |
else | |
fallback() | |
end | |
end), | |
["<C-n>"] = cmp.mapping({ | |
c = function() | |
if cmp.visible() then | |
cmp.select_next_item({behavior = cmp.SelectBehavior.Select }) | |
else | |
vim.api.nvim_feedkeys(t("<Down>"), "n", true) | |
end | |
end, | |
i = function(fallback) | |
if cmp.visible() then | |
cmp.select_next_item({behavior = cmp.SelectBehavior.Select }) | |
else | |
fallback() | |
end | |
end, | |
}), | |
["<C-p>"] = cmp.mapping({ | |
c = function() | |
if cmp.visible() then | |
cmp.select_prev_item({behavior = cmp.SelectBehavior.Select }) | |
else | |
vim.api.nvim_feedkeys(t("<Up>"), "n", true) | |
end | |
end, | |
i = function(fallback) | |
if cmp.visible() then | |
cmp.select_prev_item({behavior = cmp.SelectBehavior.Select }) | |
else | |
fallback() | |
end | |
end, | |
}), | |
}, | |
formatting = { | |
fields = { "kind", "abbr", "menu" }, | |
format = function(entry, vim_item) | |
local kind = lspkind.cmp_format({ preset = "codicons", maxwidth = 50 })(entry, vim_item) | |
local strings = vim.split(kind.kind, "%s", { trimempty = true }) | |
kind.kind = " " .. (strings[1] or "") .. " " | |
kind.menu = " " .. (strings[2] or "") | |
return kind | |
end, | |
}, | |
sources = { | |
{ name = "nvim_lsp" }, | |
{ name = "luasnip" }, | |
{ name = "spell" }, | |
{ name = "nvim_lsp_signature_help" }, | |
}, | |
window = { | |
completion = { | |
winhighlight = "Normal:Pmenu,FloatBorder:FloatBorder,CursorLine:Visual,Search:None", | |
col_offset = -3, | |
side_padding = 0, | |
}, | |
documentation = { | |
border = "rounded", | |
side_padding = 2, | |
winhighlight = "Normal:CmpDocumentation,FloatBorder:CmpDocumentationBorder,CursorLine:Visual,Search:None", | |
}, | |
}, | |
}) | |
end | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment