Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add intellij-gno to LSP4IJ #7

Open
angelozerr opened this issue Feb 6, 2025 · 17 comments
Open

Add intellij-gno to LSP4IJ #7

angelozerr opened this issue Feb 6, 2025 · 17 comments

Comments

@angelozerr
Copy link

I have noticed that your plugin uses LSP4IJ, that is great!

Could you please create a PR to LSP4IJ to add it to
https://github.com/redhat-developer/lsp4ij?tab=readme-ov-file#who-is-using-lsp4ij please

And if you like LSP4IJ could you please add a review https://plugins.jetbrains.com/plugin/23257-lsp4ij/reviews to help us ro promote LSP4IJ

Thanks!

@DIGIX666
Copy link
Collaborator

I have noticed that your plugin uses LSP4IJ, that is great!

Could you please create a PR to LSP4IJ to add it to https://github.com/redhat-developer/lsp4ij?tab=readme-ov-file#who-is-using-lsp4ij please

And if you like LSP4IJ could you please add a review https://plugins.jetbrains.com/plugin/23257-lsp4ij/reviews to help us ro promote LSP4IJ

Thanks!

Yep I see after finishing the plugin because in fact it's actually usable but the syntax highlighter is no good and LSP4IJ doesn't send the default highlighter because when I check the token received with my LSP, I see the entire code of my file in the console and not the specific token

Image

@angelozerr
Copy link
Author

And what about LSP console server traces https://github.com/redhat-developer/lsp4ij/blob/main/docs/UserGuide.md#lsp-console

You should see some LSP request like

Image

and some LSP response:

Image

@DIGIX666
Copy link
Collaborator

Nop it's empty

Image

but I know that the server works because autocomplete, syntax error, go to symbol or refactor work.

@angelozerr
Copy link
Author

You need to set server trace as verbose in debug tab and save settings.

@angelozerr
Copy link
Author

It seems the ls is a copy paste from go ls.

I suspect that you need to enable semantic tokens on client side like I did for go https://github.com/redhat-developer/lsp4ij/blob/main/src%2Fmain%2Fresources%2Ftemplates%2Fgopls%2FinitializationOptions.json

In your case you need to override getInitualizationOptions of your StreamConnectionProvider and returns the same json than https://github.com/redhat-developer/lsp4ij/blob/main/src%2Fmain%2Fresources%2Ftemplates%2Fgopls%2FinitializationOptions.json

@DIGIX666
Copy link
Collaborator

Thanks, I'm going to check and see how you did it because I just tried to put in and I got the syntax highlighter but strangely it's there when I stop writing.

@angelozerr
Copy link
Author

angelozerr commented Feb 10, 2025

Me I am using user defined ls. In your case you define your ls with extension point

You will need to override the method liike I suggested.

@angelozerr
Copy link
Author

Me I am using user defined ls. In your case you define your ls with extension point

You will need to override the method liike I suggested.

More exatly you need to override https://github.com/redhat-developer/lsp4ij/blob/main/src%2Fmain%2Fjava%2Fcom%2Fredhat%2Fdevtools%2Flsp4ij%2Fserver%2FStreamConnectionProvider.java#L47 in your process stream connection provider.

This method must return a JqonObject or easier a Map<String, Object> that you need to fill like https://github.com/redhat-developer/lsp4ij/blob/main/src%2Fmain%2Fresources%2Ftemplates%2Fgopls%2FinitializationOptions.json

@DIGIX666
Copy link
Collaborator

To set up ui.sementic I have to use the user view for server configuration.
Image

Or by configuring a gnopls template like for your gopls the config will be taken into account when I install my extension?

@angelozerr
Copy link
Author

To set up ui.sementic I have to use the user view for server configuration.
Image

Or by configuring a gnopls template like for your gopls the config will be taken into account when I install my extension?

As you dont use user defined ls but an extension point you cannot configure it.

You need to implement method like I suggested.

@DIGIX666
Copy link
Collaborator

Oh ok I understand better, thanks I going try

@angelozerr
Copy link
Author

I suggest really that you use LSP console with verbose trace to understand what it happens.

@angelozerr
Copy link
Author

You should see some trace like this:

Image

If you don't see that, it is normal that syntax coloration do nothing.

@DIGIX666
Copy link
Collaborator

Currently, if I run my extension, here's the trace I get for semanticTokens, so it's not correct. But on the other hand, if I add a new language server and add ui.semanticTokens: true to the configuration, I get the semanticTokens recognized. So now I'm looking for the configuration to be set to default because currently I'm running my extension and when I go to my Gno Language Server I don't have the Configuration tab.

EXTENSION :
Image

Image

MANUALLY :
Image

Image

@angelozerr
Copy link
Author

Currently, if I run my extension, here's the trace I get for semanticTokens, so it's not correct. But on the other hand, if I add a new language server and add ui.semanticTokens: true to the configuration, I get the semanticTokens recognized. So now I'm looking for the configuration to be set to default because currently I'm running my extension and when I go to my Gno Language Server I don't have the Configuration tab.

Indeed it is a limitation which has already reported at redhat-developer/lsp4ij#315

Try to add in https://github.com/gnoverse/intellij-gno/blob/main/src/main/Java/com/github/intellij/gno/lsp/GnoLanguageServer.java this following code

@Override
public Object getInitializationOptions(VirtualFile rootUri) {
    Map<String, Object> options = new HashMap<>();
    options.put("ui.semanticTokens", true);
    return options;
}

EXTENSION : Image

Image MANUALLY : ![Image](https://github.com/user-attachments/assets/f37cf49c-3709-4fd7-a54d-67cf4c3f8b7c)

Image

@DIGIX666
Copy link
Collaborator

DIGIX666 commented Feb 11, 2025

Thank you it works ! 🙏🏼

but I think I'm going to have to add a lexer and parser anyway because when I do a cmd + click for the go to symbol all the code is highlighted but the redirection works fine

Image

@angelozerr
Copy link
Author

Thank you it works ! 🙏🏼

Great!

but I think I'm going to have to add a lexer and parser anyway because when I do a cmd + click for the go to symbol all the code is highlighted but the redirection works fine

Indeed I know this problem redhat-developer/lsp4ij#98

Image

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

No branches or pull requests

2 participants