-
Notifications
You must be signed in to change notification settings - Fork 2
/
.vimrc.local
400 lines (334 loc) · 14 KB
/
.vimrc.local
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
" check spelling
nmap <F2> :sign unplace *<CR>:setlocal spell! spelllang=en_us<CR>
nmap <F3> :sign unplace *<CR>:setlocal spell! spelllang=de_de<CR>
nmap <F4> :SpellCheck<CR>:Qtoggle<CR>
" felix
nnoremap ö :update<CR>
nnoremap Ö :SudoWrite<CR>
vnoremap ö <esc>:update<CR>gv
vnoremap Ö <esc>:SudoWrite<CR>gv
nnoremap ä :q<CR>
nnoremap Ä :q!<CR>
vnoremap ä <esc>:q<CR>
vnoremap Ä <esc>:q!<CR>
nnoremap ü :bd<CR>
nnoremap Ü :BufOnly<CR>
vnoremap ü <esc>:bd<CR>
vnoremap Ü <esc>:BufOnly<CR>
" multi cursors
let g:multi_cursor_exit_from_insert_mode=0
let g:multi_cursor_exit_from_visual_mode=0
nnoremap <silent> <M-n> :MultipleCursorsFind <C-R>/<CR>
vnoremap <silent> <M-n> :MultipleCursorsFind <C-R>/<CR>
" undotree
nmap <leader>u :UndotreeToggle<CR>
" autoformat
nmap <leader>f :Autoformat<CR>
" close all buffers except current
nmap <leader>q :BufOnly<CR>
" focus undotree when toggled
let g:undotree_SetFocusWhenToggle = 1
" switch to project root
let g:rooter_manual_only = 1
let g:rooter_disable_map = 1
nmap <silent> <leader>g, :Rooter<CR>
nmap <leader>gn <Plug>GitGutterNextHunk
nmap <leader>gN <Plug>GitGutterPrevHunk
nmap <leader>ga <Plug>GitGutterStageHunk
nmap <leader>gu <Plug>GitGutterStageHunk
nmap <leader>gr <Plug>GitGutterRevertHunk
if has('nvim')
nmap <leader>gs :nohlsearch<CR>:term tig status<CR>i
else
nmap <leader>gs :nohlsearch<CR>:silent !tig status<CR>:GitGutter(All)<CR>:redraw!<CR>
endif
nmap <leader>gp :!git push<CR>
" goldenview window splitting
let g:goldenview__enable_default_mapping = 0
nmap <leader>r :GoldenViewResize<CR>
" camelcase word jumping
map <leader>w <Plug>CamelCaseMotion_w
map <leader>b <Plug>CamelCaseMotion_b
map <leader>e <Plug>CamelCaseMotion_e
" drag visuals
let g:Schlepp#allowSquishingLines = 1
let g:Schlepp#allowSquishingBlocks = 1
let g:Schlepp#reindent = 1
vmap <M-h> <Plug>SchleppLeft
vmap <M-l> <Plug>SchleppRight
vmap <M-j> <Plug>SchleppDown
vmap <M-k> <Plug>SchleppUp
nmap <M-j> <S-v><Plug>SchleppDown
nmap <M-k> <S-v><Plug>SchleppUp
vmap <M-d> <Plug>SchleppDup
nmap <M-d> <S-v><Plug>SchleppDup
" airline statusline
" let g:airline_stl_path_style = 'short'
" let g:airline_section_c_only_filename = 1
let g:airline_section_c = '%<%<%F%m %#__accent_red#%{airline#util#wrap(airline#parts#readonly(),0)}%#__restore__#%#__accent_bold#%{airline#util#wrap(airline#extensions#coc#get_status(),0)}%#__restore__#%#__accent_bold#%#__restore__#'
let g:airline#extensions#tabline#buffer_nr_show = 1
let g:airline#extensions#tabline#enabled = 1
let g:airline_powerline_fonts = 1
" disable backslash keybinding of indexed search
let g:indexed_search_show_index_mappings=0
" syntastic settings
let g:syntastic_check_on_open = 0
let g:syntastic_enable_signs = 1
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_check_on_wq = 0
" syntastic use mri + rubocop for ruby code checking
let g:syntastic_ruby_checkers = ['mri', 'rubocop']
" " styntastic java stuff
" let g:syntastic_java_checkers = ['javac', 'checkstyle']
" let g:syntastic_java_checkstyle_classpath = '/usr/share/java/checkstyle-5.7.jar'
" let g:syntastic_java_checkstyle_conf = '/usr/share/checkstyle/sun_checks.xml'
" syntastic javascript
" let g:syntastic_javascript_checkers=['jshint', 'flow']
" format java code
" let g:formatprg_args_expr_java = '"--mode=java --style=attach -pcH".(&expandtab ? "s".&shiftwidth : "t")'
" formatting with autoformat
let g:formatters_rust = ['rustfmt']
let g:formatdef_rustfmt = '""'
let g:formatters_ruby = ["rbeautify"]
let g:formatdef_rbeautify = '"-"'
let g:formatters_javascript = ['jsbeautify']
let g:formatdef_jsbeautify = '"-"'
let g:formatters_scala = ['scalafmt']
let g:formatdef_scalariform = '"scalafmt --stdin"'
let g:autoformat_autoindent = 1
let g:autoformat_retab = 1
let g:autoformat_remove_trailing_spaces = 1
" omnicomplete ruby
let g:rubycomplete_use_bundler = 1
let g:rubycomplete_load_gemfile = 1
" tex indents
let g:tex_indent_items=0
let g:LatexBox_custom_indent = '/usr/share/vim/vim74/indent/tex.vim'
" latexbox only show quickfix on error (don't autofocus)
let g:LatexBox_quickfix=4
let g:languagetool_jar="/home/cornerman/sw/LanguageTool-3.1/languagetool-commandline.jar"
" gitgutter settings
let g:gitgutter_realtime = 0
let g:gitgutter_eager = 0
let g:gitgutter_map_keys = 0
" easytag, automatic ctags, separate files for filetypes
let g:easytags_cmd = "/usr/bin/ctags"
let g:easytags_auto_update = 1
let g:easytags_dynamic_files = 1
let g:easytags_by_filetype = "~/.vim/vimtags/"
let g:easytags_async = 1
let g:easytags_ignored_filetypes = ''
let g:easytags_updatetime_min = 30000
let g:easytags_languages = {
\ 'zsh': {
\ 'cmd': g:easytags_cmd,
\ 'args': ['--fields=+l', '--c-kinds=+p', '--c++-kinds=+p'],
\ 'fileoutput_opt': '-f',
\ 'stdout_opt': '-f-',
\ 'recurse_flag': '-R'
\ }
\}
" use ag for the grep command
set grepprg=ag\ --nogroup\ --nocolor
" committia word-based diff
let g:committia#git#diff_cmd = "diff --irreversible-delete --find-copies-harder --find-copies --ignore-space-at-eol --ignore-space-change --ignore-all-space -u --cached --no-color --no-ext-diff"
" switch.vim
let g:switch_custom_definitions =
\ [
\ ['on', 'off'],
\ ['==', '!='],
\ ['_', '-'],
\ [' < ', ' > '],
\ ['<=', '>='],
\ [' + ', ' - '],
\ ['-=', '+='],
\ ['and', 'or'],
\ ['if', 'unless'],
\ ['YES', 'NO'],
\ ['yes', 'no'],
\ ['first', 'last'],
\ ['else', 'else if'],
\ ['max', 'min'],
\ ['px', '%', 'em'],
\ ['left', 'right'],
\ ['top', 'bottom'],
\ ['margin', 'padding'],
\ ['height', 'width'],
\ ['absolute', 'relative'],
\ ['horizontal', 'vertical'],
\ ['show', 'hide'],
\ ['visible', 'hidden'],
\ ['add', 'remove'],
\ ['up', 'down'],
\ ['before', 'after'],
\ ['slow', 'fast'],
\ ['small', 'large'],
\ ['even', 'odd'],
\ ['inside', 'outside'],
\ ['with', 'extends'],
\ ['val', 'def'],
\ {'"\([^"]*\)"': '''\1''', '''\([^'']*\)''': '"\1"'},
\ {
\ '\<\(\l\)\(\l\+\(\u\l\+\)\+\)\>': "\\=tolower(substitute(submatch(0), '\\(\\l\\)\\(\\u\\)', '\\1-\\2', 'g'))",
\ '\<\(\l\+\)\(_\l\+\)\+\>': "\\=substitute(submatch(0), '-\\(\\l\\)', '\\u\\1', 'g')",
\ }
\ ]
" default omnifunc
set omnifunc=syntaxcomplete#Complete
" filetype defs
autocmd vimrc Filetype ruby setlocal omnifunc=rubycomplete#Complete
autocmd vimrc Filetype ruby syn match Error "binding.pry"
autocmd vimrc FileType ruby nmap <leader><F9> :!rubocop -a % > /dev/null 2>&1<CR><CR>
autocmd vimrc FileType ruby setlocal tabstop=2
autocmd vimrc FileType ruby setlocal shiftwidth=2
autocmd vimrc FileType python setlocal tabstop=2
autocmd vimrc FileType python setlocal shiftwidth=2
autocmd vimrc FileType javascript setlocal tabstop=2
autocmd vimrc FileType javascript setlocal shiftwidth=2
autocmd vimrc FileType html setlocal tabstop=2
autocmd vimrc FileType html setlocal shiftwidth=2
autocmd vimrc FileType typescriptreact setlocal tabstop=2
autocmd vimrc FileType typescriptreact setlocal shiftwidth=2
autocmd vimrc FileType typescript setlocal tabstop=2
autocmd vimrc FileType typescript setlocal shiftwidth=2
autocmd vimrc FileType terraform setlocal tabstop=2
autocmd vimrc FileType terraform setlocal shiftwidth=2
autocmd vimrc FileType scala setlocal tabstop=2
autocmd vimrc FileType scala setlocal shiftwidth=2
autocmd vimrc FileType sbt.scala setlocal tabstop=2
autocmd vimrc FileType sbt.scala setlocal shiftwidth=2
autocmd vimrc FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd vimrc FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd vimrc FileType javascript setlocal omnifunc=tern#Complete
" autocmd vimrc FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd vimrc FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
autocmd vimrc Filetype tex setlocal omnifunc=LatexBox_Complete
autocmd vimrc FileType tex setlocal spell spelllang=en_us
" advanced rg
" https://github.com/junegunn/fzf.vim#example-advanced-ripgrep-integration
function! RipgrepFzf(query, fullscreen)
let command_fmt = 'rg --column --line-number --no-heading --color=always --smart-case -- %s || true'
let initial_command = printf(command_fmt, shellescape(a:query))
let reload_command = printf(command_fmt, '{q}')
let spec = {'options': ['--phony', '--query', a:query, '--bind', 'change:reload:'.reload_command]}
call fzf#vim#grep(initial_command, 1, fzf#vim#with_preview(spec), a:fullscreen)
endfunction
command! -nargs=* -bang RG call RipgrepFzf(<q-args>, <bang>0)
" fzf:
nmap <silent> <leader>o :Tags<CR>
nmap <silent> <leader>i :BTags<CR>
nmap <silent> <leader>e :ProjectFiles<CR>
" nmap <silent> <leader>e :Rooter<CR>:Files<CR>
nmap <silent> <leader>E :Files<CR>
" nmap <silent> <leader>E :Files<CR>
nmap <silent> <leader>m :GitFiles?<CR>
nmap <silent> <leader>r :History<CR>
nmap <silent> <leader>b :Buffers<CR>
nmap <silent> <Leader>l :Locate<space>
nmap <leader>s :Rooter<CR>:RG<CR>
nmap <leader>S :RG<CR>
nmap <silent> <leader>vd :call fzf#run({'source': 'GIT_DIR=$HOME/projects/dotfiles_bare GIT_WORK_TREE=$HOME git -c status.showUntrackedFiles=no ls-tree --full-tree --name-only -r HEAD', 'sink': 'e', 'dir': '$HOME'})<CR>
let g:fzf_layout = {} " default to full screen
" https://github.com/junegunn/fzf.vim/issues/47#issuecomment-160237795
function! s:find_git_root()
return system('git rev-parse --show-toplevel 2> /dev/null')[:-2]
endfunction
command! ProjectFiles execute 'Files' s:find_git_root()
" youcompleteme: auto show completion menu as-you-type
let g:ycm_use_ultisnips_completer = 0
let g:ycm_confirm_extra_conf = 1
let g:ycm_add_preview_to_completeopt = 0
let g:ycm_auto_trigger = 1
let g:ycm_path_to_python_interpreter= '/usr/bin/python'
" let g:ycm_global_ycm_extra_conf = '~/.ycm_extra_conf.py'
let g:ycm_collect_identifiers_from_tags_files = 1
let g:ycm_min_num_of_chars_for_completion = 2
let g:ycm_min_num_identifier_candidate_chars = 0
let g:ycm_seed_identifiers_with_syntax = 1
let g:ycm_key_list_select_completion = ['<tab>']
let g:ycm_key_list_previous_completion = ['<s-tab>', '<F15>']
let g:ycm_key_invoke_completion = '<C-Space>'
" deoplete
" Use tab for trigger completion with characters ahead and navigate.
" Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin.
" maximize fzf windows
let g:coc_fzf_preview = ''
let g:coc_fzf_opts = []
" Use tab for trigger completion with characters ahead and navigate.
" NOTE: There's always complete item selected by default, you may want to enable
" no select by `"suggest.noselect": true` in your configuration file.
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
" other plugin before putting this into your config.
inoremap <silent><expr> <TAB>
\ coc#pum#visible() ? coc#pum#next(1) : "\<Tab>"
" \ CheckBackspace() ? "\<Tab>" :
" \ coc#refresh()
inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
" Used in the tab autocompletion for coc
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" metals
set shell=/bin/sh
" Smaller updatetime for CursorHold & CursorHoldI
set updatetime=300
" don't give |ins-completion-menu| messages.
set shortmess+=c
" always show signcolumns
set signcolumn=yes
" Some server have issues with backup files, see #649
" set nobackup
" set nowritebackup
" Better display for messages
set cmdheight=2
" popup size
"set pumblend=20
"autocmd vimrc User CocOpenFloat call setwinvar(g:coc_last_float_win, "&winblend", 20)
" autocmd User CocOpenFloat call nvim_win_set_config(g:coc_last_float_win, {'relative': 'editor', 'row': 0, 'col': 0})
" autocmd User CocOpenFloat call setwinvar(g:coc_last_float_win, "&autohide", 1)
" autocmd User CocOpenFloat call nvim_win_set_width(g:coc_last_float_win, 9999)
" Use <c-space> for trigger completion.
inoremap <silent><expr> <c-space> coc#refresh()
" Use <cr> for confirm completion, `<C-g>u` means break undo chain at current position.
" Coc only does snippet and additional edit on confirm.
" inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
" Use `[c` and `]c` for navigate diagnostics
nmap <silent> [c <Plug>(coc-diagnostic-prev)
nmap <silent> ]c <Plug>(coc-diagnostic-next)
" Remap keys for gotos
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
" Remap for do codeAction of current line
nmap <leader>ac <Plug>(coc-codeaction)
" Remap for do action format
nnoremap <silent> <space>F :call CocAction('format')<CR>
" autocmd User CocOpenFloat call nvim_win_set_config(g:coc_last_float_win, {'relative': 'editor', 'row': 0, 'col': 0})
" autocmd User CocOpenFloat call nvim_win_set_width(g:coc_last_float_win, 9999)
" Use K for show documentation in preview window
nnoremap <silent> <space>K :call <SID>show_documentation()<CR>
function! s:show_documentation()
if &filetype == 'vim'
execute 'h '.expand('<cword>')
else
call CocAction('doHover')
endif
endfunction
" Highlight symbol under cursor on CursorHold
autocmd CursorHold * silent call CocActionAsync('highlight')
" Remap for rename current word
nmap <leader>rn <Plug>(coc-rename)
" Show all diagnostics
nnoremap <silent> <space>A :<C-u>CocList diagnostics<cr>
" Find symbol of current document
nnoremap <silent> <space>O :<C-u>CocList outline<cr>
" Search workspace symbols
nnoremap <silent> <space>S :<C-u>CocList -I symbols<cr>
" Do default action for next item.
nnoremap <silent> <space>J :<C-u>CocNext<CR>
" Do default action for previous item.
nnoremap <silent> <space>K :<C-u>CocPrev<CR>
" Resume latest coc list
nnoremap <silent> <space>P :<C-u>CocListResume<CR>