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

strings highlighting is not right in nushell scripts #4162

Closed
amtoine opened this issue Oct 9, 2022 · 6 comments
Closed

strings highlighting is not right in nushell scripts #4162

amtoine opened this issue Oct 9, 2022 · 6 comments
Labels
A-tree-sitter Area: Tree-sitter C-bug Category: This is a bug upstream

Comments

@amtoine
Copy link
Contributor

amtoine commented Oct 9, 2022

Summary

hello there 👋 😋

i just have a syntax hightlighting issue with some nushell code 🤔

below is a screenshot of what is happening 👍

🟢 the syntax hightlighting is right
🔵 it starts to shift around the "\nLOG:" string of characters
🔴 it is not right anymore and everything looks like a string, except strings themselves
🟠 the file is correctly identified as a nushell script

helix-nu-hightlight

Reproduction Steps

  1. go to functions.nu around the line with export def-env vcfg

I expect the string highlight to stop at the end of "\nLOG:"

Instead, it continues to the bottom of the file, i.e. the strings and the rest are inverted 😮

Helix log

nothing relevant to report from ~/.cache/helix/helix.log

Platform

Linux 5.19.10-arch1-1

Terminal Emulator

alacritty 0.10.1 ()

Helix Version

(22.08.1-165-g4d4be0e8)

@amtoine amtoine added the C-bug Category: This is a bug label Oct 9, 2022
@gavincrawford
Copy link
Contributor

This appears to be an issue with the grammar itself, provided by this repo. In this file specifically, it may have something to do with def-env, which isn't included as a keyword in the query for Nu. See here:

[
"if"
"else"
"let"
"def"
"export"
] @keyword

@amtoine
Copy link
Contributor Author

amtoine commented Oct 10, 2022

This appears to be an issue with the grammar itself, provided by this repo. In this file specifically, it may have something to do with def-env, which isn't included as a keyword in the query for Nu.

ooh yes i see it 😮

i tried to modify my ~/.config/helix/runtime/queries/nu/highlights.scm by writing

[
 "if"
 "else"
 "let"
 "def"
 "export"
 "def-env"
] @keyword

but then the hightlighting is completely gone 🤔

i'm new to tree-sitter and grammar integration to an IDE 😕
should tree-sitter-nu/highlights.scm be directly modified?
and then we should run hx --grammar fetch; hx --grammar build?

@the-mikedavis
Copy link
Member

This can't be solved just by modifying the highlights - the syntax tree has an ERROR node indicating that the parser failed to parse some of the code successfully. This will need to be fixed upstream in https://github.com/LhKipp/tree-sitter-nu

@sudormrfbin sudormrfbin added A-tree-sitter Area: Tree-sitter upstream labels Oct 10, 2022
@amtoine
Copy link
Contributor Author

amtoine commented Oct 10, 2022

This can't be solved just by modifying the highlights - the syntax tree has an ERROR node indicating that the parser failed to parse some of the code successfully. This will need to be fixed upstream in https://github.com/LhKipp/tree-sitter-nu

okok i see 🤔
i guess i'll see that with the upstream then 😌

@amtoine
Copy link
Contributor Author

amtoine commented Oct 10, 2022

there it is 💪

@amtoine
Copy link
Contributor Author

amtoine commented Nov 3, 2022

according the @LhKipp, LhKipp/tree-sitter-nu#3 has been fixed 👍

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

No branches or pull requests

4 participants