-
Notifications
You must be signed in to change notification settings - Fork 193
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
[mini.completion] Missing function / variable definition (result.detail) from popup docs for languages like TypeScript #1258
Comments
As an additional item which is related, but more of a "nice to have" than above which is pretty important to the core functionality of completions, there is also the In This is super nice, especially for ambiguous names that may have options from multiple libraries... BUT this I could do without, as opposed to the original issue above which I consider vital as props on an object will not even show you which type they are (no docs popup comes up at all for variable props). |
Thanks for the suggestion! I've only now found out about the Same goes for I'll take some time to think about this, but currently I am skeptical that this will be part of 'mini.completion'. |
Thanks for taking a look so quickly. This is not meant to be "aggressive" 🤣 but just to clarify understanding of the impact, without having the detail I really don't think mini.completion is usable for me as a typescript dev. The function definitions is one thing, but the main deal breaker is that for an object properties, it shows no docs pop up at all because it is only in the detail field. For example, if I have this object: FooObj {
foo: string;
bar: number;
baz: Date;
} And if I have to supply it as a prop to a function like: fooFunc(fooObj) When I do: fooFunc({
baz| // (autocomplete shows no "doc" popup so I do not know the type of the prop is a Date)
}) Hopefully this makes sense. I would agree this likely is something the typescript LSP could populate things differently, but from experience I know getting the LSP to change is not an option 😉). |
@echasnovski curious your thoughts on a hook that provides the docs.value, details and maybe the labelDetails as args for the hook and then the user can choose how to populate the docs popup? If the docs popup is correct then I am not too worried about the initial completion item list. Although in a perfect world a hook for the completion menu items would be amazing. Thoughts? |
I suppose would also need to provide the lsp name as an arg so you could do conditional logic based on the lsp/language. |
There is Also, after looking at code, the |
@echasnovski I'll do a little PR as proof of concept and make sure it could work out simple enough. No pressure to integrate it as I'm fine with just using my fork for the time being. |
Sorry on mobile so did not see your response before sending this. |
Would you mind only making a change in your fork and post the link to the branch/commit? I'd like to have PR count as low as possible and I have doubts there will be changes in 'mini.completion' regarding this issue. |
No problem. And see my latest message above. I did not see your other message before I sent that. I will dig into the processitems config and see if it gives what is needed but last time I checked it did not. Part of it may be that the docs come through after the initial request and only when you ctrl-n/p select an item and it gets the secondary response / request from the LSP in your code. Not at a computer right now so explaining off memory. Will take a look when back at computer tonight likely after I put the kids to bed. |
@echasnovski so I think this may be the issue. See the lines from your code below. Correct me if I'm wrong, but this "secondary" request when there is no documentation returned sends mini.nvim/lua/mini/completion.lua Lines 1034 to 1052 in 61e5d46
Does what I am saying make sense? I am still somewhat new to diving into the LSP completions stuff so if I am not describing it very well let me know and I can try to clarify. |
Are you sure you aren't mixing up |
Here is where |
And here is where |
Yes, using I think the reason |
Yeah that makes sense! labelDetails I recall only showed up in nvim-cmp more recently (in the last few months) so likely similar reason. The problem with Additionally the reason I think this is true is because |
As well, label and labelDetails are next to each other in the lsp docs. And then detail appears next to documentation and as mentioned above, start with a similar description "human readable..." TLDR: label / labelDetails should be together in the completions menu. And documentation / detail should go together in the docs popup. |
This depends on the LSP server. So, I am afraid, it is not as black and white. I'll take a look later. |
Should be the tag line for LSP generally 🤣 |
@echasnovski to one of my earlier points, a lot of this could be solved by the user if the process_items hook also processed the additional LSP response when items are selected. Or a second hook. Because none of that passes through it so users have no way to customize that part (which for typescript is where all the detail and docs comes through). See here: #1258 (comment) |
Looks like what I am referring to (for clarity) is exactly what you called out in your docs / notes here: mini.nvim/lua/mini/completion.lua Lines 99 to 106 in 61e5d46
And also similarly here: mini.nvim/lua/mini/completion.lua Lines 930 to 934 in 61e5d46
|
While I am digging into it, documenting for future references. LUAtextDocument/completionNo completionItem/resolveThe TypeScript (vtsls / tsserver)textDocument/completion
completionItem/resolve
|
@echasnovski here is my hacky working fork for completions for everything discussed above: GitMurf@cc8101f One thing that is not ideal is for languages like lua, where the LSP provides |
Contributing guidelines
Module(s)
mini.completion
Description
For languages like TypeScript I was struggling with mini.completions because the popup docs for each completion item was not showing the function / variable definition (i.e., function signature / variable type). As you can see here, for the JSON.stringify() builtin function, it only includes the documentation "annotations" explaining the function but not the function definition itself.
But as you can see in the LSP response, the
detail
property holds this information. So we need to concatenateresult.detail
withdocumentation.value
.Compared to a language like Lua, the function definition is included in the documentation.value prop in the markdown.
Now the one caveat is that for a language like Lua, it has
function
in theresult.detail
prop so if you concatenated it for Lua, it would be a little redundant since the full function definition is also included at the start of thedocumentation.value
prop.Neovim version
Neovim nightly
Steps to reproduce
Explained in detail in description...
Expected behavior
Explained in detail in description...
Actual behavior
Explained in detail in description...
The text was updated successfully, but these errors were encountered: