Open RicardoRamirezR opened 6 months ago
I took a crack at this, but I'm pretty sure it's impossible with the current grammar. The indent.begin
is used to indent child nodes and the current grammar has them as siblings instead.
Mmmm can I have an example of how this is used? I have never come across this capture.
Is this used to implement a functionality like this? 🤔
@php
automatic indentation after pressing return
@endphp
Bingo, you can find a ton of indents.scm
below:
https://github.com/nvim-treesitter/nvim-treesitter/tree/master/queries
Oh wow that's a goldmine thanks for sharing all these goodies @calebdw ! As always very much appreciated!
Well, that's not good at all! 😬
I will definitely look into this when I get a chance, but as I am extremely busy just now with university work. It might be a while!
Nova bizarrely still uses their old XML RegEx API to do the indentation hence the oversight.
Regardless, being siblings does not make sense anyways. The stuff should appear as sub-tree! 😊
I have a few questions. I have been playing around in Helix, but I am a bit unsure about the workflow in the modal editors.
@if
and then it prints stubs?
@if(<placeholder>)
<placeholder>
@endif
@if
the editor indents, when you type @endif
do you expect the editor to automatically outdent the line with the @endif
as well?I managed to get the indent working in Helix using the current grammar, for if statements
, but there are some caveats:
For normal indentation to work, the @if
and @endif
must be written and present. (this is like brackets, without the matching pair no indentation happens. At least with helix and their defaults anyways)
I did of course managed to get around this using a specific capture they have for python style grammars, which is @indent @extend
but not sure what would be the equivalent in NeoVim
On both occasions, I do need to manually outdent the @endif
... is this an expected behaviour?
tree-sitter
, meaning each editor will need to have a different indents.scm
for sure!https://github.com/EmranMR/tree-sitter-blade/assets/11975985/1706d8b9-e266-4429-9ba3-4e31fa8322c6
@if
and it would end when there's an @endif
Indents would be backed into the snippet, but that's completely separate from treesitter indents
Indentation should happen as soon as there's an
@if
and it would end when there's an@endif
Looks promising!
Because if you have snippets, you can align @if
and @endif
, then allow the editor to take over indentation.
So I reckon the video I uploaded shows a correct functioning indentation?
@if
o
, <return>
and O
(from endif) to get the indent@endif
and press return
the editor indents back!As you said I prob have to adjust some of the nodes, but seems feasible.
I will see how the query works out if too complicated I will just write the stubs so people can have a look and port, like the other scm
files. But hoping to keep it clean and simple as possible!
The only gotcha were the nodes that can also be inline, @php()
and @php @endphp
but already have some ideas how I could get around!
Hi all, do any one has an indents.scm file for share