CFiggers / vscode-janet-plus-plus

Janet language support for Visual Studio Code
Other
10 stars 2 forks source link

Valid scoped bindings are autocompleted to matching top-level bindings #19

Open jangler opened 7 months ago

jangler commented 7 months ago

For instance, I have a local variable called retry. When I write the name of the variable and press enter, it's auto-expanded to render-texture-ready? from jaylib. Top-level bindings don't seem to have this problem.

CFiggers commented 7 months ago

At present, Janet LSP (the embedded language server that provides both autocompletion and diagnostic errors for Janet++) is too simple to provide any autocompletion or hover documentation on scoped variables at all.

You can test this yourself:

1) Declare any function or variable inside of a top-level do block

2) Try to trigger autocomplete or hover documentation on that variable

=> It won't work

The reason for this is simple. Janet LSP is not a full-fledged static analyzer for Janet—it merely uses a Janet runtime to evaluate forms and return parser/compiler errors as raised by Janet itself.

Since Janet itself scopes variables properly (as you would expect it to—def'ing a variable inside a do block at the REPL will not add that variable to the top-level environment either) Janet LSP does not have the ability to recognize scoped symbols and return them to autocomplete requests.

Better behavior on this is definitely something I'd like to see and will at some point work towards. That said, this one might sit open for a while (feel free to hack on Janet LSP directly—it's written in Janet!).