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

Add tree-sitter #158

Merged
merged 1 commit into from
Oct 2, 2024
Merged

Add tree-sitter #158

merged 1 commit into from
Oct 2, 2024

Conversation

dianhenglau
Copy link
Contributor

Add Sailfish template (.stpl) grammar for tree-sitter, to provide syntax highlighting in Neovim and Helix.

@vthg2themax
Copy link
Collaborator

@dianhenglau I looked online for some information about tree sitter so that I could test this out, but didn't know where to start. Can you share some information about how I could test this, and what some of these changes enable the user to have out of the box?

@dianhenglau
Copy link
Contributor Author

To test it:

  1. Download and install the helix editor, git, and gcc.
  2. Open any stpl file. You will see there is no highlighting.
  3. Create languages.toml in helix config directory.
  4. In the helix config directory, create subdirectories runtime/queries/sailfish (mkdir -p runtime/queries/sailfish), and go to that directory (cd runtime/queries/sailfish).
  5. Create symbolic link to highlights.scm (ln -s ../../grammars/sources/sailfish/syntax/tree-sitter-sailfish/queries/highlights.scm) and injections.scm (ln -s ../../grammars/sources/sailfish/syntax/tree-sitter-sailfish/queries/injections.scm). If your platform doesn't support symbolic link, you can copy the files directly too.
  6. Run helix --grammar fetch and helix --grammar build.
  7. Open any stpl file. You will see syntax highlighting is working.

Content of languages.toml:

[[language]]
name = "sailfish"
scope = "source.sailfish"
injection-regex = "sailfish"
file-types = ["stpl"]
block-comment-tokens = { start = "<%#", end = "%>" }
indent = { tab-width = 2, unit = "  " }

[[grammar]]
name = "sailfish"
# You can change the git repository here
source = { git = "https://github.com/dianhenglau/sailfish.git", rev = "e46dec875c0b35af54057776d5a9717e2b5ea9a0", subpath = "syntax/tree-sitter-sailfish" }

@vthg2themax
Copy link
Collaborator

@dianhenglau
I think the idea for Helix editor support is very nice! I started the process to using the helix editor as a flatpak, on POP_OS (Ubuntu based), and got stuck partway through to being able to even try to debug a rust executable. If you want to contribute some information on your setup, I can update their wiki, or even mention it here. I like the idea of Helix, but it looks like it requires more configuration out of the box than vs code. However, I would like to not use vs code because I don't want to depend on a free product that could be dropped, or modified on a whim.

@vthg2themax vthg2themax merged commit a4450eb into rust-sailfish:main Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants