Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
augroup pythonFold
autocmd!
autocmd BufReadPre *.py setlocal foldmethod=indent
autocmd CursorMovedI *.py call LightlineContext()
autocmd CursorMoved *.py call LightlineContext()
augroup END
function! PinFold()
" save current position
let saveCursor = getcurpos()
" Go to upper split, open all folds and go to the same line as bottom split
normal! zR
execute "normal! " . saveCursor[1] . "G"
" Go to the beginning of the fold and put the line top of the upper split
normal! [zkk
normal! zt
let contextline=getline('.')
" Go back to bottom split and restore position
call setpos('.', saveCursor)
return contextline
endfunction
function! LightlineContext()
return PinFold()
endfunction
Config for lightline:
\ 'component_function': {
\ 'context': 'LightlineContext',
\ },
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.