opa-idea-plugin icon indicating copy to clipboard operation
opa-idea-plugin copied to clipboard

WIP: integration of Language Server Protocol

Open vgramer opened this issue 4 months ago • 14 comments

Description

PoC for integration Regal, which is actually pretty straight forward (just one class to implement) Capture d’écran 2024-04-09 à 07 39 00

TODO:

  • [ ] make this integration only for paid IntelliJ-based IDEs ( i have to check, but i think it's possible)
  • [ ] do not hardcode path of regal, would be nice to have something like sdk version
  • [ ] add settings to customize regal configuration?
  • [ ] Is it possible to add some quick-fix action for the problems reported by Regal? (e.g. opa fmt)

Fixes #171

Special notes for your reviewer

LSP api in IDEA is still under dev and unstable.

vgramer avatar Apr 09 '24 15:04 vgramer

This is awesome Vincent! 👏 Can't wait to try it out. @charlieegan3 took a look at some options here, so he'll reach out for a sync. But like you said, this clearly looks like it's a very simple addition from an integration POV.

add settings to customize regal configuration?

Perhaps we could integrate that in the UI later, via the LSP or not. In the meantime, users can always set their Regal config file.

Is it possible to add some quick-fix action for the problems reported by Regal? (e.g. opa fmt)

Yes, this is also covered by the language server protocol in the form of code actions and commands. We'll have a few basic actions (like opa-fmt) included in the next release, with more to follow. We'll mostly do this for rules in the style category though — for other rules there is a point in having the user read the docs and learn something :)

anderseknert avatar Apr 09 '24 16:04 anderseknert

Hi Vincent! This is amazing, thanks for your work on this.

make this integration only for paid IntelliJ-based IDEs

Interesting, is this something that needs to be done before we can list the plugin in the IntelliJ store? If we must do that, is it worth also investigating using another option such as https://github.com/ballerina-platform/lsp4intellij? I was having a look over https://github.com/zzehring/intellij-jsonnet earlier in the week and it seemed like it could be good inspiration.

Mixed feelings about this, as I feel like even if the pace of the first-class support for LSP in IntelliJ is unstable, it feels like it'll inevitably by the route to go in future. I am also unsure how many users of the community IntelliJ flavours there are who use this plugin.

do not hardcode path of regal, would be nice to have something like sdk version

Might we be able to determine it from looking up in the PATH? and just quietly not run it if it's missing? In the vscode ext, we have an option to install Regal, but that's not required here I think. Best would be to prompt users to install it once if it's missing.

add settings to customize regal configuration?

While there is some functionality in the vscode client and Regal LSP to handle updates to regal config live, this is something I think we'll need to revisit. See this recent issue: https://github.com/StyraInc/regal/issues/626. For now, or a first version, perhaps let's send the contents of .regal/config.yaml to the server too and we can come back to it later.

Is it possible to add some quick-fix action for the problems reported by Regal? (e.g. opa fmt)

This is something we're working on in the vscode client at the moment - it's proving a little trickier than expected!

Great work! 👏

charlieegan3 avatar Apr 09 '24 16:04 charlieegan3

Have you had any time to look into this further, @vgramer? We've added a lot of features to the language server in just the last few weeks, including the "fix" feature for linter rules that you asked about. Would love to see this in IntelliJ sometime soon!

anderseknert avatar May 06 '24 11:05 anderseknert