langium icon indicating copy to clipboard operation
langium copied to clipboard

IntelliJ example

Open ctron opened this issue 2 years ago • 4 comments

On the homepage it is mentioned that Langium can be used for IntelliJ editors. However, I wasn't able to find any information on how this could be achieved.

I think it makes sense to provide an example project, or at least outline the steps necessary.

ctron avatar Mar 27 '23 11:03 ctron

Hi @ctron,

Langium can be used by every editor that somehow supports the language server protocol (LSP). There's an LSP plugin available for IntelliJ that would allow to connect to a Langium based language server.

Note that for IntelliJ in particular, the LSP is effectively a second-class citizen, since their "normal" languages are so tightly integrated into the IDE, which is just not feasible with the LSP alone. This is why we don't offer explicit support for IntelliJ as of now. In theory you could provide a more deeply integrated, specialized plugin for a Langium based language, but I'm not sure how one would go on about this. My knowledge about IntelliJ plugin development is fairly limited.

Also note that JetBrains have their own DSL workbench specificially crafted towards their products called MPS. Maybe that fits better with your requirements.

msujew avatar Mar 27 '23 11:03 msujew

see also https://github.com/ballerina-platform/lsp4intellij/issues/303

cdietrich avatar Mar 27 '23 11:03 cdietrich

On the homepage it is mentioned that Langium can be used for IntelliJ editors. However, I wasn't able to find any information on how this could be achieved.

I think it makes sense to provide an example project, or at least outline the steps necessary.

I have tried both the IntelliJ Marketplace Plugin https://plugins.jetbrains.com/plugin/10209-lsp-support and the IntelliJ Plugin dependency https://github.com/ballerina-platform/lsp4intellij.

The Marketplace Plugin is actually working: Validations, Quick Fixes, Formatting, etc. But it crashes randomly and is not actively developed anymore.

With the lsp4intellij solution you need to setup you own IntelliJ extension project and integrate the Langium LSP server into it. It did not work for me, even though the project seems to be still alive. It does connect to the Langium LSP Server and I can even see that it receives notfications from it (e.g. on Hover) but it does not display it in the IntelliJ UI.

For me the IntelliJ LSP integration looks not really stable at the moment. Also note that Syntax Highlighting usually does not work via LSP. Meaning you need to add Syntax Highlighting manually for IntelliJ / Eclipse / Other LSP editor.

bnhmn avatar Apr 05 '23 19:04 bnhmn

Instead of IDEA, Jetbrains is coming out with Fleet soon which uses LSP, so support should be much easier for that product once it supports editor plugins.

nadavhames avatar May 28 '23 14:05 nadavhames

Please try https://github.com/redhat-developer/lsp4ij which is a free lsp support for intellij

angelozerr avatar May 18 '24 01:05 angelozerr

Fellows at zenstack were able to create the JetBrains extension:

  • Original PR where the extension was created: https://github.com/zenstackhq/zenstack/pull/904
  • The latest commit for the extension: https://github.com/zenstackhq/zenstack/tree/29962e0b48a73ae6d42f43f2575048ba9cf6a953/packages/ide/jetbrains

Yokozuna59 avatar May 18 '24 11:05 Yokozuna59

In the meantime, JetBrains has started offering LSP support for their paid IDEs: https://blog.jetbrains.com/platform/2023/07/lsp-for-plugin-developers/

As I understand this, the solution is not available for the open source IntelliJ Platform.

spoenemann avatar May 24 '24 10:05 spoenemann

See also https://plugins.jetbrains.com/docs/intellij/language-server-protocol.html

spoenemann avatar May 24 '24 10:05 spoenemann

@spoenemann as I said please try https://github.com/redhat-developer/lsp4ij  which is a free lsp support for intellij which has been released.

If you want to try to integrate your language server without developping an IJ plugin please read https://github.com/redhat-developer/lsp4ij/blob/main/docs%2FUserDefinedLanguageServer.md

If you want to try to integrate your language server by developping an IJ plugin please read https://github.com/redhat-developer/lsp4ij/blob/main/docs%2FDeveloperGuide.md

If you want to know the LSP support please read https://github.com/redhat-developer/lsp4ij/blob/main/docs%2FLSPSupport.md

angelozerr avatar May 28 '24 17:05 angelozerr

@spoenemann just for your information, we did the 0.0.2 release of LSP4IJ and if you want to have an overview of LSP4IJ, please read Meet LSP4IJ, a new LSP Client for JetBrains-based IDEs article that we have published on friday.

Hope you will like it.

angelozerr avatar Jun 23 '24 09:06 angelozerr

Nice!

spoenemann avatar Jun 24 '24 11:06 spoenemann

I've opened https://github.com/eclipse-langium/langium-website/issues/243 to track documentation on this. I think we should continue the discussion there. I'm closing this issue.

Thanks for the info about LSP4IJ, we'll surely include this on the website.

msujew avatar Jun 24 '24 11:06 msujew