Open ChrHorn opened 1 year ago
This modification will be very welcome for Emacs. I am trying to design a Julia major mode (https://github.com/ronisbr/julia-ts-mode) and without this feature the automatic indentation will not work very well. For example, if we type:
function test(a)
end
And then press enter after )
, the cursor will start at the beginning of the line because there is no node inside the function body. Hence, we cannot apply an indentation rule in Emacs at least.
I see this has the label "help wanted".
What is involved here? It seems like this could be as simple as adding field('body', ...)
to e.g. function_definition
.
I don't know much about the build setup for this repo, but I am happy to try to take a stab at this if I can get some information about what is involved in going from making a change in grammar.js
and having build artifacts available.
Most languages make their blocks inside functions, classes, etc visible.
end
: Lua, Ruby (this was changed recently issue/PR){}
: C++, Rust, ...This added visible scope would make targeting the inside/body of a function much easier. Textobjekt queries that do this are currently very cumbersome to do.
The other advantage is tree-sitter based expanding/shrinking selection. Currently it is
expression -> whole function
with this change it would beexpression -> function body -> whole function
It would be much easier to select these code blocks without selecting the surrounding syntax.I think just changing everything to
block
should be fine. The exception would be the top scope. Here we already havesource_file
, so an additional scope is not needed.