-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Built-in LSP completion not filtering on label #29287
Comments
This is kinda intentional to support the But we could add an option to make it stricter |
From my understanding,
Yes, this would be great. It can be added as an option on |
@mfussenegger I'd like to address this, but want to discuss it before I start.
vim.lsp.completion.enable(true, client.id, bufnr, {
autotrigger = true,
filter = function(item, prefix)
---@cast item lsp.CompletionItem
---@cast prefix string
return vim.fn.matchfuzzy({ item.label }, prefix)
end
}) This would either be a complete substitution for the current filter that filters by
vim.lsp.completion.enable(true, client.id, bufnr, {
autotrigger = true,
fallbackFilterByLabel = true
}) Personally, I'd prefer option 1. since it gives more flexibility, but option 2. is also perfectly fine since it solves this issue. |
Although the built-in pum completion mechanism will filter anyway on the next input it is odd if the initial popup shows entries which don't match the current prefix. Using fuzzy match on the label/prefix is compatible with `completeopt+=fuzzy` and also doesn't seem to break postfix snippet cases Closes neovim#29287
Although the built-in pum completion mechanism will filter anyway on the next input it is odd if the initial popup shows entries which don't match the current prefix. Using fuzzy match on the label/prefix is compatible with `completeopt+=fuzzy` and also doesn't seem to break postfix snippet cases Closes neovim#29287
Problem
According to LSP specification, completion items should be filtered by
filterText
property, and if it does not exist, it should filter bylabel
. Quoting from https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#completionItem:New built-in LSP completion filters only by
filterText
if it is defined, but it does not apply filtering on thelabel
as a fallback.https://github.com/neovim/neovim/blob/master/runtime/lua/vim/lsp/completion.lua#L241-L243
Steps to reproduce
vtsls
language server (this one was easiest to reproduce)nvim -u minimal_init.lua
:edit test.js
Math.mi
, this should show correct completion since it's doing "live" filtering<C-space>
, it will show a lot of unmatched itemsExpected behavior
Expected to properly filter by the prefix, which is in my example
mi
.Neovim version (nvim -v)
NVIM v0.11.0-dev-37bf4c5
Vim (not Nvim) behaves the same?
N/A
Operating system/version
Arch Linux
Terminal name/version
kitty 0.35.1
$TERM environment variable
xterm-kitty
Installation
bob (https://github.com/MordechaiHadad/bob
The text was updated successfully, but these errors were encountered: