-
-
Notifications
You must be signed in to change notification settings - Fork 10
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
feat: pass kind to cmp #10
Conversation
Filtering example: {
sources = cmp.config.sources({
{
name = "treesitter",
---@diagnostic disable-next-line: unused-local
entry_filter = function(entry, _ctx)
local banned_kinds = {
"Error",
"Comment",
}
local kind = entry:get_completion_item().cmp.kind_text
if vim.tbl_contains(banned_kinds, kind) then return false end
return true
end,
},
}),
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Hi, this dynamic |
@CharlesChiuGit @ray-x Maybe we can remove the part that makes the tree-sitter identifier camelcase, I think that was some bad judgement from my side, and it would be better to give users the raw information and let them patch it with the format handler. |
@3rd thanks for the quick reply! That would be a nice idea! |
@3rd I think I was wrong and it's not based on semantic tokens, but SymbolKind, it's missing at least Array, Object, Key from what I can see. |
hmmm, that's weird. I had add a list of icons to cmp. And concatenate those tables and pass it to lspkind, if that's the case, I shouldn't have errors, no? |
Yep, should be ok, but you can't add an entry for each tree-sitter identifier, they're too many. Easiest way is to configure a default icon. |
hmmm, sounds reasonable. let me try if that's possible to add a default icon for this cmp source. |
I think I misunderstood your meaning. You mean to add a default icon for cmp instead this certain source? |
@CharlesChiuGit yep, in cmp, you can add it only to this source if you want: format = function(entry, vim_item)
if entry.source.name == "treesitter" then
...
end
end or you can use lspkind to get only the symbol, check if it's a symbol or a longer string, and if it's a longer string swap to a default symbol and append the kind. but the best thing would be for lspkind to add a default symbol |
nvim-cmp follows the type system of lsp; anything other than the 25 contained in CompletionItemKind should not be passed to |
@uga-rosa maybe the best way to do it is to let the users map the kinds themselves. |
Actually, I prefer the case change as default lol.
Indeed, it's not from the LSPs, other cmp sources like https://github.com/tzachar/cmp-tabnine and https://github.com/Exafunction/codeium.vim also define their own |
This change would pass the symbol kind back to cmp.
It's very basic, and it converts the kinds from
dot.case
toCamelCase
to overlap with at least some of the LSP kinds, and can also be used for filtering out things likeComment
s withentry_filter
.Could be done better by maintaining a tree-sitter <-> LSP kind mappings, but it's good enough for me, and maybe it helps someone else trying to work around all the completion items being
Text
.Thanks for making the completion source, it's super fast and the workflow is awesome with LSP replacing the tree-sitter entries when it's done resolving.
cmp.mp4