-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlightline.vim
107 lines (83 loc) · 2.32 KB
/
lightline.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
function! LightlineModified()
if &filetype == "help"
return ""
elseif &modified
return "+"
elseif &modifiable
return ""
else
return ""
endif
endfunction
function! LightlineReadonly()
if &filetype == "help"
return ""
elseif &readonly
return "RO"
else
return ""
endif
endfunction
function! LightlineFugitive()
try
if expand('%:t') !~? 'Tagbar\|NERD' && exists('*fugitive#head')
let branch = fugitive#head()
return branch !=# '' ? '⎇ '.branch : ''
endif
catch
endtry
return ''
endfunction
function! LightlineFileformat()
return winwidth(0) > 70 ? &fileformat : ''
endfunction
function! LightlineFiletype()
return winwidth(0) > 70 ? (&filetype !=# '' ? &filetype : '[No ft]') : ''
endfunction
function! LightlineFileencoding()
return winwidth(0) > 70 ? (&fenc !=# '' ? &fenc : &enc) : ''
endfunction
function! LightlineFilename()
return ('' != expand('%:t') ? expand('%:t') : '[No Name]') .
\ ('' != LightlineModified() ? ' ' . LightlineModified() : '')
endfunction
function! LightlineMode()
let fname = expand('%:t')
return fname == '__Tagbar__' ? 'Tagbar' :
\ fname =~ 'NERD_tree' ? 'NERDTree' :
\ &ft == 'unite' ? 'Unite' :
\ winwidth(0) > 60 ? lightline#mode() : ''
endfunction
" augroup AutoNeomake
" autocmd!
" autocmd BufWritePost *.py,*.go call s:neomake()
" augroup END
" function! s:neomake()
" Neomake
" call lightline#update()
" endfunction
function! TagbarStatusFunc(current, sort, fname, ...) abort
let g:lightline.fname = a:fname
return lightline#statusline(0)
endfunction
function! FoldContext()
augroup pythonFold
autocmd BufReadPre *.py setlocal foldmethod=indent
autocmd BufReadPost *.py wincmd s | wincmd k | resize 3 | wincmd j
autocmd CursorMovedI *.py call PinFold()
autocmd CursorMoved *.py call PinFold()
augroup END
endfunction
function! PinFold()
let saveCursor = getcurpos()
" Go to upper split, open all folds and go to the same line as bottom split
wincmd k
normal! zR
execute "normal! " . saveCursor[1] . "G"
" Go to the beginning of the fold and put the line top of the upper split
normal! [zk
normal! zt
" Go back to bottom split and restore position
wincmd j
call setpos('.', saveCursor)
endfunction