blink.cmp
blink.cmp copied to clipboard
Support completeopt=longest
Feature Description
Hey.
I like the behavior of completeopt=longest generally, namely that if I have:
ford
foobar
foobaz
and I type
foo<tab>
I want to see foob with the pum staying open and ready for me to decide if I want foobar or foobaz by again triggering completion.
I haven't been able to get that behavior, though apologies if I've missed this somewhere.
(My config FWIW at the moment is:
local has_words_before = function()
local _, col = unpack(vim.api.nvim_win_get_cursor(0))
local line = vim.api.nvim_get_current_line()
return col ~= 0 and not line:sub(col, col):match '%s'
end
return {
{
'saghen/blink.cmp',
version = 'v0.*',
lazy = false,
---@module 'blink.cmp'
---@type blink.cmp.Config
opts = {
keymap = {
['<C-space>'] = { 'show', 'show_documentation', 'hide_documentation' },
['<C-e>'] = { 'hide', 'fallback' },
['<C-p>'] = { 'show', 'select_prev', 'fallback' },
['<C-n>'] = { 'show', 'select_next', 'fallback' },
['<C-b>'] = { 'scroll_documentation_up', 'fallback' },
['<C-f>'] = { 'scroll_documentation_down', 'fallback' },
['<Tab>'] = {
function(cmp)
if not has_words_before() then
return
end
return cmp.select_and_accept()
end,
'snippet_forward',
'fallback'
},
['<S-Tab>'] = { 'snippet_backward', 'fallback' },
},
highlight = { use_nvim_cmp_as_default = true },
trigger = { signature_help = { enabled = true } },
documentation = { auto_show = true },
sources = {
completion = {
enabled_providers = { "lsp", "path", "snippets", "buffer", "lazydev" },
},
providers = {
lsp = { fallback_for = { "lazydev" } },
lazydev = { name = "LazyDev", module = "lazydev.integrations.blink" },
},
},
},
},
}
And thanks for the plugin!