Created
March 30, 2025 23:43
-
-
Save mhartington/d2e757e1cdb2ed678ee755de640050a0 to your computer and use it in GitHub Desktop.
blink 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-git" }, | |
{ "Kaiser-Yang/blink-cmp-dictionary" }, | |
}, | |
version = "1.*", | |
opts = { | |
keymap = { preset = "super-tab" }, | |
appearance = { | |
nerd_font_variant = "mono", | |
}, | |
completion = { | |
ghost_text = { enabled = true }, | |
list = { | |
selection = { | |
preselect = true, | |
auto_insert = false, | |
}, | |
}, | |
trigger = { | |
show_on_trigger_character = true, | |
}, | |
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 = { "git", "dictionary", "lsp", "path", "snippets", "buffer" }, | |
providers = { | |
git = { | |
module = "blink-cmp-git", | |
name = "Git", | |
enabled = function() | |
return vim.tbl_contains({ "octo", "gitcommit", "markdown" }, vim.bo.filetype) | |
end, | |
opts = { }, | |
}, | |
dictionary = { | |
module = "blink-cmp-dictionary", | |
name = "Dict", | |
min_keyword_length = 3, | |
opts = { }, | |
}, | |
}, | |
}, | |
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
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", | |
}, | |
}, | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment