-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvim.rc
More file actions
executable file
·401 lines (336 loc) · 10.2 KB
/
vim.rc
File metadata and controls
executable file
·401 lines (336 loc) · 10.2 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
set nocompatible
filetype off " Need to turn off filetype during vundle step.
" Vundle
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Bundle 'gmarik/vundle'
Bundle 'ctrlpvim/ctrlp.vim'
Bundle 'tpope/vim-fugitive'
Bundle 'bling/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Bundle 'vim-scripts/taglist.vim'
Bundle 'airblade/vim-gitgutter'
Bundle 'tpope/vim-obsession'
Bundle 'chrisbra/vim-diff-enhanced'
Bundle 'vim-scripts/DirDiff.vim'
Bundle 'rking/ag.vim'
Bundle 'Shougo/vimproc.vim'
Bundle 'jiangmiao/auto-pairs'
Bundle 'sjl/gundo.vim'
Bundle 'tpope/tpope-vim-abolish'
Bundle 'djoshea/vim-autoread'
Bundle 'prabirshrestha/async.vim'
Bundle 'prabirshrestha/vim-lsp'
Bundle 'sirtaj/vim-openscad'
Bundle 'neomake/neomake'
Bundle 'autozimu/LanguageClient-neovim'
Bundle 'junegunn/fzf'
Bundle 'junegunn/fzf.vim'
if has('nvim')
Bundle 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
else
Bundle 'Shougo/deoplete.nvim'
Bundle 'roxma/nvim-yarp'
Bundle 'roxma/vim-hug-neovim-rpc'
endif
" Language support
Bundle 'lukerandall/haskellmode-vim'
Bundle 'eagletmt/ghcmod-vim'
Bundle 'eagletmt/neco-ghc'
Bundle 'vim-ruby/vim-ruby'
Bundle 'tpope/vim-rails'
Bundle 'scala/scala-dist', {'rtp': 'tool-support/src/vim'}
Bundle 'vim-scripts/VimClojure'
Bundle 'tmhedberg/matchit'
Bundle 'groenewege/vim-less'
Bundle 'lepture/vim-velocity'
Bundle 'hdima/python-syntax'
Bundle 'tfnico/vim-gradle'
Bundle 'burnettk/vim-angular'
Bundle 'pangloss/vim-javascript'
Bundle 'othree/javascript-libraries-syntax.vim'
Bundle 'matthewsimo/angular-vim-snippets'
Bundle 'uarun/vim-protobuf'
Bundle 'google/vim-ft-bzl'
Bundle 'rust-lang/rust.vim'
Bundle 'idris-hackers/idris-vim'
Bundle 'leafgarland/typescript-vim'
set t_Co=256
colorscheme bubblegum
"let g:rehash256 = 1
set background=dark
" hide the gui menubar
if has('gui_running')
set guioptions=egmr
if has("mac")
set guifont=Menlo\ for\ Powerline:h11
else
set guifont=Menlo\ for\ Powerline\ 10
endif
endif
set tabstop=2 softtabstop=2 shiftwidth=2 expandtab
set autoindent smartindent cindent
au BufRead,BufNewFile Makefile* setlocal noexpandtab
au BufRead,BufNewFile *.java setlocal tabstop=2 softtabstop=2 shiftwidth=2 textwidth=100
au BufRead,BufNewFile *.vm setlocal tabstop=2 softtabstop=2 shiftwidth=2 textwidth=200
au BufRead,BufNewFile *.rb setlocal textwidth=100
au BufRead,BufNewFile *.js setlocal textwidth=80
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
autocmd FileType c setlocal omnifunc=ccomplete#Complete
" Set vimdiff to wrap
autocmd FilterWritePre * if &diff | setlocal wrap< | endif
syntax on
filetype plugin indent on
" Fix OSX backspacing
set backspace=indent,eol,start
set spelllang=en_us
set spell
nmap <silent> <leader>s :set spell!<CR>
" nice searching
set ignorecase
set smartcase
set ruler nu
set showcmd
set hlsearch
set incsearch
set noerrorbells
" Word wrap w/o line breaks
set wrap
set linebreak
set list
set nostartofline
" Nicer autocomplete commands
set wildmode=longest:full
set wildmenu
" Screw backups
set nobackup nowritebackup noswapfile
set colorcolumn=+1
set clipboard=unnamed
set complete-=i
set fileformats=unix,dos,mac
scriptencoding utf-8
set encoding=utf-8
set history=10000
" Disable ex mode
nnoremap Q <nop>
" Use and toggle mouse
set mouse=a
function! ToggleMouse()
if &mouse == 'a'
set mouse=
set nonumber
echo "Mouse usage disabled"
else
set mouse=a
set number
echo "Mouse usage enabled"
endif
endfunction
nmap <silent> <leader>c :call ToggleMouse()<CR>
" Auto local cd to the file's directory
autocmd BufEnter * silent! lcd %:p:h
" Make tabs super visible
execute "set listchars=tab:" . nr2char(187) . '\ ,trail:' . nr2char(8226)
" folds!
set foldenable
set foldmethod=indent
set foldnestmax=2
set foldlevel=1
set foldlevelstart=1
set foldminlines=10
set fillchars=vert:\|,fold:\
map <Leader>f zR
" Toggle folds with space
fu! ToggleFold()
if foldlevel('.') == 0
normal! l
else
if foldclosed('.') < 0
. foldclose
else
. foldopen
endif
endif
echo
endf
noremap <space> :call ToggleFold()<CR>
" Re-highlight after Indent/unindent
vmap < <gv
vmap > >gv
" Show location list
function! GetBufferList()
redir =>buflist
silent! ls
redir END
return buflist
endfunction
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>
command! -complete=shellcmd -nargs=+ Shell call s:RunShellCommand(<q-args>)
function! s:RunShellCommand(cmdline)
" echo a:cmdline
let expanded_cmdline = a:cmdline
for part in split(a:cmdline, ' ')
if part[0] =~ '\v[%#<]'
let expanded_part = fnameescape(expand(part))
let expanded_cmdline = substitute(expanded_cmdline, part, expanded_part, '')
endif
endfor
botright new
setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile nowrap
"call setline(1, 'You entered: ' . a:cmdline)
"call setline(2, 'Expanded Form: ' .expanded_cmdline)
"call setline(3,substitute(getline(2),'.','=','g'))
execute '$read !'. expanded_cmdline
setlocal nomodifiable
1
endfunction
" Wrap location jumps
function! WrapCommand(direction, prefix)
if a:direction == "up"
try
execute a:prefix . "previous"
catch /^Vim\%((\a\+)\)\=:E553/
execute a:prefix . "last"
catch /^Vim\%((\a\+)\)\=:E\%(776\|42\):/
endtry
elseif a:direction == "down"
try
execute a:prefix . "next"
catch /^Vim\%((\a\+)\)\=:E553/
execute a:prefix . "first"
catch /^Vim\%((\a\+)\)\=:E\%(776\|42\):/
endtry
endif
endfunction
" <Home> and <End> go up and down the quickfix list and wrap around
nnoremap <silent> [c :call WrapCommand('up', 'c')<CR>
nnoremap <silent> ]c :call WrapCommand('down', 'c')<CR>
" " <C-Home> and <C-End> go up and down the location list and wrap around
nnoremap <silent> [l :call WrapCommand('up', 'l')<CR>
nnoremap <silent> ]l :call WrapCommand('down', 'l')<CR>
" Emacs!
imap <C-a> <Esc>I
imap <C-e> <Esc>A
" Maintain cursor position in file
:au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal g'\"" | endif
" ,, Turn off search highlight
nmap ,, :nohlsearch<CR>
" Toggle paste mode
nmap ,p :set invpaste paste?<CR>
" Neomake
call neomake#configure#automake('rw', 1000)
let g:neomake_open_list = 2
" Disable C++ in neomake in favor of languageclient
let g:neomake_cpp_enabled_makers=[]
"let g:neomake_cpp_enabled_makers=['clang']
let g:neomake_cpp_clang_args = ["-std=c++11", "-stdlib=libc++"]
let g:neomake_python_enabled_makers = ['python']
" LanguageClinet
let g:LanguageClient_serverCommands = {
\ 'cpp': ['clangd'],
\ 'typescript': ['typescript-language-server', '--stdio']
\ }
nnoremap gd :call LanguageClient#textDocument_definition()<CR>
nnoremap <Leader>' :call LanguageClient_contextMenu()<CR>
nnoremap <Leader>i :call LanguageClient#textDocument_hover()<CR>
nnoremap <Leader>] :call LanguageClient#textDocument_definition()<CR>
nnoremap <Leader>[ :call LanguageClient#textDocument_references()<CR>
nnoremap <Leader>r :call LanguageClient#textDocument_rename()<CR>
" eclim stuff
map <Leader>d <ESC>:JavaSearch -p <C-R><C-W> -x declarations<CR>
map <Leader>i <ESC>:JavaSearch -p <C-R><C-W> -x implementations<CR>
map <Leader>r <ESC>:JavaSearch -p <C-R><C-W> -x references<CR>
map <Leader>j <ESC>:JavaSearchContext<CR>
map <Leader>p <ESC>:JavaDocPreview<CR>
map <Leader>D <ESC>:JavaSearch -x declarations -p
map <Leader>I <ESC>:JavaSearch -x implementations -p
map <Leader>R <ESC>:JavaSearch -x references -p
map ; <ESC>:JavaCorrect<CR>
map <Leader>; <ESC>:lfirst<CR>:JavaCorrect<CR>
" Fix imports
nmap ,i :JavaImportOrganize<CR>
let g:EclimCompletionMethod = 'omnifunc'
" CtrlP
map <Leader>b <ESC>:CtrlPBuffer<CR>
map <Leader><Space> <ESC>:CtrlPMRUFiles<CR>
let g:ctrlp_working_path_mode = 'ra'
set wildignore+=*.o,*.so,*.swp,*.zip,*.jar,*.class,*.pdf,*.gif,*.png,*.jpg,*.o,*.hi,*.pyc
let g:ctrlp_custom_ignore = '\v[\/](_build|(\.(git|hg|svn)))$'
let g:ctrlp_max_depth = 20
let g:ctrlp_max_files = 0
if executable("ag")
set grepprg=ag\ --nogroup\ --nocolor
endif
" Airline
set laststatus=2 " Always show the statusline
set noshowmode " Hide the default mode text (e.g. -- INSERT -- below the statusline)
let g:airline_powerline_fonts=1
let g:airline_theme='dark'
let g:airline_mode_map = {
\ '__' : '-',
\ 'n' : 'N',
\ 'i' : 'I',
\ 'R' : 'R',
\ 'v' : 'V',
\ 'V' : 'V-L',
\ 'c' : 'C',
\ '' : 'V-B',
\ 's' : 'S',
\ 'S' : 'S-L',
\ '' : 'S-B',
\ }
let g:airline_section_x = airline#section#create_right([''])
let g:airline_section_z = airline#section#create(['%c'])
" Goto
nnoremap <Leader>] :YcmCompleter GoTo<CR>
let g:ycm_rust_src_path = '/usr/local/rust/src'
" Taglist
map <silent> <Leader>t :TlistToggle<CR>
let g:haddock_browser="o"
autocmd BufWritePost *.hs GhcModCheckAndLintAsync
" Deoplete
" Eclim support
" See https://www.reddit.com/r/vim/comments/5xspok/trouble_with_eclim_and_deoplete
let g:deoplete#omni#input_patterns = {}
let g:deoplete#omni#input_patterns.java = '[^. *\t]\.\w*'
" Autoclose preview windows
" https://github.com/Shougo/deoplete.nvim/issues/115
autocmd InsertLeave,CompleteDone * if pumvisible() == 0 | pclose | endif
" https://github.com/Shougo/deoplete.nvim/issues/100
" use tab to forward cycle
inoremap <silent><expr><tab> pumvisible() ? "\<c-n>" : "\<tab>"
" use tab to backward cycle
inoremap <silent><expr><s-tab> pumvisible() ? "\<c-p>" : "\<s-tab>"
" Lazy load Deoplete to reduce statuptime
" See manpage
" Enable deoplete when InsertEnter.
let g:deoplete#enable_at_startup = 1
autocmd InsertEnter * call deoplete#enable()
if filereadable($WORK_RCDIR . "/vim.rc")
source $WORK_RCDIR/vim.rc
else
Bundle 'Rip-Rip/clang_complete'
end
if filereadable($HOME . "/.vimrc.local")
source $HOME/.vimrc.local
end