-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.vimrc
425 lines (380 loc) · 12.9 KB
/
.vimrc
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
set nocompatible " be iMproved, required
set exrc " allow project .vimrc
set secure " disallow autocmd, shell and write commands in project .exrc
" Plugins {{{
" automatically install vim-plug
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin('~/.vim/plugged')
Plug 'editorconfig/editorconfig-vim'
Plug 'junegunn/vim-emoji'
Plug 'chriskempson/base16-vim'
Plug 'daviesjamie/vim-base16-lightline'
Plug 'scrooloose/nerdtree'
Plug 'ryanoasis/vim-devicons'
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'low-ghost/nerdtree-fugitive'
Plug 'svenwin/vim-splitted-nerdtree'
" NERDTree {{{
" Open tree in current buffer / split
nmap - :call splittednerdtree#revealFile()<CR>
let NERDTreeShowHidden=1
let NERDTreeRespectWildIgnore=1
" }}}
Plug 'neomake/neomake'
Plug 'benjie/neomake-local-eslint.vim'
Plug 'dense-analysis/ale'
let g:ale_fix_on_save = 1
Plug 'maximbaz/lightline-ale'
Plug 'airblade/vim-gitgutter'
Plug 'tpope/vim-fugitive'
Plug 'itchyny/lightline.vim'
" Lightline {{{
let g:lightline = {
\ 'colorscheme': 'base16',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'gitbranch', 'gitgutter', 'readonly', 'relativepath', 'modified' ] ],
\ 'right': [ [ 'lineinfo' ],
\ [ 'percent' ],
\ [ 'filetype' ],
\ [ 'linter_checking', 'linter_errors', 'linter_warnings', 'linter_infos', 'linter_ok' ]],
\ },
\ 'component_function': {
\ 'gitbranch': 'FugitiveHead'
\ },
\ 'component_expand': {
\ 'gitgutter': 'GitGutterStatus',
\ 'linter_checking': 'lightline#ale#checking',
\ 'linter_infos': 'lightline#ale#infos',
\ 'linter_warnings': 'lightline#ale#warnings',
\ 'linter_errors': 'lightline#ale#errors',
\ 'linter_ok': 'lightline#ale#ok',
\ 'neomake': 'LightlineNeomake'
\ },
\ 'component_type': {
\ 'gitgutter': 'warning',
\ 'linter_checking': 'right',
\ 'linter_infos': 'right',
\ 'linter_warnings': 'warning',
\ 'linter_errors': 'error',
\ 'linter_ok': 'right',
\ 'neomake': 'error'
\ },
\ 'tab': {
\ 'active': [ 'tabnum', 'cwd' ],
\ 'inactive': [ 'tabnum', 'cwd' ]
\ },
\ 'tab_component_function': {
\ 'cwd': 'LightlineTabname'
\ }
\}
function LightlineNeomake()
return '%{neomake#statusline#LoclistStatus()}'
endfunction
function! LightlineTabname(n) abort
return fnamemodify(getcwd(tabpagewinnr(a:n), a:n), ':t')
endfunction
function! GitGutterStatus()
let [a,m,r] = GitGutterGetHunkSummary()
if has('mac')
return printf(emoji#for('hatching_chick') . '%d '. emoji#for('mushroom') . '%d ' . emoji#for('skull') . '%d', a, m, r)
endif
return printf('+%d ~%d -%d', a, m, r)
endfunction
" }}}
Plug 'tomtom/tcomment_vim'
Plug 'tpope/vim-surround'
Plug 'pearofducks/ansible-vim'
Plug 'sheerun/vim-polyglot'
let g:jsx_ext_required = 1
let g:javascript_plugin_jsdoc = 1
Plug 'ap/vim-css-color'
Plug 'lvht/phpcd.vim', { 'for': 'php', 'do': 'composer install' }
Plug 'jiangmiao/auto-pairs'
Plug 'christoomey/vim-tmux-navigator'
Plug 'mileszs/ack.vim'
" Ack {{{
let g:ackhighlight = 1
let g:ack_autofold_results = 1
if executable('ag')
let g:ackprg = 'ag --hidden -p ~/.ignore --vimgrep'
endif
" }}}
Plug '/opt/homebrew/opt/fzf'
Plug 'junegunn/fzf.vim'
" fzf {{{
let g:fzf_layout = { 'down': '~20%' }
nnoremap <c-p> :Files<cr>
nnoremap <Leader>y :Buffers<cr>
nnoremap <Leader>m :GFiles?<cr>
nnoremap <Leader>a :Ag
" }}}
Plug 'fatih/vim-go', { 'for': 'go', 'do': ':GoInstallBinaries' }
let g:go_fmt_command = "goimports"
let g:go_highlight_types = 1
Plug 'tpope/vim-projectionist'
" vim-projectionist {{{
let g:projectionist_heuristics = {
\ "README.md": {
\ "README.md": {"type": "doc"},
\ },
\ ".editorconfig": {
\ ".editorconfig": {"type": "ec"},
\ },
\ "composer.json": {
\ "composer.json": {"type": "pkg"},
\ "src/*.php": {"type": "src"},
\ "spec/*Spec.php": {"type": "spec", "alternate": "src/{}.php"},
\ "tests/*Test.php": {"type": "test", "alternate": "src/{}.php"}
\ },
\ "package.json": {
\ "package.json": {"type": "pkg"},
\ "src/*.js": {"type": "src", "alternate": "tests/{}-test.js"},
\ "tests/*-test.js": {"type": "test", "alternate": "src/{}.js"},
\ "src/*.jsx": {"type": "src", "alternate": "tests/{}-test.jsx"},
\ "tests/*-test.jsx": {"type": "test", "alternate": "src/{}.jsx"},
\ "src/*.test.js": {"type": "test", "alternate": "src/{}.js"},
\ "src/*.test.ts": {"type": "test", "alternate": "src/{}.ts"}
\ },
\ "*.go": {
\ "*.go": {"type": "src", "alternate": "{}_test.go"},
\ "*_test.go": {"type": "test", "alternate": "{}.go"}
\ },
\ "ansible/": {
\ "ansible/playbook.yml": {"type": "playbook"},
\ "ansible/roles/*/defaults/main.yml": {"type": "defaults", "alternate": "ansible/roles/{}/tasks/main.yml"},
\ "ansible/roles/*/tasks/main.yml": {"type": "task", "alternate": "ansible/roles/{}/defaults/main.yml"}
\ }
\ }
" }}}
Plug '[email protected]:c-brenn/fuzzy-projectionist.vim.git'
Plug 'heavenshell/vim-jsdoc'
" vim-jsdoc {{{
let g:jsdoc_allow_input_prompt = 1
let g:jsdoc_enable_es6 = 1
" }}}
Plug 'janko-m/vim-test'
" vim-test {{{
let g:test#runner_commands = ['Behat', 'PHPSpec', 'PHPUnit']
let test#php#phpspec#options = '--no-code-generation'
let test#javascript#reactscripts#options = '--watchAll=false'
let test#strategy = "neoterm"
nnoremap <Leader>tf :TestFile<cr>
nnoremap <Leader>tl :TestLast<cr>
nnoremap <Leader>tn :TestNearest<cr>
nnoremap <Leader>ts :TestSuite<cr>
nnoremap <Leader>tv :TestVisit<cr>
" }}}
Plug 'mtth/scratch.vim'
Plug 'SirVer/ultisnips'
" UltiSnips {{{
let g:snips_author=$AUTHOR
let g:UltiSnipsListSnippets="<c-d>"
autocmd BufRead,BufNewFile,BufEnter *Spec.php UltiSnipsAddFiletypes php-phpspec
" }}}
Plug 'honza/vim-snippets'
Plug 'kylef/apiblueprint.vim'
Plug 'matze/vim-move'
let g:move_key_modifier = 'C'
Plug 'junegunn/vader.vim'
Plug 'Shougo/echodoc.vim'
let g:echodoc_enable_at_startup = 1
Plug 'kassio/neoterm'
" Neoterm {{{
let g:neoterm_size = 16
let g:neoterm_autoscroll = 1
let g:neoterm_default_mod = 'belowright'
" }}}
Plug 'gotchane/vim-git-commit-prefix'
" Neovim specific plugins {{{
if has('nvim')
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
let g:deoplete#enable_at_startup = 1
Plug 'autozimu/LanguageClient-neovim', {
\ 'branch': 'next',
\ 'do': 'bash install.sh',
\ }
let g:LanguageClient_serverCommands = {
\ 'css': ['css-languageserver', '--stdio'],
\ 'Dockerfile': ['docker-langserver', '--stdio'],
\ 'javascript': ['javascript-typescript-stdio'],
\ 'scss': ['css-languageserver', '--stdio'],
\ 'sh': ['bash-language-server', 'start'],
\ 'terraform': ['terraform-ls', 'serve'],
\ 'typescript': ['javascript-typescript-stdio'],
\ }
Plug 'Shougo/neco-vim'
Plug 'deathlyfrantic/deoplete-spell'
Plug 'zchee/deoplete-go', { 'for': 'go', 'do': 'make'}
endif
" }}}
" All of your Plugins must be added before the following line
call plug#end()
" }}}
" General settings {{{
" set the runtime path to custom snippets
set rtp+=$HOME/.vim/snippets/
" {{{ Spell check
set spell spelllang=en_gb spellfile=~/.vim/spell/en.utf-8.add
" Turn off spelling for certain syntaxes or if no syntax
autocmd BufEnter,BufNewFile * if &syntax == "" | setlocal nospell | endif
autocmd FileType apache,conf,dosini,fzf,gitconfig,gitrebase,json,neoterm,nerdtree,yaml setlocal nospell
map <F5> :setlocal spell!<CR>
" Auto-complete with dictionary words when spell check is on
set complete+=kspell
" }}}
" Turn on line numbers
set number
" Add ALE as a Deoplete source
if exists('*deoplete#custom#option')
call deoplete#custom#option('sources', {'_': ['ale']})
endif
" Status bar
set laststatus=2 " always show
" Always draw the sign column
set signcolumn=yes
" Bufferline
let g:bufferline_echo = 0 " don't echo to command bar
" Don't show mode
set noshowmode
" Ensure Vim doesn't beep at you every time you make a mistype
set visualbell
" Show tabs and trailing spaces
set list listchars=tab:\ \ ,trail:~
" Indenting
filetype plugin indent on " Enable language-dependent indenting
set tabstop=4 " The width of a tab
set shiftwidth=4 " Indent size
" Switch syntax highlighting on, when the terminal has colours
syntax on
" Allow backspace to delete end of line, indent and start of line characters
set backspace=indent,eol,start
" Highlight search matches
set hlsearch
" Ignore case in search
set ignorecase
set smartcase
" Show where search pattern typed so far matches
set incsearch
" Folding
set foldmethod=syntax
autocmd FileType ansible,conf,sh,tmux,zsh,vim setlocal foldmethod=marker
set foldlevelstart=7
" Auto read and write
set autoread
set autowrite
" Enable mouse support
set mouse=a
" Use system clipboard
set clipboard+=unnamed
" Redraw only when we need to
set lazyredraw
" Reduce time signs take to appear
set updatetime=600
" No backup files
set nobackup
" No write backup
set nowritebackup
" No swap file
set noswapfile
" Split behaviour
set splitbelow
" Shortcut to reload .vimrc
nnoremap <Leader>r :source ~/.vimrc<CR>
" Splits based on Tmux keys
nnoremap <Leader>" :split<CR>
nnoremap <Leader>% :vsplit<CR>
nnoremap <Leader>w :update<CR>
" Shortcut for quick terminal exit
:silent! tnoremap <Esc> <C-\><C-n>
" Alias Wq to wq for all those times I accidentally type it
command! Wq wq
" Ignore these files and directories
set wildignore+=*/.git,*/.hg,*/.svn,*/.tmp,*/.DS_Store
set wildignore+=*.phar,*.o,*.obj,*.exe,*.dll,*.manifest " compiled and binary files
set wildignore+=*/.idea,*/.project,*/nbproject,*/.tern-port " other IDEs
set wildignore+=*/app/cache,*/.sass-cache " project caches
" }}}
" Theme {{{
set termguicolors
set t_Co=256 " Enable 256 colours
set background=light
try
colorscheme base16-tomorrow
catch
colorscheme default
endtry
" }}}
if $BACKGROUND == 'dark'
set background=dark
colorscheme base16-tomorrow-night-eighties
endif
" Comments in italics
highlight Comment cterm=italic gui=italic
" File extensions {{{
au BufNewFile,BufRead *.ctp setlocal filetype=html.php
au BufNewFile,BufRead *.hbt setlocal filetype=html.handlebars
au BufNewFile,BufRead .babelrc setlocal filetype=json
au BufNewFile,BufRead .bowerrc setlocal filetype=json
au BufNewFile,BufRead .jshintrc setlocal filetype=json
au BufNewFile,BufRead .eslintrc setlocal filetype=json
au BufNewFile,BufRead .prettierrc setlocal filetype=json
au BufNewFile,BufRead .envrc setlocal filetype=conf
au BufNewFile,BufRead composer.lock setlocal filetype=json
au BufNewFile,BufRead .git-authors setlocal filetype=yaml
au BufNewFile,BufRead .env.* setlocal filetype=sh
" }}}
" Templates {{{
autocmd BufNewFile .editorconfig 0r $HOME/.vim/templates/editorconfig
" }}}
" Completion {{{
" Turn off complete option preview
set completeopt-=preview
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
autocmd FileType c setlocal omnifunc=ccomplete#Complete
" }}}
" Emoji {{{
if has('mac')
" Git gutter
let g:gitgutter_sign_added = emoji#for('hatching_chick')
let g:gitgutter_sign_modified = emoji#for('mushroom')
let g:gitgutter_sign_removed = emoji#for('skull')
let g:gitgutter_sign_modified_removed = emoji#for('cloud')
" NERDTree Git
let g:NERDTreeGitStatusIndicatorMapCustom = {
\ "Modified" : emoji#for('mushroom'),
\ "Staged" : emoji#for('outbox_tray'),
\ "Untracked" : emoji#for('alien'),
\ "Renamed" : emoji#for('arrow_forward'),
\ "Unmerged" : emoji#for('stuck_out_tongue'),
\ "Deleted" : emoji#for('skull'),
\ "Dirty" : emoji#for('cloud'),
\ "Clean" : emoji#for('sunny'),
\ "Unknown" : emoji#for('fearful')
\ }
" Neomake
let g:neomake_error_sign = {'text': emoji#for('rage'), 'texthl': 'NeomakeErrorSign'}
let g:neomake_warning_sign = { 'text': emoji#for('worried'), 'texthl': 'NeomakeWarningSign' }
let g:neomake_message = { 'text': emoji#for('weary'), 'texthl': 'NeomakeWarningSign' }
let g:neomake_message_sign = { 'text': emoji#for('arrow_forward'), 'texthl': 'NeomakeMessageSign' }
let g:neomake_info_sign = {'text': emoji#for('stuck_out_tongue'), 'texthl': 'NeomakeInfoSign'}
" ALE
let g:ale_sign_error = emoji#for('scream')
let g:ale_sign_warning = emoji#for('worried')
let g:lightline#ale#indicator_checking = emoji#for('thinking')
let g:lightline#ale#indicator_infos = emoji#for('eyes')
let g:lightline#ale#indicator_warnings = emoji#for('worried')
let g:lightline#ale#indicator_errors = emoji#for('scream')
let g:lightline#ale#indicator_ok = emoji#for('ok_hand')
endif
" }}}
" prevent :autocmd, shell and write commands from inside project-specific .vimrc
set secure