Skip to content

Conversation

@Igonato
Copy link

@Igonato Igonato commented Dec 24, 2025

Adding Odin support (#182). Currently there are false positives with CONSTANTS in enum variant values and bit_fields size:

image

Can use another pair of eyes, I might be missing a way to make a query that can handle this case. It is also possible that's the grammar needs changing. Grammar for reference: https://github.com/tree-sitter-grammars/tree-sitter-odin/blob/master/grammar.js

What do you think?

@blopker
Copy link
Owner

blopker commented Dec 31, 2025

This looks great so far, but oof, I have no idea how to read Odin. There's also no Odin support in my tree-sitter visualizer, so debugging this will take some time. I'd be happy to merge this as is though if you want it in now?

@Igonato
Copy link
Author

Igonato commented Jan 1, 2026

Hey, I'd like to spend more time on it, just got distracted with the holidays (Happy New Year btw 🎉). I'm reading up on Tree-sitter, I wanted to learn how to make a parser anyway, then I'll know for sure if it's limited by the grammar or just needs a better query.

@blopker
Copy link
Owner

blopker commented Jan 1, 2026

Happy new year! Sounds good. I find that adding tests helps with the iteration speed a lot. Happy to answer any questions, but I have no experience with Odin specifically 🙂

@Igonato
Copy link
Author

Igonato commented Jan 1, 2026

Oh, I had some tests already, just didn't include them in the PR. They immediately flagged the duplication and I figured better do a proper fix instead of figuring how to suppress those and submitting a partial solution.

Odin is quite simple, no-nonsense, boring in a good way and the community is awesome! If you find a spare hour, I would encourage you to look up some interviews with the creator of Odin @gingerBill and give the language a try. I found that it simplicity brought back joy to my programming life, serving as a nice break from the Web and Rust stuff.

@Igonato
Copy link
Author

Igonato commented Jan 5, 2026

Didn't mean to do that. Sorry

@Igonato Igonato reopened this Jan 5, 2026
@Igonato
Copy link
Author

Igonato commented Jan 5, 2026

I wanted to tidy things up and force-pushed your current main to my working branch, turns out that closes the PR, TIL I guess.

From what I was able to gather, grammar is indeed needed to be changed, I ended up forking it and publishing it under a different crate since the original doesn't seem to be active. I also merged changes from one of the more active forks, not sure that it was necessary for Codebook specifically, and in hindsight it wasn't, but I think it shouldn't hurt. If you want to verify that I didn't do anything funny, you can:

git clone [email protected]:Igonato/tree-sitter-odin-codebook.git
cd tree-sitter-odin-codebook
tree-sitter generate

And check the diff. My tree-sitter --version is 0.26.3.

I have some thoughts how we can better handle grammars in this project, I'll write that a new issue since it's unrelated to the PR. Cheers!

@Igonato
Copy link
Author

Igonato commented Jan 9, 2026

Rebased on the latest main and ran cargo test. Please let me know if anything else is needed

@blopker
Copy link
Owner

blopker commented Jan 9, 2026

Hey! Nice, I've had to fork a few grammars myself, which is kind of a pain. I saw your proposal issue. I need to investigate a bit, but I'll reply to that issue.

Anyway, this looks great! Thank you.

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