reddit / emacs

LSP function parameters completion

[deleted] · 2022-05-10 09:48
[deleted] · 2022-05-10 09:51
Ever since this pr [https://github.com/typescript-language-server/typescript-language-server/pull/303](https://github.com/typescript-language-server/typescript-language-server/pull/303) got merged, typescript-language-server supports function parameters completion. As you can see from the video, it works in neovim, but for some reason doesn't work in emacs. Has anyone managed or tried to get it working?
yyoncho · 2022-05-10 10:07
if you have yasnippet on and if you are using the same server version then it should work in lsp-mode as well. We have that feature implemented for like 4 years.
[deleted] · 2022-05-10 10:30
Yes, I do, I tried these settings to no avail (use-package lsp-mode :config (setq lsp-javascript-suggest-complete-function-calls t) (lsp-register-custom-settings '(("completions.completeFunctionCalls" t t))) :custom (lsp-enable-snippet t)) (use-package typescript-mode :mode ("\\.ts\\'" "\\.js\\'") :hook (typescript-mode . lsp-deferred)
yyoncho · 2022-05-10 10:36
I don't see yasnippet here
[deleted] · 2022-05-10 10:42
Here's my init.el with yasnippets: https://gist.github.com/kuator/89d67eb38ea8a02fd137778f3551d0d6
yyoncho · 2022-05-10 10:56
I checked the code: The issue is in the server. They are populating the `insertText` as part of the resolve request which is wrong. As per spec, the `insertText` should be populated in advance and it should not require calling the server.
yyoncho · 2022-05-10 10:59
I added comment in the review: https://github.com/typescript-language-server/typescript-language-server/pull/303/files#r869102064
[deleted] · 2022-05-10 11:02
Thank you for taking your time to look into the issue!
yyoncho · 2022-05-10 11:08
if you wish, you can use the following patch: https://github.com/yyoncho/lsp-mode/commit/fd2cbc8afcfb9e3e3439010d6f76bbb68bd71f81 It will solve your issue but it will result in a bit slower completion (after you do RET). For certain servers, it won't be noticeable but it is not the right thing to do.
[deleted] · 2022-05-10 11:13
🤩 Thank you!
jigarthanda-paal · 2022-05-10 13:06
Is this behavior possible in java/jdtls?
[deleted] · 2022-05-10 13:14
Yes, just enable the snippet support ``` (use-package lsp-mode :custom (lsp-enable-snippet t)) ``` And make sure to have yasnippets installed
jigarthanda-paal · 2022-05-10 15:29
I have it installed and the variable set to `t`. I see the placeholders in the echo area as part of the signature but not while I'm editing the fields
[deleted] · 2022-05-10 16:25
Worth opening an issue, I guess
StMonty · 2022-05-10 19:45
Unrelated, but what colorscheme is this?
[deleted] · 2022-05-11 01:19
Spacemacs
aisamu · 2022-05-11 01:34
Would you happen to know if that's "natively" available on a vanilla Doom config? I'm asking because it appears that I've got all the required pieces, but still couldn't manage to get experience shown above :/
dpoggio · 2022-05-11 03:22
I just came to say: If someone implements this in Emacs, it would be nice to use Eldoc by default. These flashing popups look horrible and invasive, and Eldoc is an elegant, ready to use solution that ships with Emacs.
yyoncho · 2022-05-11 05:48
Read the other comments, there is a server issue blocking it from working by default.
ProfessorSexyTime · 2022-05-13 03:11
Yea the documentation spawning in a child frame next to the completion candidates is a bit much for me. On cursor hover it's fine, like most IDEs do.
RantSomeWhere · 2022-05-13 09:11
Hi, I've applied your patch, but it does not seem to work. Is there any other way to solve this issue, or is it a matter of waiting until the problem is fixed upstream? At the very least, is there any way to inject function brackets into the completion if the candidate is a function?
yyoncho · 2022-05-13 09:34
There is one more line in OP's config. I will post it when I am on my PC
yyoncho · 2022-05-13 11:27
``` (lsp-register-custom-settings '(("completions.completeFunctionCalls" t t))) ```
RantSomeWhere · 2022-05-17 16:02
It worked! Thank you!