Skip to content

Conversation

@charlieegan3
Copy link
Contributor

This PR uses the lsp4ij library to build in basic support for the Regal language server. I have generally worked on the server component and LSP clients are still a bit of a new thing for me.

For this work, I have as closely as possible followed the guide here - I found it to be very helpful.

Some things that are not perfect:

  • lsp: Use full text replacement for Intellij fmt regal#1637 is needed to ensure that formatting works reliably (see videos below).
  • Starting a debugging session works, but breakpoints are not respected and per-rule debugging is also not supported. I have tried, but wasn't able to get either of these working. I have left in RegalDebugAdapterDescriptor as it does work, but just not with the same features as other clients yet.

Examples of some functionality (./gradlew :plugin:runIde for testing)

Screen.Recording.2025-07-30.at.10.40.46.mov
Formatting issues (fixed in regal PR)
Screen.Recording.2025-07-29.at.16.21.54.mov
Screen.Recording.2025-07-30.at.10.01.08.mov

@charlieegan3
Copy link
Contributor Author

Hey @vgramer, if you have any time to look this one over that'd be appreciated!

Signed-off-by: Charlie Egan <[email protected]>
@vgramer vgramer self-requested a review July 31, 2025 07:09
@angelozerr
Copy link

@charlieegan3 thanks so much for using LSP4IJ.

Please note that i am improving dap api to customize breakpoint type, configuration type, configuration settings editor, etc

If you install lsp4ij nighthy you qhould have rhose feature.

I need to write docs.

@angelozerr
Copy link

To improve your lsp and dap support, you should implement an lsp4ij installer for lsp and dap.

Please read doc at https://github.com/redhat-developer/lsp4ij/blob/main/docs%2FUserDefinedLanguageServerTemplate.md

@vgramer
Copy link
Member

vgramer commented Aug 11, 2025

@charlieegan3 thanks for implementing lsp !

the "light" tests are failling because IDE create file in temp FS (IIRC in memory), which is not compatible with lsp. i think the simpler solution is to disable lsp adn dap for these tests.

all light test extends OpaTestBase.

import  com.redhat.devtools.lsp4ij.LanguageServerManager
import  com.redhat.devtools.lsp4ij.dap.DebugAdapterManager

abstract class OpaTestBase : BasePlatformTestCase(), OpaTestCase {
    override fun setUp() {
        super.setUp()
        
        // light tests use tempFS which is not compatible with lsp. So we need to disable it
        LanguageServerManager.getInstance(myFixture.project).stop("regal")

        val debugAdapterManager = DebugAdapterManager.getInstance()
        debugAdapterManager.getDebugAdapterServerById("regal-debug")
            ?.let { debugAdapterManager.removeDebugAdapterServer(it) }

    }
}

if we need lsp for testing, we can still use OpaWithRealProjectTestBase which creates a real project but is slower.

Another solution could be to disable lsp and dap programaticcaly in production by

  • make RegalLanguageServerFactory to implement LanguageServerEnablementSupport
  • ovverdie RegalDebugAdapterDescriptorFactory.isDebuggableFile to detect tempFS and return false� (this one seems a bit hacky)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants