Compatibility with blink.cmp completer?
I have seen some posts on Reddit about cmp-vimtex being only used for nvim-cmp. I was using nvim-cmp and cmp-vimtex worked like a charm. I especially liked how it helped me view and complete bib citations. Is there any way to make it work equally well with blink.cmp instead of nvim-cmp? I just switched last week and I tried to also use blink.compat which is supposed to help blink be compatible with source providers for nvim-cmp, but it doesn't seem to be working.
Thanks so much for this plugin. I really like it and I just hope that it can eventually work with blink.cmp because it seems that this is overtaking nvim-cmp as the go-to completer for neovim.
Thank you for contributing this (and in the past)! Unfortunately, I've sort of fallen behind on the Neovim community and haven't really moved to using blink. From a time-management perspective, it seems unlikely that I'll able to, in the future.
I would really like to see this plugin keeping up with current developments, but I just don't have the time. Unless someone contributes to the project I don't I'll be able to.
I completely understand. I would like to contribute but I don’t have the knowledge base to know how to develop a plugin. I do appreciate all the work you put into this for the community.
—Jeff
On 13 Feb 2025, at 15:52, micangl wrote:
micangl left a comment (micangl/cmp-vimtex#30)
Thank you for contributing this (and in the past)! Unfortunately, I've sort of fallen behind on the Neovim community and haven't really moved to using blink. From a time-management perspective, it seems unlikely that I'll able to, in the future.
I would really like to see this plugin keeping up with current developments, but I just don't have the time. Unless someone contributes to the project I don't I'll be able to.
-- Reply to this email directly or view it on GitHub: https://urldefense.com/v3/https://github.com/micangl/cmp-vimtex/issues/30*issuecomment-2657786792;Iw!!KwNVnqRv!ExAEv_u8EWjHDjdsbo8iCvmjQWDpgEPPOI4vJvY9pthUhtMo_OJh87MOinaXdMGDDswWO5OmTwelPtbCMyHBEdodZbM$ You are receiving this because you authored the thread.
Message ID: @.***>
@jwbullard
This works for me.
return {
"saghen/blink.cmp",
enabled = true,
-- In case there are breaking changes and you want to go back to the last
-- working release
-- https://github.com/Saghen/blink.cmp/releases
-- version = "v0.9.3",
dependencies = {
"micangl/cmp-vimtex",
dependencies = {
{
"saghen/blink.compat",
version = "*",
lazy = true,
opts = {},
},
},
},
opts = function(_, opts)
opts.sources = vim.tbl_deep_extend("force", opts.sources or {}, {
default = { "lsp", "path", "snippets", "buffer", "vimtex" },
providers = {
lsp = {
name = "lsp",
enabled = true,
module = "blink.cmp.sources.lsp",
kind = "LSP",
min_keyword_length = 3,
score_offset = 90, -- the higher the number, the higher the priority
},
path = {
name = "Path",
module = "blink.cmp.sources.path",
score_offset = 25,
fallbacks = { "snippets", "buffer" },
min_keyword_length = 2,
opts = {
trailing_slash = false,
label_trailing_slash = true,
get_cwd = function(context)
return vim.fn.expand(("#%d:p:h"):format(context.bufnr))
end,
show_hidden_files_by_default = true,
},
},
buffer = {
name = "Buffer",
enabled = true,
max_items = 3,
module = "blink.cmp.sources.buffer",
min_keyword_length = 2,
score_offset = 15, -- the higher the number, the higher the priority
},
snippets = {
name = "snippets",
enabled = true,
max_items = 15,
min_keyword_length = 2,
module = "blink.cmp.sources.snippets",
score_offset = 85, -- the higher the number, the higher the priority
},
-- add vimtex as sources
-- credit: https://www.reddit.com/r/neovim/comments/1invqwg/comment/mcgttl5/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button
vimtex = {
name = "vimtex",
min_keyword_length = 2,
module = "blink.compat.source",
score_offset = 80,
},
},
})
opts.cmdline = {
-- command line completion, thanks to dpetka2001 in reddit
-- https://www.reddit.com/r/neovim/comments/1hjjf21/comment/m37fe4d/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button
sources = function()
local type = vim.fn.getcmdtype()
if type == "/" or type == "?" then
return { "buffer" }
end
if type == ":" then
return { "cmdline" }
end
return {}
end,
}
opts.completion = {
menu = {
border = "single",
},
documentation = {
auto_show = true,
window = {
border = "single",
},
},
-- Displays a preview of the selected item on the current line
ghost_text = {
enabled = true,
},
}
opts.snippets = {
preset = "luasnip",
-- This comes from the luasnip extra, if you don't add it, won't be able to
-- jump forward or backward in luasnip snippets
-- https://www.lazyvim.org/extras/coding/luasnip#blinkcmp-optional
expand = function(snippet)
require("luasnip").lsp_expand(snippet)
end,
active = function(filter)
if filter and filter.direction then
return require("luasnip").jumpable(filter.direction)
end
return require("luasnip").in_snippet()
end,
jump = function(direction)
require("luasnip").jump(direction)
end,
}
-- The default preset used by lazyvim accepts completions with enter
-- I don't like using enter because if on markdown and typing
-- something, but you want to go to the line below, if you press enter,
-- the completion will be accepted
-- https://cmp.saghen.dev/configuration/keymap.html#default
opts.keymap = {
preset = "default",
["<Tab>"] = { "snippet_forward", "fallback" },
["<S-Tab>"] = { "snippet_backward", "fallback" },
["<Up>"] = { "select_prev", "fallback" },
["<Down>"] = { "select_next", "fallback" },
["<C-p>"] = { "select_prev", "fallback" },
["<C-n>"] = { "select_next", "fallback" },
["<S-k>"] = { "scroll_documentation_up", "fallback" },
["<S-j>"] = { "scroll_documentation_down", "fallback" },
["<C-space>"] = { "show", "show_documentation", "hide_documentation" },
["<C-e>"] = { "hide", "fallback" },
}
return opts
end,
}
Hi, I've come from the future to say that the @tienlonghungson config does indeed work for me as well.
Maybe this should be mentioned in the README and tutorial.
Would be nice to know exactly what's essential in there. I guess that's the adding of cmp-nvim as a dependency and source in the Blink setup.
The reddit comment they cited as the source of the solution has a MWE.
I'm not the smartest or the most experienced, but I could contribute to the docs if this is correct (and if there isn't a more fit contributor available).