-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvimrc
More file actions
385 lines (301 loc) · 10.4 KB
/
vimrc
File metadata and controls
385 lines (301 loc) · 10.4 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
" Don't source this file again if it was already loaded. This happens when
" this file is located at ~/.vimrc
if exists('g:vimrc_sourced')
finish
endif
"--------------------------------------------------------------------------------
"dein (plugin manager) Scripts-----------------------------
if &compatible
set nocompatible " Be iMproved
endif
" Fix up the runtime path to use the system first, then local
let rtp=&runtimepath
set runtimepath=/etc/vim,/etc/vim/bundle/dein.vim,~/.vim/bundle/dein.vim
let &runtimepath.=','.rtp
" Figure out the correct dein directory, which depends on whether this is run
" directly or via docker
if isdirectory(resolve(expand("~/.vim/bundle/dein.vim")))
let deindir="~/.vim/bundle/dein.vim"
let deinstate="~/.vim/bundle/dein.vim/state"
else
let deindir="/etc/vim/bundle/dein.vim"
let deinstate="/etc/vim/bundle/dein.vim/state"
endif
" Required:
if dein#load_state(deinstate)
call dein#begin(deinstate)
" Let dein manage dein
" Required:
call dein#add(deindir)
" 5 minute install timeout for bundles
let g:dein#install_process_timeout = 1500
" Add or remove your plugins here like this:
"call dein#add('Shougo/neosnippet.vim')
"call dein#add('Shougo/neosnippet-snippets')
" YouCompleteMe config file autogenerator
call dein#add('rdnetto/YCM-Generator')
" Easy find/replace
call dein#add('dkprice/vim-easygrep')
" Call graphs using cscope
call dein#add('hari-rangarajan/CCTree')
" File system browser
call dein#add('scrooloose/nerdtree')
call dein#add('Xuyuanp/nerdtree-git-plugin')
" Git tools inside vim
call dein#add('tpope/vim-fugitive')
call dein#add('airblade/vim-gitgutter')
" Autocompletion for many file types
call dein#add('Valloric/YouCompleteMe', { 'merged': 0 })
" Automated linting
call dein#add('dense-analysis/ale')
" Local .vimrc files for projects
call dein#add('MarcWeber/vim-addon-local-vimrc')
" Easy commenting / uncommenting with gc
call dein#add('tpope/vim-commentary')
" Adds ae and ie motions to operate on the entire file
call dein#add('kana/vim-textobj-user')
call dein#add('kana/vim-textobj-entire')
" Adds fuzzy file searching
call dein#add('ctrlpvim/ctrlp.vim')
" Automatic paste mode
call dein#add('ConradIrwin/vim-bracketed-paste')
" AnsiEsc - Lets you load files with ANSI color codes embedded in them
call dein#add('powerman/vim-plugin-AnsiEsc')
" Note Taking Tools
call dein#add('vimwiki/vimwiki')
call dein#add('fmoralesc/vim-pad')
call dein#add('vim-scripts/utl.vim')
" Java Unused Imports
" NeoBundle 'akhaku/vim-java-unused-imports'
" Java Import Manager
" NeoBundle 'vim-scripts/JavaImp.vim--Lee'
" Required:
call dein#end()
call dein#save_state()
endif
" Required:
filetype plugin indent on
syntax enable
" If you want to install not installed plugins on startup.
"if dein#check_install()
" call dein#install()
"endif
"End dein Scripts-------------------------
if has('cscope')
set cscopetag cscopeverbose
if has('quickfix')
" set cscopequickfix=s-,c-,d-,i-,t-,e-
endif
"cnoreabbrev csa cs add
"cnoreabbrev csf cs find
"cnoreabbrev csk cs kill
"cnoreabbrev csr cs reset
"cnoreabbrev css cs show
"cnoreabbrev csh cs help
function! LoadCscope()
let l:dbcount=1
let l:db = "junk"
while (!empty(l:db))
let l:db = findfile("cscope.out", ".;", l:dbcount)
if (!empty(l:db))
let path = strpart(l:db, 0, match(l:db, "/cscope.out$"))
set nocscopeverbose " suppress 'duplicate connection' error
" Load the cscope database into cscope
exe "cs add " . l:db . " " . path
set cscopeverbose
let l:dbcount = l:dbcount + 1
endif
endwhile
endfunction
autocmd Filetype c call LoadCscope()
function! Loadcctree()
let l:dbcount=1
let l:db = "junk"
while (!empty(l:db))
let l:db = findfile("cscope.out", ".;", l:dbcount)
if (!empty(l:db))
" Load the cscope database into cctree
if (l:dbcount > 1)
exe "CCTreeAppendDB " . l:db
else
exe "CCTreeLoadDB " . l:db
endif
let l:dbcount = l:dbcount + 1
endif
endwhile
endfunction
endif
function! Astylelinux()
exe "write"
set autoread
exe "!astyle --style=linux --indent=tab=8 --convert-tabs --indent-preprocessor --min-conditional-indent=3 --max-instatement-indent=60 --pad-oper --unpad-paren --pad-header --align-pointer=name --indent-namespaces --max-code-length=100 %"
set noautoread
endfunction
function! Astyleallman()
exe "write"
set autoread
exe "!astyle --style=allman --indent=tab=4 --convert-tabs --indent-preprocessor --min-conditional-indent=3 --max-instatement-indent=60 --pad-oper --unpad-paren --pad-header --align-pointer=name --indent-namespaces --max-code-length=100 %"
set noautoread
endfunction
" Set the gq autoformat command to use astyle
" For C/C++ use Linux kernel style code
autocmd Filetype c,cpp set formatprg=astyle\ --style=linux\ --indent=tab=8\ --convert-tabs\ --indent-preprocessor\ --min-conditional-indent=3\ --max-instatement-indent=60\ --pad-oper\ --unpad-paren\ --pad-header\ --align-pointer=name\ --indent-namespaces\ --max-code-length=100
autocmd Filetype java set formatprg=astyle\ --style=java\ --indent=tab=4\ --convert-tabs\ --min-conditional-indent=3\ --max-instatement-indent=60\ --pad-oper\ --unpad-paren\ --pad-header\ --indent-namespaces\ --add-brackets
function! TabsOn()
set list listchars=tab:\>\ ,trail:-
endfunction
function! TabsOff()
set nolist
endfunction
" Allow using mouse in VIM. From here:
" https://superuser.com/questions/549930/cant-resize-vim-splits-inside-tmux
function! MouseOn()
nunmap <C-M>
nmap <C-M> :call MouseOff()<CR>
set mouse+=a
set ttymouse=xterm2
endfunction
function! MouseOff()
nunmap <C-M>
nmap <C-M> :call MouseOn()<CR>
set mouse-=a
set ttymouse=
endfunction
nmap <C-M> :call MouseOn()<CR>
" More info here: http://vim.wikia.com/wiki/Highlight_unwanted_spaces
" Show tabs that are not at the start of a line:
" Show spaces used for indenting from the start of a line, unless the next
" immediate character is a *
" highlight ExtraWhitespace ctermbg=darkgreen guibg=darkgreen
" autocmd Filetype c,cpp match ExtraWhitespace /^[^/].*[^\t]\zs\t\+\|^\zs \+\ze[^\*]/
" Remove whitespace from end of lines when saving
autocmd BufWritePre * :%s/\s\+$//e
" Show commands triggered by macros/leader shortcuts
set showcmd
" Don't wrap long lines
set nowrap
" Use UTF-8 encoding
set encoding=utf-8
" Use tabs, display them with a width of four characters
set tabstop=4
set shiftwidth=4
" Text files don't use tabs
autocmd FileType text setlocal expandtab
" Allow backspacing over everything in insert mode
set bs=indent,eol,start
" Always set autoindenting on
set autoindent
" Keep lots of command line history
set history=10000
" Show the cursor position all the time
set ruler
" Show a line at the current cursor position
set cursorline
" Make search more visible
set incsearch
set showmatch
set hlsearch
" Case insensitive unless something is uppercase
set ignorecase
set smartcase
" ZSH style autocompletion via tab
set wildmenu
set wildmode=full
" Vertical split windows open on the right instead of the left
set splitright
" If input is from stdin, assume it hasn't been modified (and thus will not require saving or ! to escape)
autocmd StdinReadPost * set nomodified
" Fix weird NERDTree characters
let g:NERDTreeDirArrows=0
" Open Ctrl-P with ,p
let g:ctrlp_map = '<leader>p'
let g:ctrlp_cmd = 'CtrlP'
" Ctrl-P ignore list
let g:ctrlp_custom_ignore = { 'dir': '\v[\/]\.(git|hg|svn)$', 'file': '\v\.(class)$' }
" Open nerdtree with ,ne
let mapleader = ","
nmap <leader>ne :NERDTree<cr>
" Open taglist with ,tl
nmap <leader>tl :TlistToggle<cr>
" Load cctree taglist with ,cc
nmap <leader>cc :call Loadcctree()<cr>
" Edit this vimrc file with ,vi
nmap <leader>vi :tabedit $MYVIMRC<CR>
" YouCompleteMe shortcuts
nmap <leader>ji :YcmCompleter OrganizeImports<CR>
nmap <leader>fi :YcmCompleter FixIt<CR>
" GitGutter sign column minimalist customization
let g:gitgutter_sign_added = '+'
let g:gitgutter_sign_modified = '>'
let g:gitgutter_sign_removed = '-'
let g:gitgutter_sign_removed_first_line = '^'
let g:gitgutter_sign_modified_removed = '<'
highlight GitGutterAdd guifg=#009900 ctermfg=2
highlight GitGutterChange guifg=#bbbb00 ctermfg=3
highlight GitGutterDelete guifg=#ff2222 ctermfg=1
highlight! link SignColumn LineNr
" Update stuff(?) a lot more often for improved responsiveness
" This improves the sign column responsiveness, not sure what else it changes
set updatetime=250
" Hunk-add and hunk-revert for chunk staging
nmap <Leader>ga <Plug>(GitGutterStageHunk)
nmap <Leader>gu <Plug>(GitGutterUndoHunk)
" Jump between hunks
nmap <Leader>gn <Plug>(GitGutterNextHunk)
nmap <Leader>gp <Plug>(GitGutterPrevHunk)
" Quickfix mappings:
nmap <leader>co :copen<CR>
nmap <leader>cq :cclose<CR>
nmap <leader>cn :cn<CR>
nmap <leader>cp :cp<CR>
" Next buffer shortcut
nmap <leader>nn :bnext<CR>
" Disable highlighting:
nmap <leader>hl :nohls<CR>
" Set YouCompleteMe semantic completer to trigger on 'Control + k'
let g:ycm_key_invoke_completion = '<c-k>'
let g:ycm_always_populate_location_list = 1
let g:ycm_autoclose_preview_window_after_insertion = 1
let g:ycm_global_ycm_extra_conf = '/etc/global_ycm_extra_conf.py'
" Taglist plugin opens on the right, rather than the left
let Tlist_Use_Right_Window = 1
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
syntax on
endif
" Disable color_coded in diff mode
if &diff
let g:color_coded_enabled = 0
endif
" Control + S saves current file
nmap <c-s> :w<CR>
imap <c-s> <Esc>:w<CR>a
" Disable Q starting Ex mode
nnoremap Q <nop>
" Allow saving of files as sudo when I forgot to start vim using sudo.
cmap w!! w !sudo tee > /dev/null %
" Rebuild PlantUML with ,ml
" let g:plantuml_executable_script='java -jar /path/to/plantuml.jar -tsvg'
" nmap <leader>ml :w<CR> :silent make<CR>
" Use markdown syntax highlighting for wiki
let wiki_1 = {}
let wiki_1.syntax = 'markdown'
let g:vimwiki_list = [wiki_1]
let g:pad#dir = '~/vimwiki'
let g:vimwiki_conceallevel = 0
" Adjust highlighting to better utilize color_coded
exe 'hi Function ctermfg=white'
exe 'hi Type ctermfg=lightgreen'
exe 'hi Number ctermfg=red'
exe 'hi Macro ctermfg=blue'
exe 'hi PreProc ctermfg=brown'
exe 'hi Comment ctermfg=cyan'
exe 'hi TODO ctermfg=black ctermbg=red'
exe 'hi Member ctermfg=gray'
exe 'hi Variable ctermfg=gray'
exe 'hi Namespace ctermfg=gray'
exe 'hi EnumConstant ctermfg=blue'
let g:ale_linters={ 'python': ['pylint'], }
let g:vimrc_sourced = 1
source ~/.vimrc