chapel-lang / chapel

a Productive Parallel Programming Language
https://chapel-lang.org
Other
1.76k stars 414 forks source link

register chpl-language-server and chplcheck on mason (neovim) #25246

Open lucaferranti opened 3 weeks ago

lucaferranti commented 3 weeks ago

Installation instructions for chpl-language-server and chplcheck for neovim are pretty ok atm, but it would be nice to integrate those in the neovim ecosystems (would make it easier for people and also give a bit more visibility to chapel).

It would be very nice to have those in the neovim mason registry, which would make installation and using the language server much easier.

For chplcheck, bonus simplification can be achieved by adding that to none-ls built-ins, makin its usage also a bit easier.

Maybe a bit of a side note, but still related. I noticed that currently neither chpl-language-server nor chplcheck are packaged or versioned

❯ chpl-language-server --version
chpl-language-server.py: error: unrecognized arguments: --version

❯ chplcheck --version
chplcheck: error: unrecognized arguments: --version

I think tools like linter and language server should be decoupled from the core language and have their own version number and releases. Also, if they are written in python, might be nice to have them pip-installable

lucaferranti commented 3 weeks ago

Some references:

DanilaFe commented 3 weeks ago

Hi Luca, I myself just use https://github.com/neovim/nvim-lspconfig for my LSP-related configurations. I don't believe we have something there, either. Would adding the language server to nvim-lspconfig improve the setup experience for users of Neovim's mason such as yourself?

lucaferranti commented 3 weeks ago

I also use nvim-lspconfig to use the language servers and definitely +1 for adding Chapel support there too (I guess you mean here ? )

Mason is an LSP/linters/formatters registry which I use to install and update language servers themselves. It's pretty handy since it allows to install / uninstall / update language servers and similar tools for different languages in a centralized way. It could be nice to have chpl-language-server and chplcheck there too, but I think that would need them to be versioned.

I guess the reason why chpl-language-server and chplcheck are unversioned is because they are still pretty experimental. Is there a plan of having them as independent packages (e.g. distributed via pip) with their own version etc.?

DanilaFe commented 3 weeks ago

I guess the reason why chpl-language-server and chplcheck are unversioned is because they are still pretty experimental. Is there a plan of having them as independent packages (e.g. distributed via pip) with their own version etc.?

This is relatively challenging, since they rely on building the entire compiler (which involves downloading the compiler), which is quite a heavyweight process. I am not sure that pip has enough support to do something like this, but I will investigate.

lucaferranti commented 3 weeks ago

This is relatively challenging, since they rely on building the entire compiler

I see, I also noticed when building the language server on a fresh clone it was also buidling the compiler, which would indeed make this a bit trickier. Why does it need to do that though?

DanilaFe commented 3 weeks ago

Because the language server and linter make use of the same features of the compiler that chpl does; to get warnings like UnusedVariables and to implement go-to-definition, we need to do scope resolution (a compiler operation that figures out what each variable in the code refers to), and for autocompletion we need to resolve uses and imports, which can also get quite tricky. We could in theory re-implement this in Python, but it would be much like rewriting the compiler.

To be precise, we don't need the whole compiler, just the piece called the "front end": this piece handles parsing and resolution, but doesn't actually produce executables; neither the linter nor the language server need to fully compile code.