forked from aliev/vim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stuff.vim
239 lines (201 loc) · 5.75 KB
/
stuff.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
" Airline {{{
let g:airline_powerline_fonts = 1 " Use airline fonts
" If you want to auto-completion to work stable in older vim, disable this option
let g:airline#extensions#tabline#enabled = 1
" Airline tabline settings
let g:airline#extensions#tabline#fnamemod = ':t'
" }}}
" Jedi-vim {{{
let g:jedi#show_call_signatures = 0
let g:jedi#use_tabs_not_buffers = 0
let g:jedi#popup_on_dot = 1
" }}}
" Indent-line {{{
" Make indent line faster
let g:indentLine_faster=1
" IndentLine character For use this feature please install patched font from repository root
let g:indentLine_char=nr2char(0xE0A3)
" }}}
" Syntastic {{{
" Syntax check mode for python (pip install pylama)
let g:syntastic_python_checkers = ['flake8']
" Syntax check mode for javascript (npm install jslint)
let g:syntastic_javascript_checkers = ['jslint']
" Make syntastic auto update the location list and make it also check
" when the file opens
let g:syntastic_always_populate_loc_list=1
let g:syntastic_check_on_open=1
let g:syntastic_enable_signs=0
" }}}
" NERDTree {{{
let NERDTreeMinimalUI = 1
let NERDTreeIgnore = ['\.pyc$']
" }}}
" Color options {{{
colors lucius " Color scheme
" Disable colors for folding column
hi FoldColumn ctermbg=NONE guibg=NONE
" Sign colors
hi! link SignColumn FoldColumn
" Disable background and foreground for vertical split
hi vertsplit ctermbg=NONE guibg=NONE
hi! link Folded ColorColumn
hi! link Error SpellBad
" }}}
" UltiSnips {{{
let g:UltiSnipsJumpForwardTrigger='<tab>'
" }}}
" Aurline {{{
let g:airline_section_c = '%t'
" }}}
" GitGutter {{{
let g:gitgutter_max_signs=10000
" }}}
" | Goto file with line number under cursor | gf | {{{
nnoremap gf gF
" }}}
" | Show NERDTree | leader+e | {{{
nnoremap <silent> <Leader>e :NERDTreeToggle<CR>
" }}}
" | List toggle | leader+l | {{{
nnoremap <silent> <Leader>l :set list!<CR>
" }}}
" | Close buffer with ask save it | leader+w | {{{
nnoremap <silent> <Leader>w :confirm :Bclose<CR>
" }}}
" | Silver searcher | :Ag | {{{
function! s:ag_to_qf(line)
let parts = split(a:line, ':')
return {'filename': parts[0], 'lnum': parts[1], 'col': parts[2],
\ 'text': join(parts[3:], ':')}
endfunction
function! s:ag_handler(lines)
if len(a:lines) < 2 | return | endif
let cmd = get({'ctrl-x': 'split',
\ 'ctrl-v': 'vertical split',
\ 'ctrl-t': 'tabe'}, a:lines[0], 'e')
let list = map(a:lines[1:], 's:ag_to_qf(v:val)')
let first = list[0]
execute cmd escape(first.filename, ' %#\')
execute first.lnum
execute 'normal!' first.col.'|zz'
if len(list) > 1
call setqflist(list)
copen
wincmd p
endif
endfunction
command! -nargs=* Ag call fzf#run({
\ 'source': printf('ag --nogroup --column --color "%s"',
\ escape(empty(<q-args>) ? '^(?=.)' : <q-args>, '"\')),
\ 'sink*': function('<sid>ag_handler'),
\ 'options': '--ansi --expect=ctrl-t,ctrl-v,ctrl-x '.
\ '--multi --bind ctrl-a:select-all,ctrl-d:deselect-all '.
\ '--color hl:68,hl+:110',
\ 'down': '50%'
\ })
" }}}
" | Quickly jump by declarations list | leader+b |{{{
function! s:align_lists(lists)
let maxes = {}
for list in a:lists
let i = 0
while i < len(list)
let maxes[i] = max([get(maxes, i, 0), len(list[i])])
let i += 1
endwhile
endfor
for list in a:lists
call map(list, "printf('%-'.maxes[v:key].'s', v:val)")
endfor
return a:lists
endfunction
function! s:btags_source()
let lines = map(split(system(printf(
\ 'ctags -f - --sort=no --fields=nKs --excmd=pattern --language-force=%s %s',
\ &filetype, expand('%:S'))), "\n"), 'split(v:val, "\t")')
if v:shell_error
throw 'failed to extract tags'
endif
return map(s:align_lists(lines), 'join(v:val, "\t")')
endfunction
function! s:btags_sink(line)
let lines = split(a:line, "\t")
for line in lines
let arr = split(line, ":")
if arr[0] == "line"
exec arr[-1]
endif
endfor
sil! norm! zvzz
endfunction
function! s:btags()
try
call fzf#run({'source': s:btags_source(),
\'down': '50%',
\'options': '+m -d "\t" --with-nth 4,1,5',
\'sink': function('s:btags_sink')})
catch
echohl WarningMsg
echom v:exception
echohl None
endtry
endfunction
command! BTags call s:btags()
nnoremap <silent> <Leader>s :BTags<CR>
" }}}
" | Buffer list | leader+b | {{{
function! s:buflist()
redir => ls
silent ls
redir END
return split(ls, '\n')
endfunction
function! s:bufopen(e)
execute 'buffer' matchstr(a:e, '^[ 0-9]*')
endfunction
nnoremap <silent> <Leader>b :call fzf#run({
\ 'source': reverse(<sid>buflist()),
\ 'sink': function('<sid>bufopen'),
\ 'options': '+m',
\ 'down': len(<sid>buflist()) + 2
\ })<CR>
" }}}
" | Open files in splits | leader+f, leader+v | {{{
" Open files
nnoremap <silent> <Leader>f :call fzf#run({
\ 'down': '40%',
\ 'sink': 'e' })<CR>
nnoremap <silent> <Leader>v :call fzf#run({
\ 'right': winwidth('.') / 2,
\ 'sink': 'vertical botright split' })<CR>
" }}}
" | MRU search | :FZFMru | {{{
command! FZFMru call fzf#run({
\'source': v:oldfiles,
\'sink' : 'e ',
\'options' : '-m',
\})
function! s:line_handler(l)
let keys = split(a:l, ':\t')
exec 'buf' keys[0]
exec keys[1]
normal! ^zz
endfunction
" }}}
" | Search lines in all open vim buffers | :FZFLines | {{{
function! s:buffer_lines()
let res = []
for b in filter(range(1, bufnr('$')), 'buflisted(v:val)')
call extend(res, map(getbufline(b,0,"$"), 'b . ":\t" . (v:key + 1) . ":\t" . v:val '))
endfor
return res
endfunction
command! FZFLines call fzf#run({
\ 'source': <sid>buffer_lines(),
\ 'sink': function('<sid>line_handler'),
\ 'options': '--extended --nth=3..',
\ 'down': '60%'
\})
" }}}
" vim:foldmethod=marker:foldlevel=0