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

Update helix instructions #13

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,21 @@ expected paths. You can add this line to the top of your config file if its file
name = "ghostty"
scope = "source.ghostty"
injection-regex = "ghostty"
file-types = [{ glob = "*ghostty/config" }]
file-types = [{ glob = "*ghostty/config*" }, { glob = "*ghostty/themes/*" }]
grammar = "ghostty"
comment-tokens = "#"

[[grammar]]
name = "ghostty"
source = { git = "https://github.com/bezhermoso/tree-sitter-ghostty", rev = "main" }
source = { git = "https://github.com/bezhermoso/tree-sitter-ghostty", rev = "e1a73c6231b9d760cd01204f9467d82a9d46bcb9" }
```

2. In your `runtime` directory, symlink `./queries/ghostty/highlights.scm` to `grammars/sources/ghostty/queries/highlights.scm`
2. Symlink the `highlights.scm` file. Assuming your config directory is `~/.config/helix`:
```bash
mkdir -p ~/.config/helix/runtime/queries/ghostty
cd ~/.config/helix/runtime/queries/ghostty/
ln -s ../../grammars/sources/ghostty/queries/ghostty/highlights.scm .
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looked at Helix documentation and it notes that how Helix applies highlight groups differs from Neovim in that it only uses the first query that match whereas Neovim will use the last one.

Curious, how do things look like in Helix? Since Helix also have a wider selection of groups I think it might be worth designating a separate one for it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2025-01-01 at 23 27 54

this is how your test config is highlighted

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for sharing that screenshot. I'll play around with Helix and see what we can improve. At the very least, it can probably leverage more groups.

Copy link
Contributor Author

@kabouzeid kabouzeid Jan 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a heads up, many themes will assign similar colors to ghostty's current highlight groups, that's why I picked the bogster theme here. Also, you can use the :tree-sitter-scopes and :tree-sitter-highlight-name commands to debug the symbol under the cursor in helix. lmk if you have questions :)

Copy link
Contributor

@gerblesh gerblesh Jan 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The boolean and number literals are not properly highlighted. Additionally, the precedence for helix is reversed in comparison to neovim. When upstreaming to helix, we'll likely need to modify the highlight queries to fix highlighting, and also change the order of the queries to fix precedence

Copy link
Owner

@bezhermoso bezhermoso Jan 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we can define the queries to be more targeted, designed to match once. I'm somewhat doubtful it's possible to share the same highlights.scm for both Neovim and Helix and satisfy both e.g. (property) @variable ... (config-file-directive (property)) @keyword.import) works for Neovim but I assume doesn't for Helix, but I don't want to enumerate all (*-directive (property))s either.

Given that Helix offers a wider selection of possible highlight groups, I'm more inclined to have separate highlights.scm files instead. Also given that Helix doesn't try to auto-discover queries based on plugin paths and require instructing the user to symlink a file anyway, this doesn't seem to be any worse for Helix (correct me if I'm wrong here, just basing this on the documentation, I don't use it)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Helix bundles the highlights.scm files for each language it supports. We should make a PR over there once this repo is somewhat stable.

```

[Ghostty]: https://ghostty.org
[nvim-treesitter]: https://github.com/nvim-treesitter/nvim-treesitter