teal-language-server icon indicating copy to clipboard operation
teal-language-server copied to clipboard

LSP suggests variables when changing the "capabilities" config

Open ErickProgramer opened this issue 7 months ago • 2 comments

One thing I noticed was missing in this LSP was variable suggestions. It didn't show variables in scope while typing. But after looking at the source code, I changed the LSP's capabilities configuration, and now it works just fine. I'm not sure why that fixed it — was this intentional?

Image

Also, function signatures weren’t appearing, but I added the () character to the triggerCharacters list of the signatureHelpProvider, and now that works too. (I think it's because I use a neovim plugin that adds a closing bracket automatically, but it would be great fix it in the repository)

Image

Image

ErickProgramer avatar May 26 '25 00:05 ErickProgramer

Thanks, I tried it and can confirm that the trigger character change to add all word characters works well and seems like a nice improvement. However I wasn't able to confirm any change related to adding ")" and "()"

svermeulen avatar May 26 '25 02:05 svermeulen

From the language server protocol docs, it looks like triggerCharacters should be characters outside of [a-zA-Z].

/**
 * The additional characters, beyond the defaults provided by the client (typically
 * [a-zA-Z]), that should automatically trigger a completion request. For example
 * `.` in JavaScript represents the beginning of an object property or method and is
 * thus a good candidate for triggering a completion request.
 *
 * Most tools trigger a completion request automatically without explicitly
 * requesting it using a keyboard shortcut (e.g. Ctrl+Space). Typically they
 * do so when the user starts to type an identifier. For example if the user
 * types `c` in a JavaScript file code complete will automatically pop up
 * present `console` besides others as a completion item. Characters that
 * make up identifiers don't need to be listed here.
 */
triggerCharacters?: string[];

Also based on the clarifications from this thread: https://github.com/Microsoft/language-server-protocol/issues/268 (which also lists out what other languages use)

From the neovim docs there are some ways to get it to trigger on every keypress. I think based on all of this, I don't think we should add every character to the triggerCharacters list.

I hope this helps!

FourierTransformer avatar May 26 '25 17:05 FourierTransformer