Skip to content

Make fold levels be buffer local. #419

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions autoload/sy/fold.vim
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

" SignifyFoldExpr {{{1
function! SignifyFoldExpr(lnum)
return s:levels[a:lnum]
return b:levels[a:lnum]
endfunction

" SignifyFoldText {{{1
Expand Down Expand Up @@ -48,8 +48,8 @@ function! sy#fold#enable(do_tab) abort
tabedit %
endif

let [s:context0, s:context1] = get(g:, 'signify_fold_context', [3, 8])
let s:levels = s:get_levels(s:get_lines())
let [context0, context1] = get(g:, 'signify_fold_context', [3, 8])
let b:levels = s:get_levels(s:get_lines(), context0, context1)

setlocal foldexpr=SignifyFoldExpr(v:lnum)
setlocal foldtext=SignifyFoldText()
Expand Down Expand Up @@ -92,22 +92,22 @@ function! s:get_lines() abort
endfunction

" s:get_levels {{{1
function! s:get_levels(lines) abort
function! s:get_levels(lines, context0, context1) abort
let levels = {}

for line in range(1, line('$'))
let levels[line] = 2
endfor

for line in a:lines
for l in range(line - s:context1, line + s:context1)
for l in range(line - context1, line + context1)
if (l < 1) || (l > line('$'))
continue
endif
if levels[l] == 2
let levels[l] = 1
endif
for ll in range(line - s:context0, line + s:context0)
for ll in range(line - context0, line + context0)
let levels[ll] = 0
endfor
endfor
Expand Down