Draw item.detail inline
Feature Description
For C++ (clangd) function "return type" is returned in item.detail. It is possible to draw it inline with custom component, but
- To highlight it with treesitter I am using something like
local saved_label = ctx.label
ctx.label = detail
vim.list_extend(highlights, require('blink.cmp.completion.windows.render.treesitter').highlight(ctx))
ctx.label = saved_label
Can we accept string in highlight function instead of whole ctx?
2. I want to disable documentation window for items with detail present and no documentation. I can remove detail in custom draw callback with opts.default_implementation({ detail = {} }), but it is still drawn because check is done before https://github.com/Saghen/blink.cmp/blob/efa0b4d94d2dd1e7b572cd9bd83fbf394d60ec4a/lua/blink/cmp/completion/windows/documentation.lua#L67
Can we make documentation detail drawing opt-out and also provide custom component for detail for easier configuration?
Also, It would be nice to allow treesitter-highlighting of label and label_detail as a whole. For now I am using similar hack as in pt. 1 for that.
Can we accept string in highlight function instead of whole ctx?
Yep, works with me
Can we make documentation detail drawing opt-out and also provide custom component for detail for easier configuration?
How about making the completion.documentation.auto_show optionally a function like function(ctx, item): bool, so that you can return false for these items? Right now we only check for initially showing the window but we would want to check it for updating the window as well now
https://github.com/Saghen/blink.cmp/blob/efa0b4d94d2dd1e7b572cd9bd83fbf394d60ec4a/lua/blink/cmp/completion/windows/documentation.lua?plain=1#L44-L55
Would you be willing to send two PRs for these changes?
Will try to find spare time on a weekend. Btw, when detail can be a list of items instead of a string?
Sometimes there's function overloads so a function can have multiple details