Comment by chubot
1 day ago
Nested is also demonstrated by stage 2 fixing the "nested double quotes bug". Screenshots:
https://github.com/oils-for-unix/oils.vim/blob/main/doc/stag...
Stage 1 is non-recursive, but stage 2 is recursive.
1 day ago
Nested is also demonstrated by stage 2 fixing the "nested double quotes bug". Screenshots:
https://github.com/oils-for-unix/oils.vim/blob/main/doc/stag...
Stage 1 is non-recursive, but stage 2 is recursive.
fair, recursive groups exist, and yeah stage 2’s structure is solid. but the point was less about recursion as a feature and more about context awareness. vim’s engine lets you nest, sure, but it doesnt preserve intent across transitions. you can recurse into quoted strings, command subs, etc, but you can’t reflect on why you entered a state. there's no semantic trace. take ysh: command vs expression isn’t just syntactic, it shifts meaning of the same tokens. `[` in one context is an index, in another it’s test. vim can match both, but it can’t decide which meaning is active unless the outer mode is remembered. and that’s the gap
tbh the plugin is impressive, no question. but that memoryless model will always need compromises, rule layering, and finetuned sync tricks. treesitter has its issues too, agreed. but having typed nodes and scope trees gives a baseline advantage when meaning depends on ancestry.
> `[` in one context is an index, in another it’s test. vim can match both, but it can’t decide which meaning is active unless the outer mode is remembered. and that’s the gap
ysh.vim solves exactly that problem.
The [ in command mode (test) is not highlighted.
In contrast, the [ within expressions like a[i] is highlighted (currently Normal, but you can make it any color - https://github.com/oils-for-unix/oils.vim/blob/main/syntax/l... )
Again I recommend trying it. Verify what you think the bugs are. I think you have some preconceptions based on using other Vim plugins.
Vim's model is powerful enough to write good plugins, or bad plugins. That is one of the main points of this article.
sure, i'll give it a proper test, but just to clarify my point wasn't that it can't highlight the brackets right, it's that it doesn't know why it's doing it. if the plugin works, it's because someone manually encoded enough of ysh's rules to simulate context. that's impressive engineering, no doubt. but the engine still doesn't track semantic intent across shifts unless you build that logic yourself. that's the memory gap i meant. so yeah, your plugin might solve it for now, but only by outsmarting the engine, not because the engine inherently understands