yi-editor / yi

The Haskell-Scriptable Editor
GNU General Public License v2.0
1.51k stars 201 forks source link

Feature Request (vim-binding): Join (J) merges comments like in neovim #1047

Open stites opened 7 years ago

stites commented 7 years ago

One neovim feature which I think is nice: Given some file for which we know what a comment is (in this case a .hs file): 2017-09-28-145402_129x92_scrot Hitting join (J) merges the comments: 2017-09-28-145500_143x74_scrot

noughtmare commented 7 years ago

We could implement this ad-hoc, or we could go the full structured editing route. Ad hoc seems easier at first, but it doesn't scale if we want to add lots of similar features in the future.

thomastjeffery commented 7 years ago

Full structured editing would be fantastic. We could write functions that read the syntax tree for a buffer, generate an edit, and put it in the right place. That way most of these functions can be totally language independent, but still do exactly the right thing.

If I am understanding correctly, there are syntax trees being generated separately for each language, right?

I think first we would need to have one standard syntax tree type, so there can be a standard way of reading it.

In order to generate code, like correct indentation (like == in Vim), refactoring (take a lambda out, and write a named function, etc.), merging comments, etc. we need a set of rules for each language to make generating code unambiguous. Otherwise, we don't know how much indentation to use where, how comments should look, etc.

How would all of this look with yi's current codebase?