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

Racket LSP disables syntax highlighting #4913

Closed
HereComesTheMoon opened this issue Nov 27, 2022 · 1 comment · Fixed by #4915
Closed

Racket LSP disables syntax highlighting #4913

HereComesTheMoon opened this issue Nov 27, 2022 · 1 comment · Fixed by #4915
Labels
A-language-support Area: Support for programming/text languages C-bug Category: This is a bug

Comments

@HereComesTheMoon
Copy link

Summary

If the Racket LSP is enabled there's no syntax highlighting whatsoever. Here's my languages.toml file:

[[language]]
name = "racket"
scope = "source.rkt"
roots = []
file-types = ["rkt"]
shebangs = ["racket"]
comment-token = ";"
grammar = "racket"
language-server = { command = "racket", args = ["-l", "racket-langserver"] }

[[grammar]]
name = "racket"
source = { git = "https://github.com/6cdh/tree-sitter-racket", rev = "09cb27a06415bce529a26774a842f5a80d50d362" }

Notes:

  • The language server appears to connect to helix, and is installed properly.
  • If I change the rkt in file-types = ["rkt"] to gibberish (or comment out the entire language block), then there is syntax highlighting
  • I tried to install the tree-sitter-racket thing to see if that'd help at all. It was a bit of a struggle, and I still don't think that it works.
  • Without tree-sitter-racket the issue persists
  • I used the latest version of Helix in the Arch repositories (from September), and the latest git build, there were no observable differences

Reproduction Steps

Install racket and the racket language server (using raco) as specified on the installation page. Have this in your language.toml.

[[language]]
name = "racket"
scope = "source.rkt"
roots = []
file-types = ["rkt"]
shebangs = ["racket"]
comment-token = ";"
grammar = "racket"
language-server = { command = "racket", args = ["-l", "racket-langserver"] }

Racket files (ie. those with extension .rkt) will have no syntax highlighting if the above is set correctly. When removing the above lines .rkt files will have syntax highlighting.

Helix log

With LSP enabled and opening a racket file with hx -v, these are the the log entries:

~/.cache/helix/helix.log
2022-11-27T23:21:58.408 helix_view::editor [ERROR] Failed to initialize the LSP for `source.toml` { cannot find binary path }
2022-11-27T23:22:37.361 helix_view::clipboard [INFO] Using wl-copy+wl-paste to interact with the system and selection (primary) clipboard
2022-11-27T23:22:37.362 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{"textDocument":{"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}}},"completion":{"completionItem":{"insertReplaceSupport":true,"resolveSupport":{"properties":["documentation","detail","additionalTextEdits"]},"snippetSupport":false},"completionItemKind":{}},"hover":{"contentFormat":["markdown"]},"publishDiagnostics":{},"rename":{"dynamicRegistration":false,"honorsChangeAnnotations":false,"prepareSupport":false},"signatureHelp":{"signatureInformation":{"activeParameterSupport":true,"documentationFormat":["markdown"],"parameterInformation":{"labelOffsetSupport":true}}}},"window":{"workDoneProgress":true},"workspace":{"applyEdit":true,"configuration":true,"didChangeConfiguration":{"dynamicRegistration":false},"executeCommand":{"dynamicRegistration":false},"symbol":{"dynamicRegistration":false},"workspaceFolders":true}},"processId":206149,"rootPath":"/home/mond/Racket/AdventOfCode2022","rootUri":"file:///home/mond/Racket/AdventOfCode2022","workspaceFolders":[{"name":"AdventOfCode2022","uri":"file:///home/mond/Racket/AdventOfCode2022"}]},"id":0}

Platform

Linux

Terminal Emulator

foot-extra

Helix Version

helix 22.08.1 (583c2a5)

@HereComesTheMoon HereComesTheMoon added the C-bug Category: This is a bug label Nov 27, 2022
@the-mikedavis
Copy link
Member

Syntax highlighting is done through tree-sitter rather than LSP. Currently the highlighting is provided by tree-sitter-scheme:

helix/languages.toml

Lines 1525 to 1536 in bf908cc

[[language]]
name = "scheme"
scope = "source.scheme"
injection-regex = "scheme"
file-types = ["ss", "rkt"] # "scm",
roots = []
comment-token = ";"
indent = { tab-width = 2, unit = " " }
[[grammar]]
name = "scheme"
source = { git = "https://github.com/6cdh/tree-sitter-scheme", rev = "27fb77db05f890c2823b4bd751c6420378df146b" }

Adding that block to your ~/.config/helix/languages.toml must change the precedence so that we use racket over scheme for rkt files.

It looks like since rkt files belong to scheme, you can't currently use the racket language server. This can be fixed in this repository's languages.toml by explicitly using the scheme grammar for the racket [[language]] entry and setting up queries that inherit from scheme.

@the-mikedavis the-mikedavis added the A-language-support Area: Support for programming/text languages label Nov 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-language-support Area: Support for programming/text languages C-bug Category: This is a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants