helix icon indicating copy to clipboard operation
helix copied to clipboard

Error parsing Python highlights queries

Open arvydasv opened this issue 2 years ago • 1 comments

Summary

Cannot open python file due to errors parsing runtime/queries/python/highlights.scm file.

Error started from commit hash: 0a2646e720c4d3361e0ffa79aa5d2fd01e80568e

Reproduction Steps

Open a python file.

Helix log

thread 'main' panicked at 'Could not parse queries for language "python". Are your grammars out of sync? Try running 'hx --grammar fetch' and 'hx --grammar build'. This query could not be parsed: QueryError { row: 161, column: 14, offset: 3838, message: "", kind: NodeType }', helix-core/src/syntax.rs:377:43
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Platform

Linux

Terminal Emulator

xterm

Helix Version

helix 22.05 (404defb5)

arvydasv avatar Aug 09 '22 11:08 arvydasv

I can't reproduce this on master. You most likely have out-of-date queries in your ~/.config/helix/runtime. You should update the files there or ideally use a symlink between the repo's runtime and your ~/.config/helix/runtime.

the-mikedavis avatar Aug 10 '22 01:08 the-mikedavis

I've had numerous issues like this when changing versions. Make sure to update your runtime and run hx --grammar fetch with hx --grammar build if you're changing Helix versions.

AceofSpades5757 avatar Aug 12 '22 17:08 AceofSpades5757

Noticed that when I change helix version the commands hx --grammar fetch; hx --grammar build are not updating the grammar file I get is already up to date. on fetch and is already built. on build.

Linked the latest runtime folder to ~/.config/helix/runtime, and manually erased grammar .so files to properly invoke fetch and build. But the problem still persist.

arvydasv avatar Aug 16 '22 09:08 arvydasv

You can also check for the $HELIX_RUNTIME env var. Helix looks up runtime files like queries in $HELIX_RUNTIME/queries and parsers in $HELIX_RUNTIME/grammars. If that env var is not already set, you can set it to point to ~/.config/helix/runtime or directly to the repo's runtime/ directory in the clone

the-mikedavis avatar Aug 17 '22 01:08 the-mikedavis

Runtime is set properly, I still can't open python files. If I remove runtime/queries/python/highlights.scm then I can open python files, with syntax highlights of course. The other way I solved is to set highlights to when it was working git checkout 2ede98c4b4275cc2176836347b7c921a7f018d72 -- runtime/queries/python/highlights.scm

arvydasv avatar Aug 17 '22 06:08 arvydasv

Did you try to completely remove the runtime directory/symlink and re-adding/re-linking it? I'm having trouble replicating it on Windows or Linux without either not doing hx --grammar fetch and hx --grammar build, or setting $HELIX_RUNTIME to an unfetched and unbuilt runtime directory (I did it a couple of times using a freshly downloaded helix repo).

On Windows, I've defaulted to Copy-Item -Force -Recurse since I was having intermittent issues with mixed/older files and Window's symlinking breaks frequently for me. On Linux, I cp -rf so that I can delete the Helix repo that was downloaded.

AceofSpades5757 avatar Aug 17 '22 07:08 AceofSpades5757

Ah, that means that you're running an older hx binary, one compiled from a revision before https://github.com/helix-editor/helix/pull/3103 was merged to master. You'll want to re-install/upgrade from a more recent source revision. If you already have, it's possible that you have multiple hx binaries on your system and you should be able to find them with which -a hx

the-mikedavis avatar Aug 17 '22 12:08 the-mikedavis

That fix it I was using a different hx binary.

arvydasv avatar Aug 17 '22 13:08 arvydasv