M
Modular•4mo ago
lukas

tree-sitter-mojo

I had half an hour today, and Mojo is close enough to Python, so I forked the Python Tree Sitter grammar and got it working for mojo.
No description
49 Replies
lukas
lukas•4mo ago
GitHub
GitHub - lsh/tree-sitter-mojo: Mojo grammar for tree-sitter
Mojo grammar for tree-sitter. Contribute to lsh/tree-sitter-mojo development by creating an account on GitHub.
Dmitry Salin
Dmitry Salin•4mo ago
Nice, I will try to use your variant with Helix editor. You can also look at https://github.com/garam-kim1/tree-sitter-mojo The idea is to automatically update using GitHub Actions.
GitHub
GitHub - garam-kim1/tree-sitter-mojo: mojo grammar for tree-sitter
mojo grammar for tree-sitter. Contribute to garam-kim1/tree-sitter-mojo development by creating an account on GitHub.
lukas
lukas•4mo ago
Oh if I had seen that maybe I would have just used that lol
Dmitry Salin
Dmitry Salin•4mo ago
I haven't looked into the details, but perhaps your mojo part of the grammar is more relevant. But without automation it will be difficult to maintain such a fork. https://github.com/garam-kim1/tree-sitter-mojo/blob/master/.github/workflows/tree_sitter_maker.yml
Jack Clayton
Jack Clayton•4mo ago
Epic thanks both helix works now!
No description
lukas
lukas•4mo ago
Whoops I forgot to add alias, should do that now
Dmitry Salin
Dmitry Salin•4mo ago
It would be nice to push Helix PR forward at some point. https://github.com/helix-editor/helix/pull/8657
GitHub
feat: adds mojo language support by mabasic · Pull Request #8657 · ...
The same as: #8583 removed tags.scm removed commented line from language.toml applied suggested changes
Jack Clayton
Jack Clayton•4mo ago
If you raise a PR from your repo @Dmitry Salin it might avoid that test failure?
Dmitry Salin
Dmitry Salin•4mo ago
It's not mine, but it could definitely be used in PR and then maybe the build and tests will be ok. It seems better to create a new PR. The current one is already the second 🙂
ModularBot
ModularBot•4mo ago
Congrats @Dmitry Salin, you just advanced to level 1!
lukas
lukas•4mo ago
FWIW this is my helix config and it works for me
[language-server.mojo-lsp]
command = "mojo-lsp-server"
config = { provideFormatter = true }

[[grammar]]
name = "mojo"
source = { git = "https://github.com/lsh/tree-sitter-mojo", rev = "e645ad097257a29bed5ee6213fef47e26b280f63" }

[[language]]
name = "mojo"
grammar = "mojo"
scope = "source.mojo"
roots = ["__init__.mojo"]
file-types = ["mojo", "🔥"]
indent = { tab-width = 4, unit = " " }
auto-format = true
language-servers = ["mojo-lsp"]
formatter = { command = "mojo", args = ["format", "-q", "-"]}
[language-server.mojo-lsp]
command = "mojo-lsp-server"
config = { provideFormatter = true }

[[grammar]]
name = "mojo"
source = { git = "https://github.com/lsh/tree-sitter-mojo", rev = "e645ad097257a29bed5ee6213fef47e26b280f63" }

[[language]]
name = "mojo"
grammar = "mojo"
scope = "source.mojo"
roots = ["__init__.mojo"]
file-types = ["mojo", "🔥"]
indent = { tab-width = 4, unit = " " }
auto-format = true
language-servers = ["mojo-lsp"]
formatter = { command = "mojo", args = ["format", "-q", "-"]}
Melody Daniel
Melody Daniel•4mo ago
This is what I get while trying to compile the parser in Neovim Edit: I just failed to include scanner.c, it is compiled now.
No description
Jack Clayton
Jack Clayton•4mo ago
Only thing stopping me from using Helix as my main editor is it still doesn't have persistent undo history. I tried building this but doesn't work on mac: https://github.com/helix-editor/helix/pull/9154
lukas
lukas•4mo ago
Just pushed better support for parameter functions and decorators. Also wrote a Zed extension
Jack Clayton
Jack Clayton•4mo ago
Awesome cheers @lukas!
Want results from more Discord servers?
Add your server