Open sarimak opened 7 years ago
@sarimak How would that be done though? Not every code file supported by micro delineates code blocks in the same way. It could be a large performance hit to micro in addition to being rather difficult to implement.
I am aware of Scintilla-based editor with code folding - Geany - which uses lexers on top of parsers for finding the folding points. Maybe you could re-use at least the approach, if not the existing code?
See https://github.com/geany/geany/blob/7ae1d031efe8dd1b967c89ee404ab6fb2172ec4c/ctags/parsers/python.c for an example of a parser and https://github.com/geany/geany/blob/master/scintilla/lexers/LexPython.cxx#L715 for an example of a lexer + https://github.com/geany/geany/blob/2a2ae728341d12b7cea29b671beb08e441f62d95/scintilla/lexers/LexBasic.cxx#L101 for generic lexer's code related to folding.
And there is also a support for code folding in Github Atom: Per-language configuration: https://github.com/atom/language-python/blob/master/settings/language-python.cson Folding the view: https://github.com/atom/atom/blob/cc6e127ec149221871e4e6025616fa6e8118c138/src/language-mode.coffee#L94 Parser: https://github.com/atom/language-python/tree/master/grammars Plugin for custom folding: https://github.com/bsegraves/custom-folds (I don't speak JavaScript => these are at least some starting points)
If a generic approach would not be feasible, what about at least folding of indented lines (Python), folding of curly bracket contents (C-like family of languages) and user-hinted folding (like "Marker" at http://learnvimscriptthehardway.stevelosh.com/chapters/48.html - there is a good description of available approaches). Vim's folding could be explored from https://github.com/vim/vim/blob/9d20ce6970158de69202a82529d9e97827a9e71b/src/fold.c#L1120 where syntax parsers can be found at https://github.com/vim/vim/blob/d07969093a9b3051511c478d71c36de6fc33c0d6/runtime/syntax/python.vim
+1
It could be some keybinds like atom:
Any update on this? 😅
@Penguinlay As far as I know, nobody has started working on this feature yet. Be the change you want to see :slightly_smiling_face:
I code in my own bubble, but FWIW, indentation-based folding would absolutely be sufficient for me.
I am currently swamped but I will give it a shot this weekend. 😊
The only terminal editor I know of that supports code folding is Textadept (Scintilla based). See the discussion of the feature here: https://foicica.com/textadept/api.html#lexer
The only terminal editor I know of that supports code folding is Textadept (Scintilla based). See the discussion of the feature here: https://foicica.com/textadept/api.html#lexer
FYI vim, neovim supports code folding out of the box.
The only killer feature available in modern graphical code editors seems to be missing in micro: code folding. I understand the implementation would be non-trivial but the benefit of having such feature is really high. Please consider adding it.