Repository navigation
Expand file tree
/
Copy path_vimrc
More file actions
executable file
·437 lines (365 loc) · 11.8 KB
/
Copy path_vimrc
File metadata and controls
executable file
·437 lines (365 loc) · 11.8 KB
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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
set nocompatible
filetype indent on
" {{{ PLUGINS
set rtp+=~/vimfiles
if !empty(glob("~/vimfiles/autoload/pathogen.vim"))
call pathogen#infect()
endif
" vim-polyglot
let g:vim_markdown_conceal = 0
" autoformat
nnoremap <F5> :Autoformat<CR>
let g:formatdef_autopep8 = "'autopep8 - --aggressive'"
let g:formatters_python = ['autopep8']
" vimtex
let g:tex_flavor = 'latex'
let g:vimtex_quickfix_open_on_warning = 0
let g:vimtex_view_method = 'zathura'
let g:vimtex_view_zathura_options = '&>/dev/null'
" FZF
if executable('fzf')
let g:fzf_colors = {
\ 'fg': ['Normal'],
\ 'bg': ['Normal'],
\ 'hl': ['Comment'],
\ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'],
\ 'bg+': ['bg', 'CursorLine', 'CursorColumn'],
\ 'hl+': ['fg', 'Statement'],
\ 'info': ['fg', 'PreProc'],
\ 'border': ['fg', 'Ignore'],
\ 'prompt': ['fg', 'Conditional'],
\ 'pointer': ['fg', 'Exception'],
\ 'marker': ['fg', 'Keyword'],
\ 'spinner': ['fg', 'Label'],
\ 'header': ['fg', 'Comment'] }
command! CD call fzf#run({
\'source': 'bfs ~ -type d',
\'sink': 'cd'})
fu! ZF(...)
call fzf#run({
\'source': 'locate -Ai ' . join(a:000),
\'sink': 'cd'})
endfu
command! -nargs=+ Z call ZF(<f-args>)
command! Kno call fzf#run({
\'source': 'kno.sh ' .
\expand('%:p') .
\':' .
\line('.') .
\':' .
\substitute(s:LineContext(), ':', ' ', '') .
\':' .
\shellescape(getline('.')),
\'sink': function('<sid>kno')})
fu! s:kno(tags)
let line=getline('.')
if l:line=~#"^#"
call setline('.', line . ', ' . a:tags)
normal! $
return
endif
call append(line('.'), '# ' . a:tags)
normal! j$
endfu
endif
set rtp+=~/opt/fzf
" UltiSnips
" Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe.
set runtimepath+=~/code/snippets
let g:UltiSnipsSnippetsDir = "~/code/snippets/ultisnips"
let g:UltiSnipsSnippetDirectories = ["ultisnips"]
let g:UltiSnipsExpandTrigger="<c-o>"
let g:UltiSnipsJumpForwardTrigger="<c-b>"
let g:UltiSnipsJumpBackwardTrigger="<c-z>"
" If you want :UltiSnipsEdit to split your window.
let g:UltiSnipsEditSplit="vertical"
" Compatibility with other plugins (such as `clang_complete`)
let g:UltiSnipsUsePythonVersion = 2
" Ale
let g:ale_completion_enabled = 1
let g:ale_history_log_output = 1
let g:ale_lint_on_text_changed = 'never'
let g:ale_css_csslint_options = '--ignore=important'
let g:ale_python_pylint_executable = 'run-pylint.sh'
let g:ale_sh_shellcheck_options = '--exclude=SC1090,SC2004,SC2164'
" Syntastic
set statusline=%t
set statusline+=%#warningmsg#
if exists('*ALEGetStatusLine')
set statusline+=%{ALEGetStatusLine()}
endif
if exists('*SyntasticStatuslineFlag')
set statusline+=%{SyntasticStatuslineFlag()}
endif
set statusline+=%*
set statusline+=%=%l,%c\ %P
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 0
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 1
let g:syntastic_enable_perl_checker = 1
let g:syntastic_perl_checkers = ['perl', 'podchecker']
let g:syntastic_css_csslint_args = '--ignore=important'
let g:syntastic_python_pylint_exe = 'run-pylint.sh'
let g:syntastic_sh_shellcheck_exe = 'shellcheck --exclude=SC1090,SC2004,SC2164'
" Clang
let g:clang_auto_select=0
let g:clang_complete_auto=1
let g:clang_complete_copen=1
let g:clang_complete_macros=1
let g:clang_complete_patterns=1
let g:clang_jumpto_declaration_key='g>'
let g:clang_memory_percent=70
let g:clang_use_library=1
let g:clang_user_options='-I/usr/include -std=c++11'
set conceallevel=2
set concealcursor=vin
let g:clang_snippets=1
let g:clang_conceal_snippets=1
let g:clang_snippets_engine='clang_complete'
" Jedi
let g:jedi#auto_close_doc=1
let g:jedi#popup_on_dot=0
" Gundo
nnoremap <F4> :GundoToggle<CR>
let g:gundo_close_on_revert=1
" web-indent
let g:js_indent_log=0
" }}}
" {{{ FUNCTIONS
function! GetBufferList()
redir => l:buflist
silent! ls!
redir END
return l:buflist
endfunction
function! ToggleList(bufname, pfx)
let l:buflist = GetBufferList()
for bufnum in map(filter(split(l:buflist, '\n'), 'v:val =~ "'.a:bufname.'"'), 'str2nr(matchstr(v:val, "\\d\\+"))')
if bufwinnr(bufnum) != -1
exec(a:pfx.'close')
return
endif
endfor
if a:pfx == 'c' && len(getqflist()) == 0
echohl ErrorMsg
echomsg "Quickfix List is Empty."
echohl None
return
endif
if a:pfx == 'l' && len(getloclist(0)) == 0
echohl ErrorMsg
echomsg "Location List is Empty."
echohl None
return
endif
let winnr = winnr()
exec(a:pfx.'open')
if winnr() != winnr
wincmd p
endif
endfunction
nmap <silent> ,l :call ToggleList("Location List", 'l')<CR>
nmap <silent> ,e :call ToggleList("Quickfix List", 'c')<CR>
function! s:DiffSaved()
let filetype=&ft
diffthis
vnew | r # | normal! 1Gdd
diffthis
exe "setlocal bt=nofile bh=wipe nobl noswf ro ft=" . filetype
endfunction
command! DiffSaved call s:DiffSaved()
command! CompareSaved call s:DiffSaved()
function! s:ToJavaString()
silent %s/"/\\"/g
silent %s/^/+ "/g
silent %s/$/"/g
normal! zR
endfunction
command! ToJavaString call s:ToJavaString()
function! s:ToJavaStringFromJsonValues()
silent %s/^[^:]*:[ ]*//g
silent %s/",/"/g
normal! zR
endfunction
command! ToJavaStringFromJsonValues call s:ToJavaStringFromJsonValues()
" https://github.com/frioux/vim-lost
" https://git.savannah.gnu.org/cgit/diffutils.git/tree/src/diff.c?id=eaa2a24#n464
function! s:LineContext()
let re = get(b:, 'line_context_regex', '\v^[[:alpha:]#$_]')
let found = search(re, "bn", 1, 100)
if found > 0
let line = getline(found)
return line
else
return '?'
endif
endfunction
command! LineContext echomsg s:LineContext()
command! Reload bufdo set eventignore-=Syntax | e
command! TagsRegenerate call job_start(['tags-regenerate.sh'])
command! Todo noautocmd vimgrep /TODO\|FIXME/j ** | cw
" }}}
" {{{ MAPPINGS
set pastetoggle=<F2>
noremap L Lzt
noremap H Hzb
nnoremap <Space> <C-f>
nnoremap <C-x>] <Esc>:exe "ptjump " . expand("<cword>")<Esc>
map ,' ciW''<Esc>P
map ," ciW""<Esc>P
map ,( ciW()<Esc>P
" Sign/Gutter column
sign define check_ok text=>o texthl=Search
map ,xo :exe ":sign place " . line(".") . " line=" . line(".") . " name=check_ok file=" . expand("%:p")<CR>:redraw!<CR>
map ,xd :exe ":sign unplace " . line(".")<CR>:redraw!<CR>
" Search selected text in current buffer
nnoremap g/ viwy/\V<C-R>"<CR>
" Search selected text in all buffers
" DEPENDENCIES: fzf
nnoremap ,/ viwy:Lines <C-R>"<CR>
vnoremap ,/ y:Lines <C-R>"<CR>
" Sane pasting
nnoremap "+p :set paste<CR>"+p:set nopaste<CR>
nnoremap "*p :set paste<CR>"*p:set nopaste<CR>
" Sane completion menu
inoremap <expr> <CR> pumvisible() ? "\<C-Y>" : "\<CR>"
autocmd InsertLeave,CompleteDone * pclose
" Conserve split on buffer delete
nnoremap <C-c> :bp\|bd #<CR>
" Ignore diacritics while searching,
" replacing each alphabetic character by its corresponding equivalence class.
" See: https://vi.stackexchange.com/questions/7386/ignoring-diacritics-accents-when-searching/7394#7394
cnoremap <CR> <C-\>e getcmdtype() =~ '[?/]' ? substitute(getcmdline(), '\a', '[[=\0=]]', 'g'): getcmdline()<CR><CR>
" Remove trailing white space
command! RemoveWhite %s/\s\+$//
command! TrimWhite RemoveWhite
" Buffers
"map ,b :ls<CR>:buffer<Space>
map ,o :b#<CR>
map <C-j> :bn<CR>
map <C-k> :bp<CR>
"silent! unmap! <C-i>
"imap <C-i> <C-x><C-o>
map <C-l> <Esc>:pc<CR>:noh<CR>:redraw!<CR>
" Hack to prevent omnicomplete on tab
"function! InsertTabWrapper()
" return "\<tab>"
"endfunction
"inoremap <tab> <c-r>=InsertTabWrapper()<cr>
" }}}
" {{{ BEHAVIOUR
set autochdir
set wildignore+=.hg,.git,.svn
set wildignore+=*.aux,*.out,*.toc
set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg
set wildignore+=*.o,*.lo,*.obj,*.exe,*.dll,*.manifest
set wildignore+=*.spl
set wildignore+=*.luac
set wildignore+=*.pyc
set wildignore+=*.class,*.jar
set wildignore+=*.DS_Store
set wildignore+=*.sw?
set tags=tags;
if isdirectory($HOME . '/tmp')
set backupdir=~/tmp directory=~/tmp
set tags+=~/tmp/tags
endif
set number
set cindent
set wildmenu
set tabstop=4 softtabstop=4 shiftwidth=4 expandtab
set completeopt=menu,preview
set diffopt+=iwhite
set viminfo='200,<50,s10,h
" Search down into subdirectories
set path+=**
" Case insensitive search for lowercase chars
set ignorecase
set smartcase
" Match as you type
set incsearch
" Switch buffers without saving
set hidden
set hlsearch
" }}}
" {{{ APPEARANCE
try
colorscheme yotsubaB
catch /^Vim\%((\a\+)\)\=:E/
colorscheme koehler
endtry
" Fix slowdown on cmd/conemu
set lazyredraw
set ttyfast
set belloff=all
set previewheight=6
set cmdheight=2
set shortmess=a
set showbreak=\\\ breakindent linebreak
syntax on
if has("gui_running")
try
set termguicolors
catch /^Vim\%((\a\+)\)\=:E/
endtry
set guioptions=-m
set guioptions=-s
set guioptions-=T
set guioptions+=c
set lines=40 columns=84
endif
autocmd BufEnter *
\ if &ft ==? 'markdown' |
\ syntax sync fromstart |
\ endif |
\ if line('$') < 1000 |
\ for i in range(1, line('$')) |
\ if strlen(getline(i)) >= 3000 |
\ setlocal syntax=off |
\ if exists('*SyntasticStatuslineFlag') |
\ let b:syntastic_skip_checks = 1 |
\ SyntasticReset |
\ endif |
\ break |
\ endif |
\ endfor |
\ endif
if isdirectory("~/code/snippets/recipes")
autocmd BufNewFile *.html 0r ~/code/snippets/recipes/html
autocmd BufNewFile *.py 0r ~/code/snippets/recipes/py | execute "normal! G"
autocmd BufNewFile *.sh 0r ~/code/snippets/recipes/sh | execute "normal! G"
autocmd BufNewFile *.yml,*.yaml 0r ~/code/snippets/recipes/yaml | execute "normal! G"
autocmd BufNewFile Makefile* 0r ~/code/snippets/recipes/Makefile
autocmd BufNewFile package.json 0r ~/code/snippets/recipes/package.json
endif
autocmd BufRead,BufNewFile *.nfo
\ colorscheme default |
\ setlocal guifont=Terminus |
\ setlocal lines=64 |
\ setlocal nonumber |
\ silent! e ++enc=cp437 |
\ execute "normal! gg"
" Idiotic tab width due to poor decisions in life
autocmd BufRead,BufNewFile *.sh,*.zsh
\ setlocal tabstop=2 softtabstop=2 shiftwidth=2 omnifunc=o |
\ setlocal omnifunc=bashcomplete#Complete
" Open folds
autocmd FileType vim setlocal foldmethod=marker | execute "normal! zR"
autocmd FileType xml,html,xhtml,json,jsp setlocal foldmethod=indent | execute "normal! zR"
" Completion
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
" Git
autocmd FileType gitcommit set colorcolumn=73 textwidth=72
" CMake
autocmd BufRead,BufNewFile *.cmake,CMakeLists.txt,*.cmake.in runtime! indent/cmake.vim
autocmd BufRead,BufNewFile *.cmake,CMakeLists.txt,*.cmake.in setf cmake
autocmd BufRead,BufNewFile *.ctest,*.ctest.in setf cmake
function! HighlightedSynGroup()
let l:s = synID(line('.'), col('.'), 1)
echo synIDattr(l:s, 'name') . ' -> ' . synIDattr(synIDtrans(l:s), 'name')
endfun
command! HighlightedSynGroup call HighlightedSynGroup()
" }}}