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

Improve tsq/tree-sitter-query language support #12148

Merged
merged 5 commits into from
Dec 27, 2024

Conversation

uncenter
Copy link
Contributor

@uncenter uncenter commented Nov 28, 2024

WIP adding support for tree-sitter query files (scheme-like), using https://github.com/tree-sitter-grammars/tree-sitter-query for the grammar and https://github.com/ribru17/ts_query_ls as the LSP.

Todo

  • LSP
  • Reverse query order for precedence order difference

Copy link
Member

@the-mikedavis the-mikedavis left a comment

Choose a reason for hiding this comment

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

You can update the existing entry for this language instead:

helix/languages.toml

Lines 1439 to 1449 in b1bdbc6

[[language]]
name = "tsq"
scope = "source.tsq"
file-types = ["tsq"]
comment-token = ";"
injection-regex = "tsq"
indent = { tab-width = 2, unit = " " }
[[grammar]]
name = "tsq"
source = { git = "https://github.com/the-mikedavis/tree-sitter-tsq", rev = "48b5e9f82ae0a4727201626f33a17f69f8e0ff86" }

That language is set to recognize .tsq files as a dummy value. (We didn't want the tree-sitter query language to be used over Scheme generally.) The file-types you have proposed here instead looks better though, there might still be some overlap with regular Scheme files but it seems unlikely.

@the-mikedavis the-mikedavis added the A-language-support Area: Support for programming/text languages label Dec 2, 2024
@uncenter
Copy link
Contributor Author

uncenter commented Dec 2, 2024

I might be messing something up but it seems like I can't leave the name as tsq, it only works when I use the grammar name query.

@the-mikedavis
Copy link
Member

You may need to set grammar = "query" in the [[language]] entry for tsq. The [[grammar]] entry's name is used for loading the parser so it needs to basically match the name attribute from the grammar.js https://github.com/tree-sitter-grammars/tree-sitter-query/blob/a6674e279b14958625d7a530cabe06119c7a1532/grammar.js#L16

@uncenter uncenter changed the title Add query (tree-sitter-query) support Improve tsq/tree-sitter-query language support Dec 6, 2024
@uncenter uncenter marked this pull request as ready for review December 8, 2024 16:54
Copy link
Member

@the-mikedavis the-mikedavis left a comment

Choose a reason for hiding this comment

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

thanks!

@the-mikedavis the-mikedavis merged commit a5a7cff into helix-editor:master Dec 27, 2024
6 checks passed
@uncenter uncenter deleted the feat/query branch December 27, 2024 15:03
CedricMeu pushed a commit to CedricMeu/helix that referenced this pull request Jan 2, 2025
the-mikedavis added a commit that referenced this pull request Jan 2, 2025
The changes in #12148 were a bit radical - this restores some
customizations we had like using "label" for captures and not
highlighting the '#' or '?'/'!' parts differently. Also the highlighting
for predicates we do (not) support has been restored.
akhenakh pushed a commit to akhenakh/helix that referenced this pull request Jan 4, 2025
akhenakh pushed a commit to akhenakh/helix that referenced this pull request Jan 4, 2025
The changes in helix-editor#12148 were a bit radical - this restores some
customizations we had like using "label" for captures and not
highlighting the '#' or '?'/'!' parts differently. Also the highlighting
for predicates we do (not) support has been restored.
GladkihEgor pushed a commit to GladkihEgor/helix that referenced this pull request Jan 4, 2025
GladkihEgor pushed a commit to GladkihEgor/helix that referenced this pull request Jan 4, 2025
The changes in helix-editor#12148 were a bit radical - this restores some
customizations we had like using "label" for captures and not
highlighting the '#' or '?'/'!' parts differently. Also the highlighting
for predicates we do (not) support has been restored.
Desdaemon pushed a commit to Desdaemon/helix that referenced this pull request Jan 6, 2025
Desdaemon pushed a commit to Desdaemon/helix that referenced this pull request Jan 6, 2025
The changes in helix-editor#12148 were a bit radical - this restores some
customizations we had like using "label" for captures and not
highlighting the '#' or '?'/'!' parts differently. Also the highlighting
for predicates we do (not) support has been restored.
diucicd pushed a commit to diucicd/helix that referenced this pull request Jan 8, 2025
diucicd pushed a commit to diucicd/helix that referenced this pull request Jan 8, 2025
The changes in helix-editor#12148 were a bit radical - this restores some
customizations we had like using "label" for captures and not
highlighting the '#' or '?'/'!' parts differently. Also the highlighting
for predicates we do (not) support has been restored.
rmburg pushed a commit to rmburg/helix that referenced this pull request Jan 20, 2025
rmburg pushed a commit to rmburg/helix that referenced this pull request Jan 20, 2025
The changes in helix-editor#12148 were a bit radical - this restores some
customizations we had like using "label" for captures and not
highlighting the '#' or '?'/'!' parts differently. Also the highlighting
for predicates we do (not) support has been restored.
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants