rockofox / intellij-haskell-lsp

IntelliJ Plugin that provides Haskell language support via haskell-language-server
https://plugins.jetbrains.com/plugin/24123-haskell-lsp
Apache License 2.0
14 stars 4 forks source link

Added support for custom hls configuration #7

Closed dozed closed 2 months ago

dozed commented 2 months ago

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: https://github.com/haskell/haskell-language-server/issues/4081#issuecomment-1949124141

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 commented 2 months ago

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 commented 2 months ago

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.