I am not sure if this is caused by the LSP or by Neovim, but when I type something like \tr and then I accept the autocompletion to \transclude, it inserts \transclude().
It's useful to compare with https://tangled.org/jonmsterling.com/ocaml-forester/issues/38: currently autocompletion gets triggered even without the backslash, and the interesting thing is that when I accept such an autocompletion, it does not insert the ().
Comments
did:plc:jjiv56ot7d6sgethto3jr3r5
To provide additional context, this may be some weird interaction with Neovim. But in any case, the parentheses are inserted when I use ctrl-y to accept the autocompletion, and not when I simply 'activate' it by selecting it with the arrow keys.
did:plc:4gj3ihsdh6fn3aqq5bdnw5w3
I can't reproduce this, is your neovim config available?
did:plc:jjiv56ot7d6sgethto3jr3r5
Here's a minimal configuration in which the issue can be reproduced:
vim.pack.add {
{ src = 'https://github.com/neovim/nvim-lspconfig' },
{ src = 'https://github.com/saghen/blink.cmp', checkout = 'v1.*' },
}
vim.diagnostic.config { virtual_text = true }
vim.opt.linebreak = true
vim.opt.breakindent = true
vim.opt.expandtab = true
vim.opt.tabstop = 2
vim.opt.shiftwidth = 2
vim.opt.softtabstop = 2
vim.keymap.set({'n', 'v'}, 'j', 'gj')
vim.keymap.set({'n', 'v'}, 'k', 'gk')
vim.filetype.add { extension = { tree = 'forester' } }
vim.lsp.config('forester', {
cmd = { 'forester', 'lsp' },
filetypes = { 'forester' },
root_markers = { 'forest.toml' },
})
require('blink.cmp').setup {
keymap = { preset = 'default' },
completion = {
trigger = { show_on_keyword = false, show_on_trigger_character = true },
documentation = { auto_show = true },
},
sources = { default = { 'lsp', 'path', 'snippets' } },
fuzzy = { implementation = 'lua' },
}
vim.lsp.enable('forester')
To reproduce, start typing \trans and then when the autocompletion menu comes up press ctrl-y to accept the first suggestion. It will complete to \transclude().
did:plc:4gj3ihsdh6fn3aqq5bdnw5w3
This is a blink configuration issue:
https://cmp.saghen.dev/configuration/completion.html#auto-brackets
Since we set the completion kind to "function", it inserts parentheses. IMO it's insane for a completion plugin to make sweeping assumptions about syntax.
For the record, I use neovim's native completion capability:
vim.api.nvim_create_autocmd("LspAttach", {
callback = function(ev)
vim.lsp.completion.enable(true, ev.data.client_id, ev.buf)
end,
})
-- This is a hack to work around a bad interaction with an autopair plugin I use
vim.api.nvim_create_autocmd("TextChangedI", {
callback = function()
local col = vim.fn.col(".") - 1
local before = vim.api.nvim_get_current_line():sub(1, col)
if before:match("%[%[$") or before:match("%]%($") then
vim.lsp.completion.get()
end
end,
})
did:plc:jjiv56ot7d6sgethto3jr3r5
thanks!! That is crazy, indeed.