-
Notifications
You must be signed in to change notification settings - Fork 233
Add Label Details (Display Source) on Autocomplete #97
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
Comments
Not what you want, but it should be helpful! TIP: render what your want from ctx
|
I know about this, thanks btw, but I’m talking about source like where it comes from, like module a or module b etc |
@0xJWLabs What AbaoFromCUG gave is the first half of the problem (and they knew that, because they said they knew it wasn't what you were after). I was doing this with cmp using a similar method. What you're asking about is the other half of the problem: getting the source information. I do this like this: local function get_lsp_completion_context(completion)
local ok, source_name = pcall(function()
return vim.lsp.get_client_by_id(completion.client_id).name
end)
if not ok then
return nil
end
if source_name == "ts_ls" then
return completion.detail
elseif source_name == "pyright" and completion.labelDetails ~= nil then
return completion.labelDetails.description
elseif source_name == "texlab" then
return completion.detail
elseif source_name == "clangd" then
local doc = completion.documentation
if doc == nil then return end
local import_str = doc.value
import_str = import_str:gsub("[\n]+", "")
local str
str = import_str:match('<(.-)>')
if str then
return '<' .. str .. '>'
end
str = import_str:match('["\'](.-)["\']')
if str then
return '"' .. str .. '"'
end
return nil
end
end
draw = function(ctx)
-- differentiate snippets from LSPs, the user, and emmet
local icon, cmp_item, source = ctx.kind_icon, ctx.item, ctx.item.source
local cmp_ctx
if source == "LSP" then
cmp_ctx = get_lsp_completion_context(cmp_item)
if cmp_ctx == nil then
cmp_ctx = ""
end
end
return {
{ " " },
{
" " .. ctx.item.label .. " ",
fill = true,
hl_group = ctx.deprecated and "BlinkCmpLabelDeprecated" or "BlinkCmpLabel",
max_width = 45,
},
{ cmp_ctx },
{ " " },
}
end, And I get this for clangd: |
Keeping this open as I plan to add support natively in blink |
Please make sure you've read and added the new |
I would like to request a feature enhancement for the autocomplete suggestions when working with modules let’s say in TypeScript. Specifically, when typing a symbol (e.g., a.ab), it would be useful to see the source module or origin of the symbol alongside the kind and label.
For example, when importing a module like:
import a from "abc_module";
As we type a.ab, the autocomplete should display the following format:
Where:
So, for the example above, the autocomplete would display:
Motivation
This feature would greatly improve the developer experience by providing additional context in the autocomplete dropdown. It would help users quickly identify where a symbol is coming from, especially when working with multiple modules or libraries.
Use Case
Expected Behavior
The autocomplete suggestions should have an additional field for label_detail, which shows the originating module or source of the symbol.
Example Autocomplete Suggestion Format
For a.ab, imported from abc_module:
Example from other plugin
nvim-cmp:

The text was updated successfully, but these errors were encountered: