Open teto opened 7 years ago
with the current code it should be easy to adjust dynamically the foldcolumn width depending on the nesting fold depth
Won't that make the screen "bounce around" when opening/closing a fold? Allowing the foldcolumn width to be configurable should be enough. Any deeper folds should just show the fold symbol in the rightmost column of the foldcolumn (leftmost when 'rtl'
is set).
multicell display ? I wonder if some multicell character can improve the foldcolumn look enough to justify the addition. Which character would you like (I could only find that one '+') ?
I wouldn't bother with that. If the fold display is "externalized" later, even a TUI could show a custom layout.
character customization ? it's easy to change foldcolumn characters in the source but that might be a nice setting to have ? In fillchars ?
Given that "stl:" is part of fillchars, adding "foldcolumn:" or something like that, makes sense.
add nvim_create_fold() to API ?
👍 Definitely in favor.
help with folds UI externalization ? GUIs could draw better folds for sure
I suggest waiting until #5686 is finished.
Won't that make the screen "bounce around" when opening/closing a fold? Allowing the foldcolumn width to be configurable should be enough. Any deeper folds should just show the fold symbol in the rightmost column of the foldcolumn (leftmost when 'rtl' is set).
What I was thinking of is:
-Opening/closing a fold doesn't change the fdc width
-Creation/fold can change fdc width and "bounce". If neovim looks at the buffer-wide maximum nesting depth, the bouncing should be relatively infrequent
For instance, in my config I have :set fdc=3
and when my buffer has no folds, nvim displays 3 empty columns (=lost).
I wouldn't bother with that. If the fold display is "externalized" later, even a TUI could show a custom layout.
guess you are right, it adds too much complexity and limits the number of folds that can be displayed.
I got fillchars working. My problem with adaptive fdc is that is changes the meaning of the variable, i.e. it becomes the maximum width. As it might be controversial I will focus on improving tests first.
Btw, if anyone knows how to know if the current screen line is a wrapped line or not, it could spare me some analysis (seems that LineWraps
is the key but does it accepted a "screenline" or "file line" ?).
I am very tempted to change the current behavior when current line foldlevel > fdc
, i.e., vim prints somehow the fold levels. It does not make much sense to me but I am curious if others feel different, if they like it and how they use it:
aa
- {
|- {
2- {
23 bb
23 }
|| cc
|| }
| dd
| ee
|+ +--- 3 lignes : --------------------------------------------------------------------------------------------------------------------
| }
gg
I would like to convey the information there are hidden folds in another way.Highlights are too distracting. I thought of some alternatives:
||3
. Visually I would opt for ||>
but it conveys less information and might bother some.
Compared to the previous example; somethink like
|- {
|- {
|3 bb
|3 }
|| cc
|| }
| dd
Neat idea, but might be overwrought. Users should already know what to expect based on their 'foldnestmax', for example.
Users should already know what to expect based on their 'foldnestmax
Agreed that's why I find the vim numbers more confusing than anything, makes current folds hard to read. Am I right in understanding you would be ok with another behavior ? In fact I finally found a behavior I am comfortable with, ie., on the last column, just do as in all other editors and put fold open/closed on the same line. Here is a preview with a max nesting of 3.
With enough fdc, there are no problems:
But when the number of columns is not enough to display each fold on its own column, nvim merges all the folds with a level >= fdc on the same column; example with fdc=2:
...and fdc=1:
If you are ok with it I can proceed with cleaning the code and writing tests.
Can you annotate the pictures? I'm not seeing how that's different from the OP or existing behavior.
I've been working to improve the terminal folding display and some things I think are LGTM:
put_folds
, use https://github.com/vim/vim/issues/6004 or the API https://github.com/neovim/neovim/pull/11523)FoldedLight
highlight):2,1fold
fails withfdm=marker
because foldCreate uses start/end instead of start_rel/end_relBut some aspects I am less confident with and would like some input:
multicell display ? I wonder if some multicell character can improve the foldcolumn look enough to justify the addition. Which character would you like (I could only find that one '+') ?Nb: as a reminder for myself: lines displayed on screen are generated by win_line and fold_line. Both functions write their result in
current_ScreenLine
which is copied later at the right offset. fold_line fillscurrent_ScreenLine
viacopy_text_attr
calls but this function doesn't support multibytes characters.screen_puts_len
is a powered up version ofcopy_text_attr
that support multibytes characters BUT it can't write to 'current_ScreenLine' because it can't compute its offset.