facebook / starlark-rust

A Rust implementation of the Starlark language
Apache License 2.0
699 stars 57 forks source link

Codelens support for the LSP #105

Open cameron-martin opened 9 months ago

cameron-martin commented 9 months ago

It would be nice to have support for codelens in the LSP, e.g. to build, test or run a particular target. This includes support for running the resulting command. The running of the commands would need to be implementation-specific, as would I imagine the gathering of the codelens items themselves.

cameron-martin commented 9 months ago

After spending some time implementing this, I realised that running build/test commands cannot be done by the LSP since it needs to open in a terminal in the editor. Hence the IDE extension needs to handle this part. I think having the LSP supply the codelenses is useful still though.

cameron-martin commented 8 months ago

On second thoughts, maybe this shouldn't be the responsibility of the language server, but instead the responsibility of the build server. Currently there is no way for the build server to tell the client the locations of build targets, but maybe there should be.

ndmitchell commented 8 months ago

I'm really not sure. I don't think it's unreasonable for the LSP to have enough hooks that the starlark context object can do it, but build server would be "better".

cameron-martin commented 8 months ago

After playing around with the build server protocol implementation for bazel, it doesn't seem to be in its prime time yet. I agree that having this in the LSP doesn't seem unreasonable, and quite a few other language servers have this feature.

I've opened up a draft PR here if you're interested in contributions of this feature: https://github.com/facebookexperimental/starlark-rust/pull/107