cmp-nvim-lsp-signature-help
cmp-nvim-lsp-signature-help copied to clipboard
Improve active parameter highlighting
This is a kickoff to implement the feature requested on #30.
Note: although this PR already delivers the intended feature, it would be very nice to make this plugin override vim.lsp.buf.signature_help() with a formatted signature help and proper parameter highlighting. Unfortunately though, that's beyond my knowledge.
@hrsh7th , can you help take a look at this. This is how it looks now.
After updating according to PR.
still look funky with function overload and typescript madness.
For anyone looking at this PR or the other issue - this still didn't work for me with Python. I think the reason is because the --- from if signature.documentation and parameter.documentation.
Before
Python:
Lua:
After
Python:
Lua:
Looking at the markdown with :InspectTree is useful here.
(`a: LiteralString`, /, *paths: LiteralString) -> LiteralString
---
```markdown
thing
```
(document ; [0, 0] - [5, 0] markdown
(section ; [0, 0] - [5, 0] markdown
(setext_heading ; [0, 0] - [2, 0] markdown
heading_content: (paragraph ; [0, 0] - [1, 0] markdown
(inline ; [0, 0] - [0, 63] markdown
(inline ; [0, 0] - [0, 63] markdown_inline
(code_span ; [0, 1] - [0, 19] markdown_inline
(code_span_delimiter) ; [0, 1] - [0, 2] markdown_inline
(code_span_delimiter))))) ; [0, 18] - [0, 19] markdown_inline
(setext_h2_underline)) ; [1, 0] - [1, 3] markdown
(fenced_code_block ; [2, 0] - [5, 0] markdown
(fenced_code_block_delimiter) ; [2, 0] - [2, 3] markdown
(info_string ; [2, 3] - [2, 11] markdown
(language)) ; [2, 3] - [2, 11] markdown
(block_continuation) ; [3, 0] - [3, 0] markdown
(code_fence_content ; [3, 0] - [4, 0] markdown
(document ; [3, 0] - [4, 0] markdown
(section ; [3, 0] - [4, 0] markdown
(paragraph ; [3, 0] - [4, 0] markdown
(inline ; [3, 0] - [3, 5] markdown
(inline))))) ; [3, 0] - [3, 5] markdown_inline
(block_continuation)) ; [4, 0] - [4, 0] markdown
(fenced_code_block_delimiter)))) ; [4, 0] - [4, 3] markdown
vs
(`a: LiteralString`, /, *paths: LiteralString) -> LiteralString
```markdown
thing
```
(document ; [0, 0] - [5, 0] markdown
(section ; [0, 0] - [5, 0] markdown
(paragraph ; [0, 0] - [1, 0] markdown
(inline ; [0, 0] - [0, 63] markdown
(inline ; [0, 0] - [0, 63] markdown_inline
(code_span ; [0, 1] - [0, 19] markdown_inline
(code_span_delimiter) ; [0, 1] - [0, 2] markdown_inline
(code_span_delimiter))))) ; [0, 18] - [0, 19] markdown_inline
(fenced_code_block ; [2, 0] - [5, 0] markdown
(fenced_code_block_delimiter) ; [2, 0] - [2, 3] markdown
(info_string ; [2, 3] - [2, 11] markdown
(language)) ; [2, 3] - [2, 11] markdown
(block_continuation) ; [3, 0] - [3, 0] markdown
(code_fence_content ; [3, 0] - [4, 0] markdown
(document ; [3, 0] - [4, 0] markdown
(section ; [3, 0] - [4, 0] markdown
(paragraph ; [3, 0] - [4, 0] markdown
(inline ; [3, 0] - [3, 5] markdown
(inline))))) ; [3, 0] - [3, 5] markdown_inline
(block_continuation)) ; [4, 0] - [4, 0] markdown
(fenced_code_block_delimiter)))) ; [4, 0] - [4, 3] markdown
Including the --- wraps the signature paragraph to setext_heading.
Anyway, the solution is to either fork this repo and remove the ---s from the code or to add a prefix before the signature.
https://github.com/hrsh7th/cmp-nvim-lsp-signature-help/compare/main...ColinKennedy:cmp-nvim-lsp-signature-help:main
e.g.
if signature.label then
table.insert(documentation, "Signature:")
table.insert(documentation, "\n")
table.insert(documentation, self:_signature_label(signature, parameter_index))
end
Or removing this ---s. Not ideal but either way works.