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

Semantic tokens not working with Clojure LSP #2294

Closed
prcastro opened this issue Jul 3, 2023 · 4 comments
Closed

Semantic tokens not working with Clojure LSP #2294

prcastro opened this issue Jul 3, 2023 · 4 comments

Comments

@prcastro
Copy link

prcastro commented Jul 3, 2023

Describe the bug
I'm trying to setup LSP and my editor doesn't recognize s/defn macro as a function declaration.

The Clojure LSP should be reporting s/defn as function semantic tokens. Looking at the logs, the LSP plugin doesn't seem to be sending any semanticTokens/full requests. Also, adding:

{
    "rules": [
        {
            "scope": "meta.semantic-token",
            "background": "#00000101"
        },
    ]
}

To the color scheme also does nothing.

To Reproduce
Open a clojure project with prismatic schema and clojure-lsp set up. Declare a function using s/defn.

Expected behavior
I expected defn and s/defn function definitions to be highlighted the same

Screenshots
Screenshot 2023-07-03 at 11 16 45

Environment (please complete the following information):

  • OS: macOS 13.4.1
  • Sublime Text version: 4143
  • LSP version: 1.24.0
  • Language servers used: clojure-lsp

Additional context
I debugged this with the clojure-lsp dev and he was convinced the problem was on the client side (LSP)

@jwortmann
Copy link
Member

Have you enabled "semantic_highlighting": true in the LSP settings? (it's false by default)

Can you place the cursor inside s/defn and select Tools > Developer > Show Scope Name from the menu - there should be a "Semantic Token" section in the popup, if semantic tokens are enabled.

Could you post the exact response to the initialize (1) request from the LSP log panel, so we can see the exact capabilities of the clojure-lsp server?

@predragnikolic

This comment was marked as duplicate.

@predragnikolic
Copy link
Member

The docs are missing the part to set "semantic_highlighting": true
https://lsp.sublimetext.io/customization/#semantic-highlighting

@prcastro
Copy link
Author

prcastro commented Jul 3, 2023

It was indeed the "semantic_highlighting": true config missing. Maybe adding it to the documentation would make things more clear. Thanks for the help =D

And yes, clojure-lsp was announcing semantic tokens. On initialize I have:

'semanticTokens': {'requests': {'full': {'delta': True}, 'range': True},

And I have exactly one other log saying:

'semanticTokensProvider': {'full': True, 'legend': {'tokenTypes': ['namespace', 'type', 'function', 'macro', 'keyword', 'class', 'variable', 'method', 'event', 'interface'], 'tokenModifiers': ['definition', 'defaultLibrary', 'implementation']}, 'range': True}

@prcastro prcastro closed this as completed Jul 3, 2023
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

3 participants