-
Notifications
You must be signed in to change notification settings - Fork 196
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: allow providers customize documentation rendering #650
feat: allow providers customize documentation rendering #650
Conversation
Issue ===== The default way of rendering documentation using markdown and treesitter works great for most cases, but some providers may want to customize the rendering of the documentation. However, some providers may want to customize the rendering in order to add additional information or custom highlighting. Solution ======== Add a new field `render_documentation_fn` to the `CompletionItem` type. Providers can set this to a function that will be called when the documentation is about to be rendered. They can then choose to do custom rendering or fallback to the default rendering. Use cases: - when a treesitter parser is not available for code examples, providers can display colored text using Neovim's regex based syntax highlighting - can add additional highlighting to the documentation - avoid showing extra empty lines caused by markdown fenced code blocks
There are also other approaches available:
|
For now, this only works locally using this branch in blink: Saghen/blink.cmp#650
This looks great, thank you! Sorry I didn't get to this earlier. I've moved the
I'd recommended filling in the
Yeah, especially since changes to that render function could be considered breaking changes. When writing the documentation, I'll be sure to mention it can change at any time and keep it as is for now |
Awesome! No worries, blink has basically exploded in the past week 😄 |
This comment was marked as resolved.
This comment was marked as resolved.
When a result is found for a file whose filetype does not have a treesitter parser installed, fall back to regex based highlighting that is bundled in Neovim. This allows highlighting many more file types out of the box. See here for the blink side implementation and a mini demo: Saghen/blink.cmp#650
) When a result is found for a file whose filetype does not have a treesitter parser installed, fall back to regex based highlighting that is bundled in Neovim. This allows highlighting many more file types out of the box. See here for the blink side implementation and a mini demo: Saghen/blink.cmp#650
This is another attempt at #462
Issue
The default way of rendering documentation using markdown and treesitter
works great for most cases, but some providers may want to customize the
rendering of the documentation.
However, some providers may want to customize the rendering in order to
add additional information or custom highlighting.
Solution
Add a new field
render_documentation_fn
to theCompletionItem
type.Providers can set this to a function that will be called when the
documentation is about to be rendered. They can then choose to do custom
rendering or fallback to the default rendering.
Use cases:
can display colored text using Neovim's regex based syntax highlighting
mini demo:
doc-demo.mov