forked from wklken/k-vim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc.config.local
426 lines (361 loc) · 14.7 KB
/
vimrc.config.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
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
" ----------------------------------------------------------------------
" plugin customized setting
"-----------------------------------------------------------------------
if count(g:bundle_groups, 'python')
" let g:mule_python_command = 'python3'
let g:mule_auto_env = 1
let g:mule_no_hotkeys = 1
endif
if count(g:bundle_groups, 'typescript')
" let g:typescript_indent_disable = 1
let g:typescript_compiler_binary = 'tsc'
let g:typescript_compiler_options = ''
let g:tsuquyomi_disable_quickfix = 1
let g:syntastic_typescript_checkers = ['tsuquyomi']
autocmd FileType typescript nnoremap <leader><leader>td :TsuDefinition<CR>
autocmd FileType typescript nnoremap <leader><leader>tr :TsuTsuReferences<CR>
autocmd QuickFixCmdPost [^l]* nested cwindow
autocmd QuickFixCmdPost l* nested lwindow
" tagbar ctags
let g:tagbar_type_typescript = {
\ 'ctagstype': 'typescript',
\ 'kinds': [
\ 'c:classes',
\ 'n:modules',
\ 'f:functions',
\ 'v:variables',
\ 'v:varlambdas',
\ 'm:members',
\ 'i:interfaces',
\ 'e:enums',
\ ]
\ }
" let g:tagbar_type_typescript = {
" \ 'ctagsbin' : 'tstags',
" \ 'ctagsargs' : '-f-',
" \ 'kinds': [
" \ 'e:enums:0:1',
" \ 'f:function:0:1',
" \ 't:typealias:0:1',
" \ 'M:Module:0:1',
" \ 'I:import:0:1',
" \ 'i:interface:0:1',
" \ 'C:class:0:1',
" \ 'm:method:0:1',
" \ 'p:property:0:1',
" \ 'v:variable:0:1',
" \ 'c:const:0:1',
" \ ],
" \ 'sort' : 0
" \ }
endif
if count(g:bundle_groups, 'javascript')
" set foldmethod=syntax
let g:tern_map_keys=1
let g:tern_show_signature_in_pum = 1
let g:tern_show_argument_hints = 'on_hold'
autocmd FileType javascript nnoremap <leader>tt :TernDef<CR>
autocmd FileType javascript nnoremap <leader>tr :TernRefs<CR>
autocmd FileType javascript nnoremap <leader>tR :TernRename<CR>
" autocmd FileType javascript setlocal omnifunc=tern#Complete
" conflict with gruvbox theme
" autocmd FileType javascript JsPreTmpl html
" autocmd FileType typescript JsPreTmpl html
" autocmd FileType typescript syn clear foldBraces
let g:used_javascript_libs = 'jquery,underscore,backbone,angularjs,angularui,angularuirouter,react,requirejs,vue,d3'
" let NERDTreeIgnore = ['\.js$' , '\.js.map$', '^node_modules$[[dir]]']
" let g:NERDTreeIgnore=['\~$', 'node_modules', 'bower_components']
" let g:ctrlp_custom_ignore = 'node_modules\|DS_Store\|bower_components'
" let g:ctrlp_custom_ignore = {
" \ 'dir': 'node_modules\|DS_Store\|bower_components',
" \ }
let g:syntastic_javascript_checkers = ['eslint']
endif
if count(g:bundle_groups, 'angularjs')
let g:angular_find_ignore = ['build/', 'dist/']
endif
if count(g:bundle_groups, 'angular')
endif
if count(g:bundle_groups, 'vue')
autocmd BufRead,BufNewFile *.vue setlocal filetype=vue.html.javascript.css
endif
if count(g:bundle_groups, 'golang')
" ============================================================================
" Vim-go {{{
" ============================================================================
" " let g:go_metalinter_command = "golangci-lint"
" let g:go_metalinter_enabled = ['vet', 'errcheck']
" let g:go_metalinter_disabled = ['golint']
" let g:syntastic_go_checkers = ['govet']
let g:go_fmt_fail_silently = 0
let g:go_fmt_command = "goimports"
let g:go_autodetect_gopath = 1
let g:go_term_enabled = 0
let g:go_term_mode = "split"
let g:go_auto_type_info = 1
let g:go_highlight_space_tab_error = 0
let g:go_highlight_array_whitespace_error = 0
let g:go_highlight_trailing_whitespace_error = 0
let g:go_highlight_extra_types = 0
let g:go_highlight_operators = 0
let g:go_highlight_build_constraints = 1
nmap <C-g> :GoDecls<cr>
imap <C-g> <esc>:<C-u>GoDecls<cr>
au FileType go nmap <Leader>ds <Plug>(go-def-split)
au FileType go nmap <Leader>dv <Plug>(go-def-vertical)
au FileType go nmap <Leader>dt <Plug>(go-def-tab)
au FileType go nmap <Leader>i <Plug>(go-info)
au FileType go nmap <Leader>l <Plug>(go-metalinter)
au FileType go nmap <Leader>e <Plug>(go-rename)
au FileType go nmap <leader>r <Plug>(go-run)
au FileType go nmap <leader>b <Plug>(go-build)
au FileType go nmap <leader>t <Plug>(go-test)
au FileType go nmap <Leader>d <Plug>(go-doc)
au FileType go nmap <Leader>c <Plug>(go-coverage)
au FileType go nmap <Leader>gds <Plug>(go-doc)
au FileType go nmap <Leader>gdv <Plug>(go-doc-vertical)
au FileType go nmap <Leader>gdb <Plug>(go-doc-browser)
" I like these more!
augroup go
autocmd!
autocmd Filetype go command! -bang A call go#alternate#Switch(<bang>0, 'edit')
autocmd Filetype go command! -bang AV call go#alternate#Switch(<bang>0, 'vsplit')
autocmd Filetype go command! -bang AS call go#alternate#Switch(<bang>0, 'split')
augroup END
" }}}
endif
if count(g:bundle_groups, 'csharp')
let g:OmniSharp_selector_ui = 'fzf'
" let g:OmniSharp_server_type = 'v1'
" let g:OmniSharp_server_type = 'roslyn'
" let g:OmniSharp_prefer_global_sln = 1
let g:OmniSharp_timeout = 10
" let g:ycm_auto_start_csharp_server = 1
" let g:ycm_auto_stop_csharp_server = 1
let g:syntastic_cs_checkers = ['syntax', 'semantic', 'issues']
endif
if count(g:bundle_groups, 'nodejs')
autocmd User Node
\ if &filetype == "javascript" |
\ nmap <buffer> <C-w>f <Plug>NodeVSplitGotoFile |
\ nmap <buffer> <C-w><C-f> <Plug>NodeVSplitGotoFile |
\ endif
endif
if count(g:bundle_groups, 'java')
" vim-javacomplete2 {{{
autocmd FileType java setlocal omnifunc=javacomplete#Complete
" }}}
endif
" argwrap {{{
nnoremap <silent> <leader>wa :ArgWrap<CR>
let g:argwrap_padded_braces = '[{'
let g:argwrap_wrap_closing_brace = 0
" }}}
" indentLine {{{
let g:indentLine_color_term = 239
" }}}
" EditorConfig {{{
" to avoid issues with fugitive
let g:EditorConfig_exclude_patterns = ['fugitive://.*']
" }}}
" ============================================================================
" YouCompleteMe {{{
" ============================================================================
" let g:ycm_path_to_python_interpreter = '/usr/local/bin/python'
" let g:ycm_server_python_interpreter = '/usr/local/var/pyenv/versions/py3/bin/python'
" let g:ycm_path_to_python_interpreter = '/usr/local/var/pyenv/versions/3.5.0/bin/python'
" let g:ycm_python_binary_path = '/usr/local/var/pyenv/versions/3.5.0/envs/py3/bin/python'
let g:py_virtual_pyenv = $PYENV_VIRTUAL_ENV
if len(py_virtual_pyenv)>0
let g:py_virtual_pyenv .= '/bin/python'
let g:ycm_python_binary_path = py_virtual_pyenv
else
let py_shell_version = $PYENV_VERSION + 0
if py_shell_version >= 3
let g:ycm_python_binary_path = '/usr/local/var/pyenv/shims/python'
else
" let g:ycm_python_binary_path = $MY_PY_G2
let g:ycm_python_binary_path ='/usr/local/var/pyenv/shims/python'
endif
endif
" let g:ycm_global_ycm_extra_conf = '~/.config/ycm/.ycm_extra_conf.py'
" let g:ycm_global_ycm_extra_conf = '~/.config/ycm/.ycm_extra_conf.py'
nnoremap <leader>gt :YcmCompleter GetType<cr>
nnoremap <leader>go :YcmCompleter GoTo<cr>
nnoremap <leader>gf :YcmCompleter GoToDefinition<cr>
nnoremap <leader>gr :YcmCompleter GoToReferences<cr>
" }}}
" ============================================================================
" Vim QuickRun {{{
" ============================================================================
let g:quickrun_config = {
\ "_" : {
\ "outputter" : "message",
\ },
\ "typescript": {
\ "command": 'tsc',
\ "exec": ['%c --target es5 --module commonjs --experimentalDecorators %o %s', 'node %s:r.js'],
\ "tempfile": '%{tempname()}.ts',
\ "hook/sweep/files": ['%S:p:r.js'],
\ }
\}
" }}}
" trailingwhitespace {{{
map <leader><leader><space> :FixWhitespace<cr>
" }}}
" ============================================================================
" CtrlP {{{
" ============================================================================
let g:ctrlp_user_command = 'ag %s -l --nocolor --hidden -g ""'
" }}}
" ============================================================================
" VIMDevIcons {{{
" ============================================================================
let g:WebDevIconsNerdTreeAfterGlyphPadding=' '
" let g:WebDevIconsUnicodeDecorateFolderNodes = 1
" let g:DevIconsEnableFoldersOpenClose = 1
" let g:NERDTreeDisableFileExtensionHighlight = 1
" let g:WebDevIconsOS = 'Darwin'
" }}}
" ============================================================================
" Vim Autoformat {{{
" ============================================================================
noremap <leader><leader>f :Autoformat<CR>
noremap! <leader><leader>f <esc> :Autoformat<CR>
let g:formatters_javascript = ['prettier']
" noremap <c-f> :Autoformat<CR>
" autocmd FileType python let b:autoformat_autoindent=0
" }}}
" ============================================================================
" Web Developement {{{
" ============================================================================
" Emmet
" type ctrl -y -, will expand
let g:user_emmet_leader_key='<c-e>'
" autocmd FileType html,htmldjango,jinja,css,scss EmmetInstall
let g:syntastic_html_checkers=['']
" let g:syntastic_html_tidy_ignore_errors=[" proprietary attribute " ,"trimming empty <", "unescaped &" , "lacks \"action", "is not recognized!", "discarding unexpected"]
if has_key(g:plugs, 'ale')
let g:ale_linters = {
\ 'html': [],
\ 'javascript': ['eslint'],
\}
let g:ale_fixers = {
\ 'javascript': ['prettier', 'eslint'],
\ 'css': ['prettier'],
\}
let g:ale_fix_on_save = 1
noremap <leader>j <Plug>(ale_fix)
endif
" Prettier
if has_key(g:plugs, 'vim-prettier')
" nmap <Leader>py <Plug>(Prettier)
au filetype javascript,javascript.jsx,typescript,less,scss,css,json,graphql noremap <leader><leader>f :Prettier<CR>
au filetype javascript,javascript.jsx,typescript,less,scss,css,json,graphql noremap <leader><leader>f <esc> :Prettier<CR>
endif
" jsx file
augroup FiletypeGroup
autocmd!
au BufNewFile,BufRead *.jsx set filetype=javascript.jsx
augroup END
" autocmd BufEnter *.html colorscheme PaperColor
autocmd Filetype html if getfsize(@%) > 10240 | setlocal syntax=OFF | endif
let delimitMate_expand_cr = 1
let delimitMate_expand_space = 1
" au FileType javascript,html,python let b:delimitMate_matchpairs = "(:),[:],{:},<:>"
let g:used_javascript_libs = 'jquery,underscore,angularjs,angularui,react,flux'
let javascript_enable_domhtmlcss = 1
" YCM的自动补全触发器只考虑当前行。 较好的补救办法是手动设置一下触发器
let g:ycm_semantic_triggers = {
\ 'css': [ 're!^\s{4}', 're!:\s+'],
\ 'html': ['<', '"', '</', ' '],
\ 'cs,java,typescript,d,python,perl6,scala,vb,elixir,go' : ['.', 're!(?=[a-zA-Z]{3,4})'],
\ 'php' : ['->', '::', '(', 'use ', 'namespace ', '\'],
\ 'ruby' : ['.', '::'],
\ 'lua' : ['.', ':'],
\ 'erlang' : [':'],
\ 'perl' : ['->'],
\ 'haskell' : ['.', 're!.'],
\ 'scss,css': [ 're!^\s{2,4}', 're!:\s+' ],
\ 'vim' : ['re![_a-za-z]+[_\w]*\.'],
\ }
" let g:ycm_completion_confirm_key = '<enter>'
" k-vim add this config
" let g:ku_key_list_stop_completion = ['<CR>']
nnoremap <F12>f :exe ':silent !open -a /Applications/Firefox.app %'<CR>
nnoremap <F12>c :exe ':silent !open -a /Applications/Google\ Chrome.app %'<CR>
nnoremap <F12>g :exe ':silent !open -a /Applications/Google\ Chrome.app %'<CR>
nnoremap <F12>s :exe ':silent !open /Applications/Safari.app %'<CR>
" inoremap yy <C-y>,
" Markdown
function! s:setupMarkdown()
nnoremap <leader>m :silent !open -a Typora.app '%:p'<cr>
endfunction
au BufRead,BufNewFile *.{md,markdown,mdown,mkdn} call s:setupMarkdown()
" }}}
" ============================================================================
" FZF {{{
" ============================================================================
if has('nvim')
let $FZF_DEFAULT_OPTS .= ' --inline-info'
" let $NVIM_TUI_ENABLE_TRUE_COLOR = 1
endif
" File preview using CodeRay (http://coderay.rubychan.de/)
let g:fzf_files_options =
\ '--preview "(coderay {} || cat {}) 2> /dev/null | head -'.&lines.'"'
" nnoremap <silent> <Leader><Leader> :Files<CR>
nnoremap <silent> <expr> <Leader><Space> (expand('%') =~ 'NERD_tree' ? "\<c-w>\<c-w>" : '').":Files\<cr>"
nnoremap <silent> <Leader>C :Colors<CR>
nnoremap <silent> <Leader><Enter> :Buffers<CR>
nnoremap <silent> <leader>B :Buffers<CR>
nnoremap <silent> <leader>W :Windows<CR>
nnoremap <silent> <leader>L :BLines<CR>
nnoremap <silent> <leader>t :BTags<CR>
nnoremap <silent> <leader>T :Tags<CR>
nnoremap <silent> <leader>H :History<CR>
nnoremap <silent> <Leader>M :Marks<CR>
nnoremap <silent> <leader>gl :Commits<CR>
nnoremap <silent> <leader>ga :BCommits<CR>
nnoremap <silent> <leader>ft :Filetypes<CR>
" nnoremap <silent> <leader>/ :execute 'Ag ' . input('Ag/')<CR>
" nnoremap <silent> <leader>. :AgIn
nnoremap <silent> <Leader>ag :Ag <C-R><C-W><CR>
nnoremap <silent> <Leader>AG :Ag <C-R><C-A><CR>
" nnoremap <silent> q: :History:<CR>
" nnoremap <silent> q/ :History/<CR>
inoremap <expr> <c-x><c-t> fzf#complete('tmuxwords.rb --all-but-current --scroll 500 --min 5')
imap <c-x><c-k> <plug>(fzf-complete-word)
imap <c-x><c-f> <plug>(fzf-complete-path)
imap <c-x><c-j> <plug>(fzf-complete-file-ag)
imap <c-x><c-l> <plug>(fzf-complete-line)
nmap <leader><tab> <plug>(fzf-maps-n)
xmap <leader><tab> <plug>(fzf-maps-x)
omap <leader><tab> <plug>(fzf-maps-o)
command! Plugs call fzf#run({
\ 'source': map(sort(keys(g:plugs)), 'g:plug_home."/".v:val'),
\ 'options': '--delimiter / --nth -1',
\ 'down': '~40%',
\ 'sink': 'Explore'})
" }}}
" ============================================================================
" ESLint Switch {{{
" ============================================================================
" auto-formatter
function! ESlintFormatter()
let l:npm_bin = ''
let l:eslint = 'eslint'
if executable('npm')
let l:npm_bin = split(system('npm bin'), '\n')[0]
endif
if strlen(l:npm_bin) && executable(l:npm_bin . '/eslint')
let l:eslint = l:npm_bin . '/eslint'
endif
let g:formatdef_eslint = '"SRC=eslint-temp-${RANDOM}.js; cat - >$SRC; ' . l:eslint . ' --fix $SRC >/dev/null 2>&1; cat $SRC | perl -pe \"chomp if eof\"; rm -f $SRC"'
endfunction
" use: autocmd FileType javascript :call ESlintFormatter()
" }}}
function! InitNodeEnv()
silent !clear
execute "! nvm use default"
endfunction
" call InitNodeEnv()