39 ms·
I wish source code editors were much more AST-oriented rather than row-column-oriented. Sure, it’s more difficult when your grammar is more complex than s-expre
by Sharlin 4y ago
I wish source code editors were much more AST-oriented rather than row-column-oriented. Sure, it’s more difficult when your grammar is more complex than s-expressions, but most editors these days maintain an AST of the source in real time anyway.
Features such as selection that grows "inside out" (or bottom-up) rather than line by line, moving a selection around to the next/previous valid position, moving various delimiters around to next/previous valid position, enclosing whatever’s under the cursor in a new block/pair of parens, and so on.
Unless we’re talking about FORTRAN or COBOL circa 1960, source code is a tree natively and text only incidentally.
- davidkunz 4y agoHave a look at Neovim with its Tree-Sitter parser, it enables such 'growing selections' natively. It's also relatively easy to write plugins based on the parsed AST. I wrote treesitter-unit[1] making it easy to select/modify the subtree of the selection. [1]: https://github.com/David-Kunz/treesitter-unit https://github.com/David-Kunz/treesitter-unit
- ckolkey 4y agoI think you'll find treesitter quite interesting: https://github.com/nvim-treesitter/nvim-treesitter#incremental-selection https://github.com/nvim-treesitter/nvim-treesitter#increment...