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

Broken Rust highlighting #4739

Closed
emirror-de opened this issue Nov 14, 2022 · 3 comments
Closed

Broken Rust highlighting #4739

emirror-de opened this issue Nov 14, 2022 · 3 comments
Labels
C-bug Category: This is a bug

Comments

@emirror-de
Copy link

emirror-de commented Nov 14, 2022

Summary

Hi all,

with the latest revision (c74b974), Rust highlighting is broken. Building on revision 07d3157 works.

Reproduction Steps

I tried this:

  1. git checkout c74b97447f7a84f7728ce41c796f435371563a68
  2. cargo install --path helix-term
  3. hx --grammar fetch
  4. hx --grammar build
  5. Open any rust file using hx

I expected this to happen:

Rust source code is highlighted.

Instead, this happened:

Rust source code is not highlighted.

Helix log

~/.cache/helix/helix.log
2022-11-14T09:18:29.320 helix_core::syntax [ERROR] Could not parse queries for language "rust". Are your grammars out of sync? Try running 'hx --grammar fetch' and 'hx --grammar build'. This query could not be parsed: QueryError { row: 291, column: 1, offset: 4698, message: "attribute", kind: NodeType }

Platform

Linux

Terminal Emulator

alacritty 0.12.0-dev (77855806)

Helix Version

22.08.1-435-gc74b9744

Edit: Updated Summary section.

@emirror-de emirror-de added the C-bug Category: This is a bug label Nov 14, 2022
@the-mikedavis
Copy link
Member

This is caused by the update of tree-sitter-rust in #4717. The Rust highlighting on master is not actually broken though, you just have some stale state somewhere.

The "Could not parse queries..." error log line points out that the runtime/queries/rust/highlights.scm cannot be used for the current tree-sitter-rust parser. This can either happen because you have out-of-date queries or you're using a build of helix with a rust.so comiled parser which is too old. You can run hx -g fetch and hx -g build to ensure that the version of tree-sitter-rust defined in languages.toml is built. You may need to re-build helix since languages.toml is compiled-in.

Also make sure that you don't have a

[[grammar]]
name = "rust"
source = { .. }

block in your ~/.config/helix/languages.toml file.

@emirror-de
Copy link
Author

Hey thanks for this detailed answer. Indeed I had the [[grammar]] section in my languages.toml.

I found more of those sections in the file for other languages. So would you recommend to remove these in order to prevent this occurrence for other languages as well in the future?

Sorry for the buggy bug, report. 😬

@the-mikedavis
Copy link
Member

Yep, there's no need to copy the [[grammar]] sections. [[language]] sections also do not need to be copied in full, you only need to specify what's new. For example if you wanted to turn off auto-formatting for rust, you would say:

# ~/.config/helix/languages.toml
[[language]]
name = "rust"
auto-format = false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug
Projects
None yet
Development

No branches or pull requests

2 participants