Skip to content

Added support for custom hls configuration #7

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

Closed
wants to merge 2 commits into from

Conversation

dozed
Copy link

@dozed dozed commented Aug 22, 2024

With the most recent plugin version I got a lot of error message like this:

No plugins are available to handle this SMethod_TextDocumentSemanticTokensFull request.
Plugins installed for this method, but not available to handle this request are: semanticTokens is disabled globally in your config.

It seems the semantic tokens plugin is available but disabled by default: haskell/haskell-language-server#4081 (comment)

This PR adds support for custom hls configuration. If a hls.json is found in the project root, then this file is used as initialization options.

This allows to enable the semantic tokens plugin with "globalOn": true as in:

{
    ...
    "plugin": {
        ...
        "semanticTokens": {
            "config": {
                "classMethodToken": "method",
                "classToken": "class",
                "dataConstructorToken": "enumMember",
                "functionToken": "function",
                "moduleToken": "namespace",
                "operatorToken": "operator",
                "patternSynonymToken": "macro",
                "recordFieldToken": "property",
                "typeConstructorToken": "enum",
                "typeFamilyToken": "interface",
                "typeSynonymToken": "type",
                "typeVariableToken": "typeParameter",
                "variableToken": "variable"
            },
            "globalOn": true
        },
        ...
    }
}

For an example project see: https://github.com/dozed/test-hs

The proper way for this would probably be to create a plugin configuration interface, but this method here works for now.

@dozed
Copy link
Author

dozed commented Aug 25, 2024

I would propose to close this PR, since it is a feature which belongs more in the LSP4IJ plugin rather than being an ad-hoc solution in this project.

@angelozerr
Copy link

If you have this kind of error it seems that your language server returns the sem1ntic tokens capability.

In this case LSP4IJ tries to consume semantic tokens and it fails because yiur language server seems using a custom settings to enable semantic tokens.

To manage correctly this problem your language server needs to disable the semzntic tokens capabilty.

Badly LSP4IJ cannot manage semantic tokens dynamicly, and it will work only on start of the ls and not if you change your settings after the languzge server is started.

Please create an issue to the LSP4IJ repository.

@dozed dozed closed this Sep 2, 2024
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.

2 participants