Closed Hubro closed 2 years ago
It doesn't. Your indent system does.
Off the top of my head, autoindent
probably registers ncs:
as a label, moves that to the front, and does whatever thing with with the other bracket based on what autoindent sees as logical. That said, I don't understand the inner workings of any of the indent systems, so I'm not sure what the exact reason is.
However, you can trivially prove it is the indent system by copying the last example, highlighting the three lines, and pressing =
. You'll get your exact output; and that's on Vim, not auto-pairs
@LunarWatcher I see, thanks. I thought I had eliminated that possibility by disabling cindent
, but I guess not :thinking:
Removing :
from cinkeys
had no effect, nor does removing it from indentkeys
... Any combination of autoindent
, smartindent
and cindent
also doesn't appear to have any effect.
Vim indentation is... tricky, to say the least. All three built-in options have a lot of limitations outside C-like languages, unfortunately. You're better off either finding or creating an indentexpr in most other cases. Or, of course, just dealing with the indentation being weird. Unfortunately, there doesn't seem to be any indentexprs for yang at this time, so no easy way out there.
That said, tree-sitter supports indentation, and a search for tree-sitter yang parsers reveals a repo you made :p Tree-sitter is still somewhat outside my area of expertise, but you might be able to fix this by enabling tree-sitter indentation (assuming you haven't already, and assuming the yang parser supports it, if it needs to explicitly). In general, you just want a more sane indentexpr than Vim's built-in system, and tree-sitter should be able to provide that.
Alright, thanks a lot! I'll try to mess around with tree-sitter indentation.
In file
test.yang
:(Cursor is marked with
|
on line 5)When I press Enter now, the result is:
I would expect the result to be:
Why does this happen?
Neovim v0.6.1 auto-pairs master branch (
39f06b873a8449af8ff6a3eee716d3da14d63a76
)