Closed gzagatti closed 8 months ago
Yes, I'm definitely into this. I'll have a look.
I opened a new issue on the repo: https://github.com/nvim-treesitter/nvim-treesitter/issues/5620
EDIT: It was already requested at https://github.com/nvim-treesitter/nvim-treesitter/issues/2282#issuecomment-1507243495. We have to create a pull request. I found the indications to add new language at https://github.com/nvim-treesitter/nvim-treesitter/blob/master/CONTRIBUTING.md
@gzagatti How familiar are you with the tree sitter Neovim plugin? Because me, I'm not even familiar with NeoVim :/
I'm actively working on getting typst support in nvim-treesitter and I do have it in a "functional" state, but I have to do a feature comparison of this parser with
before I make the PR.
Neovim is my daily driver and I get all my treesitter grammars from the neovim-treesitter repo. I modify some queries for my own needs. However I have never made a contribution to the official repo. I can help with some of the Neovim stuff. Let me start by checking the tracker in the neovim-treesitter repo. I’m not quite sure about the feature comparison that they’re after.
When I asked on the matrix about contributing I was told to do a feature comparison of available TS grammars to avoid problems down the line.
Feature comparison finished, this one is it for neovim. SeniorMars/typst.nvim looks inactive and frozolotl/tree-sitter-typst only supports about half of the language. I'm building the neovim queries right now, if @gzagatti wants to contribute I've started development at https://github.com/Nagefire/nvim-treesitter/tree/feat/typst
Thanks for your work, guys. I'm waiting for this to be merged.
Feature comparison finished, this one is it for neovim. SeniorMars/typst.nvim looks inactive and frozolotl/tree-sitter-typst only supports about half of the language. I'm building the neovim queries right now, if @gzagatti wants to contribute I've started development at https://github.com/Nagefire/nvim-treesitter/tree/feat/typst
Is this still active?
This tree sitter grammar, yes.
The @Nagefire 's fork to add Typst to nvim-treesitter, no idea... Maybe it's a good idea to create a new one and make a pull request. Do you think you could do it ? (As I'm not a neovim user, I'm not so up for it)
A new one based on @Nagefire's fork? And then open the PR directly to the upstream tree-sitter repo?
A new one based on @Nagefire's fork? And then open the PR directly to the upstream tree-sitter repo?
I guess, yes.
Emailed them yesterday to see if they are still actively working on this (apparently not?). If not, I am considering working on this after my January finals.
By the way, thank you so much for this great project!
Just got an "undelivered" response from my fucked up email server lol. Pickles with its IP.
@uben0, could you be the one to email @Nagefire, please? Sorry to disturb you. Their email address is on their profile.
I sent a mail asking about the aliveness of its fork.
I have been working with my own set of queries. If @Nagefire's fork is still alive, I could try to contribute in there. My own set of queries also include injections and folds.
@Nagefire seems inactive, and there no way to know for how long.
@gzagatti, could you make a fork like @Nagefire did and make a pull-request ?
Or at least, could someone redact a How to to add Typst support to NeoVim, and I'll add it to the install instruction of the README. It's better than nothing while waiting official support.
At least onw nvim-treesitter fork needs to implement queries on top of your parser before it makes sense to redact a "How to" section. Once that's ready, I could do that no problem.
As of https://github.com/nvim-treesitter/nvim-treesitter/commit/1ae9b0e4558fe7868f8cda2db65239cfb14836d0, the queries here work nearly out of the box with a minimum amount of manual config:
in init.vim
Plug 'https://github.com/TheZoq2/tree-sitter-typst-2'
and wherever you have your treesitter lua config
require'nvim-treesitter.install'.prefer_git = true
parser_config.typst = {
install_info = {
url = "https://github.com/frozolotl/tree-sitter-typst.git", -- local path or git repo
files = {"src/parser.c", "src/scanner.c"},
},
filetype = "typst", -- if filetype does not match the parser name
}
However, neovim looks for queries in queries/{language}/*.scm
, not queries/*.scm
Would it break helix support if the queries in this repo were moved into queries/typst/*.scm
?
I already have a fork for that so if you want it, I can just PR that and maybe update the docs a bit.
That way you're less reliant on getting things upstreamed into the nvim treesitter plugin
Would it break helix support if the queries in this repo were moved into
queries/typst/*.scm
?
I think a symlink would also be a viable option, if for any other reason @uben0 does not want to change the project structure.
It would not break Helix support as Helix doesn't look for queries inside the tree-sitter directory (but rather in its own queries
config folder).
I can change that, but I thought I saw in the tree-sitter's documentation, indications about where to place query files. So I checked it up and I found this https://tree-sitter.github.io/tree-sitter/syntax-highlighting#language-configuration
It turns out, queries/*.scm
is the default, but can be customized in the package.json
🤷 but why? I don't know how important it is to stick to the tree-sitter documentation as no editors seems to follow it 😅
Here's my suggestion:
editors/neovim/*.scm
)queries/typst
to editors/neovim
, this way Neovim is supported out of the box. But one question: will a symlink work?It turns out, queries/*.scm is the default, but can be customized in the package.json 🤷 but why? I don't know how important it is to stick to the tree-sitter documentation as no editors seems to follow it 😅
lmao :D
I don't think editors/nvim/queries/typst
would work with the way vim plugin managers typically work. As I understand it, they add the plugin content root to the vim runtime path, and nvim-treesitter looks for queries/{language}/*.scm
in all directories in the runtime path
A symlink from queries/
to queries/typst
would work I think (though aren't symlinks a bit odd on windows?)
Oh I see, and I do agree that using a symlink, despite being an elegant solution, introduces uncertainty.
I will create one folder per editors, but the one for Neovim will be empty, just containing a README saying it is relocated at queries/typst
.
And the queries/typst
will contain queries for Neovim.
Done in e8ff9601292a3e531a264964e84d1045371a718f
Now you can modify the /queries/typst/*.scm
files to make them fully compatible with neovim and make a pull request.
I'm back from my hiatus and I'm willing to make the modifications and submit a PR for the minor changes on the nvim-treesitter/nvim-treesitter end
@RaafatTurki just had a PR merged with a custom queries built for neovim, please close this issue.
It should be relative straightforward to add support to neovim by following the instructions of the neovim-treesitter repo.
Let me know if you are interested and I can give it a go. I would add you as maintainer.