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
feat(matlab)!: replace parser #4944
Conversation
The full list of allowed captures (which is different from upstream/Helix) is here: https://github.com/nvim-treesitter/nvim-treesitter/blob/master/CONTRIBUTING.md#highlights. |
45dcc90
to
d71654a
Compare
Fixed.
Removed.
Was already there, only comments. MATLAB does not allow injections.
Was already there, at the end of the file. For strings and comments only, as most other projects do.
I fixed the function call one, but it seems to be the only trully different from what I had already. |
We also have indents; you could try adding at least initial support for them? (Not required.) |
You also need to change the commit hash in the |
I forgot about it, thank you for the reminder. It's in the repo now. And I also changed the commit in the lockfile. |
Note that the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indents.scm
looks fine to me now 👍
|
Just saw it. Already changed it to be just |
I had a |
When I first wrote this I was thinking about taking screenshots of the existing grammar and mine to show the difference, and then I thought it would be too much trouble and just wrote that text. Now I just realized that Helix uses the existing one too, so I only had to open helix and neovim to compare both. Night and day. |
I added textobjects to some classes constructs, which required a small grammar adaptation. |
The change in order revealed that I had a named node and some aliases with the same name, but totally different contexts. Fixed that. |
MATLAB accepts cell-indexing as a function identifier, |
208c8b3
to
787c183
Compare
Fixed the matrix parsing, it now follows MATLAB way of doing it a bit closer. |
There are some design choices and many issues with the grammar and queries that I do not agree with/are incorrect and I think are better fixed upstream before adding here. Let me know if you'd be welcome to a PR on my end, that'd be easier than writing a bunch of comments here |
Sure, go ahead. |
Head branch was pushed to by a user without write access
I added a file that should not be in the commit. The last force-push only removes that file. |
Is the pr ready to be merged? |
Yes. |
I just created nvim-treesitter/nvim-treesitter-context#292 and nvim-treesitter/nvim-treesitter-textobjects#468 to follow this one. |
I wrote a MATLAB parser which has more features than the current one:
returns a
function_call
token with 2argument
tokens, which is how matlab sees it. I use a scanner to correctly detect the line, so it won't mix it with a function call followed by a identifier."Format: \t %2.3f"
The parser also generates more tokens, which allows to better handle not only syntax highlighting, but specially textobjects. For instance, matrices and cells are composed of rows with values, which allows the creation of textobjects to operate on those, which is something I was missing a lot. At this point I believe I have implemented everything in MATLAB's grammar.