vimrc

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules

commit 3bf51bb654ae3a66f09bc42e6fd356ae1af779f2
parent 24b4f3e7b3d8e3e5f40328f13b9926464ea94109
Author: Pablo Cárdenas <pablo.cardenas@imca.edu.pe>
Date:   Sat,  2 May 2026 20:51:02 -0300

folds: improve python folding

Diffstat:
Mpack/pablo/opt/folds/ftplugin/python.vim | 20+++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/pack/pablo/opt/folds/ftplugin/python.vim b/pack/pablo/opt/folds/ftplugin/python.vim @@ -16,12 +16,15 @@ def MyFoldFunc(): string const line = getline(i_line + 1) const nextline = getline(i_line + 2) if line =~ '^# %% \[markdown\]' - if nextline =~ '^# #' + if nextline =~ '^# # ' current_foldlevel = 1 firstblock = true - elseif nextline =~ '^# ##' + elseif nextline =~ '^# ## ' current_foldlevel = 2 firstblock = true + elseif nextline =~ '^# ### ' + current_foldlevel = 3 + firstblock = true endif b:foldlevels->add('>' .. current_foldlevel) elseif line =~ '^# %%' @@ -30,12 +33,14 @@ def MyFoldFunc(): string firstblock = false endif b:foldlevels->add('>' .. current_foldlevel) - elseif nextline =~ '^# %% \[markdown\]' && !firstblock + elseif nextline =~ '^# %% \[markdown\]' const nextnextline = getline(i_line + 3) - if nextnextline =~ '^# #' + if nextnextline =~ '^# # ' b:foldlevels->add('0') - elseif nextnextline =~ '^# #' + elseif nextnextline =~ '^# ## ' b:foldlevels->add('1') + elseif nextnextline =~ '^# ### ' + b:foldlevels->add('2') else b:foldlevels->add('' .. current_foldlevel) endif @@ -51,11 +56,12 @@ enddef def CustomFoldText(): string const line = getline(v:foldstart + 1)->substitute('^# ', '', '') const nlines = v:foldend - v:foldstart + 1 - return printf('+--%3d lines: %s', nlines, line) + return '+' .. v:folddashes .. printf('%3d lines: %s', nlines, line) enddef -setlocal foldexpr=MyFoldFunc() setlocal foldmethod=expr +setlocal foldexpr=MyFoldFunc() setlocal foldtext=CustomFoldText() +setlocal foldlevel=1 # vim: et sts=4 sw=4