Created
November 24, 2016 09:22
-
-
Save pryg-skok/7e27d897fc3a19ebc89d33b062eac536 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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