forked from din982/dotfiles-11
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
337 lines (278 loc) · 8.32 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
scriptencoding utf-8
set shell=/bin/bash
call plug#begin('~/.vim/plugged')
if !has('nvim')
Plug 'Shougo/vimproc.vim', { 'do': 'make' }
endif
Plug 'Shougo/neosnippet.vim'
Plug 'Shougo/neosnippet-snippets'
Plug 'tpope/vim-fugitive'
Plug 'vim-ruby/vim-ruby', { 'for': ['ruby'] }
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'airblade/vim-gitgutter'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-repeat'
Plug 'dag/vim-fish'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'tpope/vim-endwise'
Plug 'christoomey/vim-tmux-navigator'
Plug 'janko-m/vim-test'
Plug 'benmills/vimux'
Plug 'tpope/vim-unimpaired'
Plug 'tpope/vim-heroku'
Plug 'djoshea/vim-autoread'
Plug 'w0rp/ale'
Plug 'editorconfig/editorconfig-vim'
Plug 'cespare/vim-toml'
Plug 'Valloric/YouCompleteMe', { 'for': ['javascript', 'typescript', 'go'], 'do': './install.py --go-completer --js-completer' }
if has('nvim')
" Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
else
" let g:ale_completion_enabled = 1
" Plug 'Shougo/deoplete.nvim'
" Plug 'roxma/nvim-yarp'
" Plug 'roxma/vim-hug-neovim-rpc'
endif
Plug 'elzr/vim-json', { 'for': ['json'] }
Plug 'jelera/vim-javascript-syntax', { 'for': ['javascript'] }
Plug 'pangloss/vim-javascript', { 'for': ['javascript'] }
" typescript syntax
Plug 'leafgarland/typescript-vim'
if has('nvim')
" Plug 'mhartington/nvim-typescript'
else
" Plug 'Quramy/tsuquyomi'
endif
" Plug 'sheerun/vim-polyglot'
Plug 'mattn/emmet-vim', { 'for': ['html'] }
Plug 'fatih/vim-go', { 'for': ['go'] }
Plug 'ekalinin/Dockerfile.vim', { 'for': ['dockerfile'] }
Plug 'markcornick/vim-bats', { 'for': ['bats'] }
Plug 'digitaltoad/vim-pug', { 'for': ['pug'] }
Plug 'kelan/gyp.vim', { 'for': ['gyp'] }
Plug 'rust-lang/rust.vim', { 'for': ['rust'] }
Plug 'nikvdp/ejs-syntax', { 'for': ['ejs'] }
" markdown stuff
Plug 'reedes/vim-pencil'
Plug 'godlygeek/tabular'
Plug 'plasticboy/vim-markdown'
Plug 'brendonrapp/smyck-vim'
Plug 'ryanoasis/vim-devicons'
call plug#end()
let g:deoplete#enable_at_startup = 1
" let g:typescript_indent_disable = 1
setlocal indentkeys+=0
let g:typescript_opfirst='\%([<>=,?^%|*/&]\|\([-:+]\)\1\@!\|!=\|in\%(stanceof\)\=\>\)'
" load the plugin and indent settings for the detected filetype
filetype plugin indent on
" let mapleader = ','
" disable arrow keys
map <up> <nop>
map <down> <nop>
map <left> <nop>
map <right> <nop>
syntax on
set noshowmode
" Whitespace stuff
set nowrap
set wm=0
set tw=0
set tabstop=2
set shiftwidth=2
set softtabstop=2
set expandtab
set autoindent
set smartindent
set list
set listchars=tab:\ \ ,trail:·
" Searching
set hlsearch
set incsearch
set ignorecase
set smartcase
" Remember last location in file
if has('autocmd')
augroup reload
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
augroup end
endif
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
" Highlight cursor line
set cursorline
" fancy find/replace
set inccommand=nosplit
" Default color scheme
set background=dark
colorscheme smyck
" Directories for swp files
set backupdir=~/.vim/backup
set directory=~/.vim/backup
" vim-airline
set laststatus=2
let g:airline_theme='wombat'
let g:airline_powerline_fonts = 1
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#formatter = 'unique_tail_improved'
let g:airline_section_b = '%{airline#util#wrap(airline#extensions#branch#get_head(),0)}'
let g:airline_section_z = ''
" mouse
set mouse=a
set number
" fzf
let $FZF_DEFAULT_COMMAND = 'ag -g ""'
nnoremap <silent> <C-p> :FZF<cr>
" nnoremap <silent> <leader>g :GFiles?<cr>
let g:fzf_action = {
\ 'ctrl-t': 'tab split',
\ 'ctrl-s': 'split',
\ 'ctrl-v': 'vsplit' }
" ctrlp
" set wildignore+=*/node_modules/*
" set wildignore+=*/vendor/*
" set wildignore+=*/tmp/*
" let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files -co --exclude-standard']
" let g:ctrlp_use_caching=0
" tabs
nnoremap <C-t>p :tabprevious<CR>
nnoremap <C-t>n :tabnext<CR>
" disable shift-k
map <S-k> <Nop>
" UltiSnips
let g:UltiSnipsExpandTrigger='<c-j>'
let g:UltiSnipsJumpForwardTrigger='<c-j>'
let g:UltiSnipsJumpBackwardTrigger='<c-b>'
" ale
" let g:ale_open_list = 1
let g:ale_set_quickfix = 1
" let g:ale_keep_list_window_open = 1
" let g:ale_completion_enabled = 1
let g:ale_lint_on_text_changed = 'never'
nmap <silent> <leader>f :ALEFix<CR>
nmap <silent> <C-a> <Plug>(ale_previous_wrap)
nmap <silent> <C-s> <Plug>(ale_next_wrap)
autocmd BufEnter heroku-*config*.sh ALEDisable
let g:ale_sh_shellcheck_options = '--external-sources'
" deoplete
set completeopt-=preview
inoremap <expr><tab> pumvisible() ? "\<c-n>" : "\<tab>"
" quickfix toggle
function! GetBufferList()
redir =>buflist
silent! ls!
redir END
return buflist
endfunction
" typescript
autocmd FileType typescript :set makeprg=tsc
" vim-test
let g:test#javascript#mocha#file_pattern = '\vtests?/.*\.(js|jsx|coffee|ts)$'
autocmd FileType typescript nmap <leader>ta :TestSuite test/**/*.test.ts<CR>
nmap <leader>r :TestNearest<CR>
nmap <leader>tf :TestFile<CR>
nmap <leader>ta :TestSuite<CR>
nmap <leader>tl :TestLast<CR>
" YouCompleteMe
autocmd FileType typescript nmap <leader>gw :YcmCompleter GoToReferences<CR>
autocmd FileType typescript nmap <leader>gq :YcmCompleter GoToDefinition<CR>
autocmd FileType typescript nmap <leader>ge :YcmCompleter GetDocs<CR>
autocmd FileType typescript nmap <leader>gt :YcmCompleter GetType<CR>
autocmd FileType typescript nmap <leader>gr :YcmCompleter RefactorRename
function! ToggleList(bufname, pfx)
let buflist = GetBufferList()
for bufnum in map(filter(split(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 == 'l' && len(getloclist(0)) == 0
echohl ErrorMsg
echo "Location List is Empty."
return
endif
let winnr = winnr()
exec(a:pfx.'open')
if winnr() != winnr
wincmd p
endif
endfunction
nmap <silent> <leader>l :call ToggleList("Location List", 'l')<CR>
nmap <silent> <leader>e :call ToggleList("Quickfix List", 'c')<CR>
" close quickfix if it is the last window
function! s:NextNormalWindow() abort
for i in range(1, winnr('$'))
let buf = winbufnr(i)
" skip unlisted buffers
if !buflisted(buf)
continue
endif
" skip temporary buffers with buftype set
if getbufvar(buf, '&buftype') != ''
continue
endif
" skip the preview window
if getwinvar(i, '&previewwindow')
continue
endif
" skip current window
if i == winnr()
continue
endif
return i
endfor
return -1
endfunction
function! s:QuitIfOnlyWindow() abort
let l:buftype = getbufvar(winbufnr(winnr()), "&buftype")
if l:buftype != "quickfix" && l:buftype != "help"
return
endif
" Check if there is more than one window
if s:NextNormalWindow() == -1
" Check if there is more than one tab page
if tabpagenr('$') == 1
" Before quitting Vim, delete the special buffer so that
" the '0 mark is correctly set to the previous buffer.
" Also disable autocmd on this command to avoid unnecessary
" autocmd nesting.
if winnr('$') == 1
if has('autocmd')
noautocmd bdelete
endif
endif
quit
else
" Note: workaround for the fact that in new tab the buftype is set
" too late (and sticks during this WinEntry autocmd to the old -
" potentially quickfix/help buftype - that would automatically
" close the new tab and open the buffer in copen window instead
" New tabpage has previous window set to 0
if tabpagewinnr(tabpagenr(), '#') != 0
let l:last_window = 0
if winnr('$') == 1
let l:last_window = 1
endif
close
if l:last_window == 1
" Note: workaround for the same bug, but w.r.t. Airline
" plugin (it needs to refresh buftype and status line after
" last special window autocmd close on a tab page
if exists(':AirlineRefresh')
execute "AirlineRefresh"
endif
endif
endif
endif
endif
endfunction
" autoclose last open location/quickfix/help windows on a tab
if has('autocmd')
aug AutoCloseAllQF
au!
autocmd WinEnter * nested call s:QuitIfOnlyWindow()
aug END
endif