forked from serebrov/vimrc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.vimrc.ide
More file actions
483 lines (428 loc) · 17.3 KB
/
.vimrc.ide
File metadata and controls
483 lines (428 loc) · 17.3 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
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
" Prettier and language-server / language-client setup, linters
" Plugins for specific languages
" similar: https://github.com/xolox/vim-easytags
Plug 'joonty/vim-taggatron'
" Taggatron {{{
augroup MyAutoCmdTags
let g:tagcommands = {
\ "python" : {
\ "tagfile": ".python.tags",
\ "args": "-R",
\ "filesappend": "/**"
\ },
\ "php" : {
\ "tagfile":".php.tags",
\ "args":"-R",
\ "filesappend": "/**"
\ },
\ "javascript" : {
\ "tagfile":".js.tags",
\ "args":"-R --exclude=node_modules --exclude=*.min.js --exclude=*-min.js",
\ "filesappend": "/**"
\ }
\}
let g:taggatron_verbose=0
autocmd MyAutoCmdTags FileType php call taggatron#SetTags(".php.tags")
autocmd MyAutoCmdTags FileType python call taggatron#SetTags(".python.tags")
autocmd MyAutoCmdTags FileType javascript call taggatron#SetTags(".js.tags")
augroup END
" todo: check http://tbaggery.com/2011/08/08/effortless-ctags-with-git.html
" and https://github.com/tpope/vim-fugitive/issues/104
" }}}
function! PreFormatPyJson()
exe "s/\\vDecimal\\('(-?\\d+)'\\)/\\1/g | s/'/\"/g | s/u\"/\"/g | s/None/null/g | s/False/false/g | s/True/true/g | s/\\(\\d\\)L\\([},]\\)/\\1\\2/g"
endfunction
function! FormatPyJson()
call PreFormatPyJson()
exe "'<,'>!python -m json.tool"
endfunction
let g:EditorConfig_exclude_patterns = ['fugitive://.*']
Plug 'editorconfig/editorconfig-vim'
" Run :Prettier to format the file, release/1.x branch has plugins (php,
" python support)
Plug 'prettier/vim-prettier', { 'do': 'yarn install', 'branch': 'release/1.x' }
" Default mapping is <Leader>p, I use that for paste from system clipboard.
nmap <Leader><Leader>p <Plug>(Prettier)
let g:prettier#autoformat = 0
" This can be used to automatically format before save
" autocmd BufWritePre *.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql,*.md,*.vue,*.yaml,*.html Prettier
autocmd BufWritePre *.js,*.jsx,*.ts,*.tsx,*.css,*.less,*.scss,*.vue,*.yaml,*.html Prettier
" The prettier/plugin-python is marked as deprecated, page says
" to use black instead, see https://github.com/prettier/plugin-python
" requires ``
Plug 'ambv/black', { 'do': 'pip3 install --user black' }
autocmd BufWritePre *.py execute ':Black'
" Syntax checker
" Python - pip install flake8 (pyflakes + pep8)
" pip install pep257 - docstring conventions
" pip install mypy-lang - python3 static type checks
" pip install vulture - dead code checks
" pip install frosted - pyflakes re-work
" pip install pylint
" Note: pylint also checks docstrings + gives a lot of other notices, not
" always useful
" The pylint behavior can be modified via pylintrc (place into the project
" root) or with special comments, like:
"
" except Exception as error: # pylint: disable=W0703
"
" here we disable the [broad-except] warning, the warning name is shown in
" the error message
"
" The warning id (W0703) can be shown using pylint itself:
"
" $ pylint --help-msg broad-except
" :broad-except (W0703): *Catching too general exception %s*
" Used when an except catches a too general exception, possibly burying
" unrelated errors. This message belongs to the exceptions checker.
"
" For flake8, to disable the error check use comment # noqa
" to disable the specific error # noqa: F401
"
if has('nvim')
" There was a problem with Neovim not seeing python
let g:python2_host_prog = '/usr/bin/python'
let g:python3_host_prog = '/usr/bin/python3'
" To get the errors, save the file or run :Neomake
" then open the local error list with :lopen to see the
" errors (and it is possible to navigate via ]l [l - this is from unimpaired
Plug 'benekastah/neomake'
let g:neomake_css_enabled_makers = ['csslint']
" Available checkers: flake8 pep257 pep8 pyflakes pylama pylint python vulture py3kwarn
" To run checker manually use :Neomake vulture
" let g:neomake_python_enabled_makers = ['pep257', 'flake8', 'mypy']
let g:neomake_python_enabled_makers = ['flake8', 'mypy']
let g:neomake_open_list = 2
"let g:neomake_python_enabled_makers = ['python', 'flake8', 'frosted', 'pylint', 'pep257']
autocmd! BufWritePost * Neomake
else
" Syntastic
Plug 'scrooloose/syntastic'
" It places errors into local error list which can be viewed with :Errors
" With unimpaired plugin you can move to the next / prev error with ]l / [l
"
" PHP - PHPCS
" set default standard for phpcs: sudo phpcs --config-set default_standard PSR2
" it is also possible to configure options for each checker, see
" syntastic helt - "syntastic-config-makeprg"
let g:syntastic_check_on_open=0
let g:syntastic_css_checkers = ['csslint']
let g:syntastic_javascript_checkers = ['eslint', 'flow', 'jshint']
" Available checkers: flake8 pep257 pep8 pyflakes pylint python
let g:syntastic_python_checkers = ['python', 'flake8']
endif
" Use :CoverageShow to show file coverage for the current buffer.
" Use :CoverageToggle to toggle coverage visibility for the current file.
" For python requires `pip install coverage`
" Add maktaba and coverage to the runtimepath.
" (The latter must be installed before it can be used.)
Plug 'google/vim-maktaba'
Plug 'google/vim-coverage'
if has('nvim')
" set signcolumn=yes
" " Languge server client.
" " Langserver features are:
" " - autocomletion
" " - diagnostics (errors / warnings)
" " - rename
" " - hover / get identifier info
" " - go to definition, implementation
" " - find references
" " - workspace / document symbols query
" " - formatting
" " - quick fix (code action)
" " Alternatives:
" " - https://github.com/w0rp/ale - neomake + lang server client
" " - https://github.com/neoclide/coc.nvim
" " - https://github.com/prabirshrestha/vim-lsp
" " - https://github.com/natebosch/vim-lsc
"
" Note: uses fzf to display lists and deoplete or
" https://github.com/ncm2/ncm2 for completion.
"
" Plug 'autozimu/LanguageClient-neovim', {
" \ 'branch': 'next',
" \ 'do': 'bash install.sh',
" \ }
" " autostart language servers
" let g:LanguageClient_autoStart = 1
" " See ./init-lang-servers.sh for installation commands and repo links
" " for servers.
" let g:LanguageClient_serverCommands = {
" \ 'bash': ['bash-language-server'],
" \ 'dockerfile': ['docker-langserver'],
" \ 'go': ['go-langserver'],
" \ 'rust': ['~/.cargo/bin/rustup', 'run', 'stable', 'rls'],
" \ 'python': ['pyls'],
" \ 'javascript': ['~/.nvm/versions/node/v6.10.3/bin/javascript-typescript-stdio'],
" \ 'typescript': ['~/.nvm/versions/node/v6.10.3/bin/javascript-typescript-stdio'],
" \ 'php': ['php', '~/.vim/vendor/felixfbecker/language-server/bin/php-language-server.php'],
" \ }
" " \ 'javascript.jsx': ['tcp://127.0.0.1:2089'],
" nnoremap <F5> :call LanguageClient_contextMenu()<CR>
" " Or map each action separately
" nnoremap <silent> K :call LanguageClient#textDocument_hover()<CR>
" nnoremap <silent> gd :call LanguageClient#textDocument_definition()<CR>
" nnoremap <silent> gi :call LanguageClient#textDocument_implementation()<CR>
" nnoremap <silent> gr :call LanguageClient#textDocument_references()<CR>
" nnoremap <silent> <F2> :call LanguageClient#textDocument_rename()<CR>
" " requires
" " sudo pip3 install neovim
" let g:deoplete#enable_at_startup = 1
" Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
" " Plug 'zchee/deoplete-jedi'
" Better display for messages
set cmdheight=2
" Smaller updatetime for CursorHold & CursorHoldI
set updatetime=300
" don't give |ins-completion-menu| messages.
set shortmess+=c
" always show signcolumns
set signcolumn=yes
" Tags: LanguageClient, Langserver
" :CocInstall coc-tsserver coc-rls coc-pyls coc-json coc-html coc-css
" coc-vetur (vue.js)
" coc-yaml coc-highlight
" coc-snippets (works with UltiSnips snippets)
" coc-phpls
" :CocConfig to edit config
"" Plug 'neoclide/coc.nvim', {'tag': '*', 'do': { -> coc#util#install()}}
Plug 'neoclide/coc.nvim', {'branch': 'release'}
" Completion: C-n / C-p
" " 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.
" inoremap <silent><expr> <TAB>
" \ pumvisible() ? "\<C-n>" :
" \ <SID>check_back_space() ? "\<TAB>" :
" \ coc#refresh()
" inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
inoremap <silent><expr> <TAB>
\ pumvisible() ? coc#_select_confirm() :
\ coc#expandableOrJumpable() ? "\<C-r>=coc#rpc#request('doKeymap', ['snippets-expand-jump',''])\<CR>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
let g:coc_snippet_next = '<tab>'
" 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)
" shows references list and preview buffer, go over results with j/k
nmap <silent> gr <Plug>(coc-references)
" Use K for show documentation in preview window
nnoremap <silent> 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)
" Remap for format selected region
vmap <leader>if <Plug>(coc-format-selected)
nmap <leader>if <Plug>(coc-format-selected)
augroup mygroup
autocmd!
" Setup formatexpr specified filetype(s).
autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
" Update signature help on jump placeholder
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
augroup end
" " Remap for do codeAction of selected region, ex: `<leader>aap` for current paragraph
" vmap <leader>a <Plug>(coc-codeaction-selected)
" nmap <leader>a <Plug>(coc-codeaction-selected)
" " Remap for do codeAction of current line
nmap <leader>ac <Plug>(coc-codeaction)
" " Fix autofix problem of current line
nmap <leader>qf <Plug>(coc-fix-current)
" actions can be invoked via :call CocAction('action')
" actions are (more in help):
" jumpDefinition, jumpDeclaration,jumpImplementation,
" jumpTypeDefinition, jumpReferences, doHover,
" showSignatureHelp, documentSymbols, rename,
" workspaceSymbols, format, formatSelected,
" codeAction, codeLensAction, fold, pickColor
" doCodeAction, doQuickfix
"
" some just return data, like :echo CocAction('services')
" commands, extensionStats, quickfixes
" Use `:Format` for format current buffer
command! -nargs=0 Format :call CocAction('format')
" Use `:Fold` for fold current buffer
command! -nargs=? Fold :call CocAction('fold', <f-args>)
" Using CocList
" :CocList (tab to complete options)
" :CocList diagnostics or :CocList outline
"
" :CocList -I -A symbols to search for symbol with preview
" (without --normal flag it start in insert mode, not sure how to
" switch between insert and normal)
" move through results with up/down arrows
"
" :CocListResume to reopen last list
"
" Show all diagnostics
" nnoremap <silent> <space>a :<C-u>CocList diagnostics<cr>
" " Manage extensions
" nnoremap <silent> <space>e :<C-u>CocList extensions<cr>
" " Show commands
" nnoremap <silent> <space>c :<C-u>CocList commands<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>
" Preview for substitute
set inccommand=nosplit
else
Plug 'davidhalter/jedi-vim'
" fetching can take a long time causing the timeout
" to manually install it
" git clone --recursive https://github.com/Valloric/YouCompleteMe.git
Plug 'Valloric/YouCompleteMe', { 'do': './install.py' }
endif
" Note: coc.nvim supports UlitSnips snippets from honza/vim-snippets
" Plug 'SirVer/ultisnips'
" " Activate with TAB, better with autocompletion plugin,
" " the UlitSnips adds entries marked [US]
" " select the one you need and press <Tab>,
" " don't go out of insert mode, enter parts of the template
" " and press <Tab> again to move to the next placeholder
" " If you exit the insert mode - just get into insert again and
" " use <Tab> / <Shift-Tab> to move between placeholders.
" "
" " http://0x3f.org/blog/make-youcompleteme-ultisnips-compatible/
" " let g:ycm_key_list_select_completion = ['<C-TAB>', '<Down>']
" " let g:ycm_key_list_previous_completion = ['<C-S-TAB>', '<Up>']
" " let g:SuperTabDefaultCompletionType = '<C-Tab>'
" let g:ycm_autoclose_preview_window_after_completion = 1
" let g:ycm_autoclose_preview_window_after_insertion = 1
" let g:ycm_key_list_select_completion = []
" let g:ycm_key_list_previous_completion = []
" let g:UltiSnipsExpandTrigger="<tab>"
" let g:UltiSnipsJumpForwardTrigger="<tab>"
" let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
" let g:ultisnips_python_style="google"
" let g:UltiSnipsExpandTrigger="<c-tab>"
" let g:UltiSnipsListSnippets="<c-s-tab>"
" let g:UltiSnipsJumpForwardTrigger="<c-tab>"
" let g:UltiSnipsJumpBackwardTrigger="<c-s-tab>"
" repository of snippets
Plug 'honza/vim-snippets'
"""""" Markdown
Plug 'plasticboy/vim-markdown'
" Plug 'tpope/vim-markdown'
" Markup files preview: <Leader>P
" Plug 'greyblake/vim-preview'
" nnoremap <Leader>pm :Preview<CR>
" let g:PreviewBrowsers='google-chrome'
" Plug 'suan/vim-instant-markdown'
"""""" PHP
" php completion - it should be copied to autoload/phpcomplete.vim
" Plug 'shawncplus/phpcomplete.vim'
" php 5.3 syntax
" Plug 'StanAngeloff/php.vim'
" Plug '2072/PHP-Indenting-for-VIm'
"""""" Javascript
Plug 'pangloss/vim-javascript'
let g:javascript_conceal = 0
Plug 'othree/javascript-libraries-syntax.vim'
let g:used_javascript_libs = 'jquery,underscore,angularjs'
" ejs templates syntax highlight
Plug 'briancollins/vim-jst'
" Typescript syntax
Plug 'leafgarland/typescript-vim'
" For some reason, typescript files are recognized as XML
autocmd BufNewFile,BufRead *.ts setlocal filetype=typescript
" Typescript completion, etc - disable, there is coc.nvim
" Requires "npm install -g typescript"
" Plug 'Quramy/tsuquyomi'
" solidity syntax
Plug 'tomlion/vim-solidity'
"""""" JSON
" better json highlighting
Plug 'elzr/vim-json'
"""""" Python
" Improved syntax highlight
Plug 'hdima/python-syntax'
" Add the virtualenv's site-packages to vim path
if has("python")
python << EOF
import os.path
import sys
import vim
if 'VIRTUAL_ENV' in os.environ:
project_base_dir = os.environ['VIRTUAL_ENV']
sys.path.insert(0, project_base_dir)
activate_this = os.path.join(project_base_dir, 'bin/activate_this.py')
execfile(activate_this, dict(__file__=activate_this))
EOF
endif
" Install: cd ~/.vim/bundle/ropevim
" python setup.py install
" See: https://github.com/python-rope/ropevim
" Plug 'python-rope/ropevim'
" let ropevim_vim_completion=1
" let ropevim_extended_complete=1
"Plug 'klen/python-mode'
" Correct python code indenting
Plug 'hynek/vim-python-pep8-indent'
" :Ped sqlalchemy.orm -> open the module from current virtual env
Plug 'sloria/vim-ped'
" " Generate docstrings with :Pydocstring
" " note: UltiSnips is also able to generate docstring templates, but
" " I didn't find the way to trigger it for already existing code
" let g:template_vim_template_dir = $HOME . "/.vim/templates/pydocstring"
" Plug 'heavenshell/vim-pydocstring'
" nmap <silent> <nop> <Plug>(pydocstring)
" augroup DocMap
" autocmd!
" autocmd FileType python nnoremap <Leader>pd :Pydocstring<CR>
" augroup END
"
let g:doge_doc_standard_python = 'google'
let g:doge_mapping = '<Leader>pd'
" Generate docstrings for different languages
" Tab / Shift-Tab to move between placeholders.
" :DogeGenerate to generate manually or use <Leader>pd.
Plug 'kkoomen/vim-doge'
"""""" Documentation
" php documenter
" Plug 'mikehaertl/pdv-standalone'
" phpDocumenter
" let g:pdv_cfg_Package = "app"
" let g:pdv_cfg_Version = ""
" let g:pdv_cfg_Author = "Boris Serebrov"
" let g:pdv_cfg_Copyright = ""
" let g:pdv_cfg_License = ""
Plug 'heavenshell/vim-jsdoc'
"JSDoc
let g:jsdoc_default_mapping = 0
augroup DocMap
autocmd!
" autocmd FileType php inoremap <Leader>pd <ESC>:call PhpDocSingle()<CR>i
" autocmd FileType php nnoremap <Leader>pd :call PhpDocSingle()<CR>
" autocmd FileType php vnoremap <Leader>pd :call PhpDocRange()<CR>
autocmd FileType javascript nnoremap <Leader>pd :JsDoc<CR>
augroup END