-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
349 lines (309 loc) · 11.1 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
" Name: .vimrc
" Author: Justin Helgesen <justinhelgesen@gmail.com>
" Created: On a cold winter night in the year of the sheep
"
" Useage "{{{
"
" ---------------------------------------------------------------------
" ABOUT:
" ---------------------------------------------------------------------
" This is my vimrc file. Setup is intended to be generic as possible
" accross a wide range of systems which I commonly use.
"
" Fitness for anyone else is purely coincidental.
"
" ---------------------------------------------------------------------
" PLUGIN INSTALLATION:
" ---------------------------------------------------------------------
" Vundle:
" 1) Clone repo
" $ mkdir -p ~/.vim/bundle
" $ cd ~/.vim/bundle
" $ git clone https://github.com/VundleVim/Vundle.vim.git
" 2) Install other plugins by executing :PluginInstall
" Reference: https://github.com/VundleVim/Vundle.vim
"
" VimProc:
" 1) Execute :PluginInstall
" 2) $ cd ~/.vim/bundle/vimproc.vim
" $ make
" References: :help vimproc
"
" VimRtags:
" vim-rtags requires RTags to be installed. See
" doc/README.codecompletion.md and https://github.com/Andersbakken/rtags
" for more information.
"
" VimAutoFormat:
" Optional External Format Programs:
" clang-format: provided by clang - supports C, C++, Objective-C
" astyle: provided by astyle - supports C#, C++, C Java
" autopep8: provided by python-autopep8 - supports Python
" tidy: proficec by tidy - supports HTML, XHTML, XML
" js-beautify: profided by pip's jsbeautifier - supports javascript, json
" For more see references.
"
" 1) dnf install astyle clang python-autopep8 tidy
" 2) pip install jsbeautifier
" 3) Execute :PluginInstall
" References: https://github.com/Chiel92/vim-autoformat
"
" VimGo:
" 1) Setup GOPATH and PATH for go development
" 2) install necessary binaries (such as gocode, godef, goimports, etc.)
" :GoInstallBinaries
" References: help: vim-go
" https://github.com/fatih/vim-go
"
" Tagbar:
" 1) dnf install ctags
" References: https://github.com/majutsushi/tagbar
"
" }}}
" Plugin Settings "{{{
"
" Only configure plugins if vundle is installed
if isdirectory(glob("~/.vim/bundle/Vundle.vim"))
" =========================== Vundle Config ================================
set nocompatible " be iMproved, required
filetype off " required
set rtp+=~/.vim/bundle/Vundle.vim " set the runtime path to include Vundle
call vundle#begin() " initialize Vundle
" =========================== Activate Plugins below =======================
Plugin 'gmarik/Vundle.vim' " let Vundle manage Vundle, required
Plugin 'tpope/vim-fugitive'
Plugin 'mileszs/ack.vim'
Plugin 'altercation/vim-colors-solarized'
Plugin 'mtth/scratch.vim'
Plugin 'scrooloose/nerdtree'
Plugin 'davidhalter/jedi-vim'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
if v:version > 700
Plugin 'Shougo/vimshell.vim'
Plugin 'Shougo/vimproc.vim'
Plugin 'scrooloose/nerdcommenter'
endif
if v:version > 701
Plugin 'majutsushi/tagbar'
endif
if v:version > 702
Plugin 'Chiel92/vim-autoformat'
endif
if has("patch-7.4.2009")
Plugin 'fatih/vim-go'
endif
if has("+lua")
Plugin 'Shougo/neocomplete.vim'
endif
if has("+python") || has("+python3")
Plugin 'lyuts/vim-rtags'
endif
" =========================== Finish Vundle Config ========================
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
" filetype plugin on
" =========================== Plugin Settings ==============================
let g:my#bundles = map(copy(g:vundle#bundles), 'v:val.name_spec')
function! IsPluginInstalled(name)
return index(g:my#bundles, a:name) > -1
endfunction
if IsPluginInstalled('vim-airline/vim-airline')
let g:airline#extensions#tabline#enabled = 0
if g:airline#extensions#tabline#enabled != 0
let g:airline#extensions#tabline#buffer_idx_mode = 1
nmap <leader>1 <Plug>AirlineSelectTab1
nmap <leader>2 <Plug>AirlineSelectTab2
nmap <leader>3 <Plug>AirlineSelectTab3
nmap <leader>4 <Plug>AirlineSelectTab4
nmap <leader>5 <Plug>AirlineSelectTab5
nmap <leader>6 <Plug>AirlineSelectTab6
nmap <leader>7 <Plug>AirlineSelectTab7
nmap <leader>8 <Plug>AirlineSelectTab8
nmap <leader>9 <Plug>AirlineSelectTab9
nmap <leader>- <Plug>AirlineSelectPrevTab
nmap <leader>= <Plug>AirlineSelectNextTab
nmap <leader>+ <Plug>AirlineSelectNextTab
endif
endif
"Autoformat settings
if IsPluginInstalled('Chiel92/vim-autoformat')
let g:formatterpath = ['/opt/llvm-10/bin/']
let g:formatdef_my_custom_json='"js-beautify -s 2 -P -n -b expand "'
let g:formatters_json = ['my_custom_json']
noremap <Leader>af :Autoformat<CR>
endif
" NERDTree Settings
if IsPluginInstalled('scrooloose/nerdtree')
noremap <Leader>nt :NERDTreeToggle<CR>
noremap <Leader>nc :NERDTreeClose<CR>
noremap <Leader>nf :NERDTreeFind<CR>
endif
" Tagbar Settings
if IsPluginInstalled('majutsushi/tagbar')
noremap <Leader>ol :TagbarToggle<CR>
endif
" Scratch Setting
if IsPluginInstalled('mtth/scratch.vim')
let g:scratch_autohide = 0
endif
" Solarized color theme
if IsPluginInstalled('altercation/vim-colors-solarized')
if $TERM !~ '\.*256color$' && ! has('gui_running')
let g:solarized_termcolors=256 " Use degraded 256 color schema
set t_Co=256
endif
"if $TERM == 'rxvt-256color'
"let g:solarized_termtrans=1 " Transparant background
"endif
let g:solarized_hitrail=1 " Hilight trailing white space
set background=dark " Configure solarized[dark|light]
syntax enable " Enable syntax highlighting
colorscheme solarized " Activate solarized color scheme
endif
" Setup neocomplete
if IsPluginInstalled('Shougo/neocomplete.vim')
let g:acp_enableAtStartup = 0
let g:neocomplete#enable_at_startup = 1
let g:neocomplete#enable_smart_case = 1
let g:neocomplete#sources#syntax#min_keyword_length = 3
let g:neocomplete#lock_buffer_name_pattern = '\*ku\*'
let g:neocomplete#sources#dictionary#dictionaries = {
\ 'default' : '',
\ 'vimshell' : $HOME.'/.vimshell_hist',
\ 'scheme' : $HOME.'/.gosh_completions'
\ }
if !exists('g:neocomplete#keyword_patterns')
let g:neocomplete#keyword_patterns = {}
endif
let g:neocomplete#keyword_patterns['default'] = '\h\w*'
inoremap <expr><C-g> neocomplete#undo_completion()
inoremap <expr><C-l> neocomplete#complete_common_string()
inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR>
function! s:my_cr_function()
return pumvisible() ? "\<C-y>" : "\<CR>"
endfunction
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<TAB>"
inoremap <expr><C-h> neocomplete#smart_close_popup()."\<C-h>"
inoremap <expr><BS> neocomplete#smart_close_popup()."\<C-h>"
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
if !exists('g:neocomplete#sources#omni#input_patterns')
let g:neocomplete#sources#omni#input_patterns = {}
endif
" Setup jedi with neocomplete
if IsPluginInstalled('davidhalter/jedi-vim')
if !exists('g:neocomplete#force_omni_input_patterns')
let g:neocomplete#force_omni_input_patterns = {}
endif
autocmd FileType python setlocal omnifunc=jedi#completions
let g:jedi#completions_enabled = 0
let g:jedi#auto_vim_configuration = 0
let g:jedi#smart_auto_mappings = 0
let g:neocomplete#force_omni_input_patterns.python = '\%([^. \t]\.\|^\s*@\|^\s*from\s.\+import \|^\s*from \|^\s*import \)\w*'
" alternative pattern: '\h\w*\|[^. \t]\.\w*'
else
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
endif
" Setup Neocomplete for Cpp with vim-rtags
if IsPluginInstalled('lyuts/vim-rtags')
function! SetupNeocomleteForCppWithRtags()
setlocal omnifunc=RtagsCompleteFunc
if !exists('g:neocomplete#sources#omni#input_patterns')
let g:neocomplete#sources#omni#input_patterns = {}
endif
let l:cpp_patterns='[^.[:digit:] *\t]\%(\.\|->\)\|\h\w*::'
let g:neocomplete#sources#omni#input_patterns.cpp = l:cpp_patterns
set completeopt+=longest,menuone
endfunction
autocmd FileType cpp,c call SetupNeocomleteForCppWithRtags()
endif
endif
endif
" }}}
" General Key Mappings, Settings and Functions "{{{
"
" Change the local working directory to that of the current buffer
noremap <Leader>cd :lcd %:p:h<CR>
" Remove trailing white space
noremap <Leader>rts :%s/\s\+$//e \| :noh<CR>
noremap <Leader>rt :s/\s\+$//e \| :noh<CR>
" Enable mouse in terminal for all modes if clipboard is enabled
if has("clipboard")
set mouse=a
endif
" Set display characters for list
set listchars=trail:~,tab:»·,eol:▼
" space was add in version 7.4.710
if has("patch-7.4.710")
set listchars+=space:·
endif
" Display line numbers
set number
" Display right margin
if exists('+colorcolumn')
set colorcolumn=80
endif
" Enable enhanced command-line completion
set wildmenu
" Complete longest common string => lists alternatives => each full match
set wildmode=longest,list,full
" Allow modified buffers to be hidden
set hidden
" Disable audio bell
set noerrorbells
if exists('+belloff')
set belloff=all
endif
" Disable visual bell
" set novb t_vb=
set vb t_vb=
" Set the GUI font
set guifont=Consolas
" Always show status
set laststatus=2
" Disable incremental search
set noincsearch
" Indicates a fast terminal connection
set ttyfast
set makeprg=tbmake\ -sj\ TESTS=NO\ RECURSIVE=NO
autocmd FileType sh setlocal makeprg=shellcheck\ %
" tabsstop = shiftwidth = softtabstop
set tabstop=4 shiftwidth=0 softtabstop=-1
" Default to expandtab
set expandtab
" Fix issue where json file was detected as javascript
" NB: Must be executed before any "autocmd FileType"
autocmd BufEnter *.json :setlocal filetype=json
" tabs=2
autocmd FileType java,sh,html,xhtml,css setlocal tabstop=2
" tabs=4
autocmd FileType go,python,make,gitconfig,c,cpp,xml,xslt,xsd,json setlocal tabstop=4
" tabs=8
autocmd FileType markdown,help,text,make setlocal tabstop=8
" text like files: set text width
autocmd FileType markdown,help,text setlocal textwidth=78
" tabs->spaces
autocmd FileType c,cpp,sh,xml,html,java,perl,python,json setlocal expandtab
" tabs
autocmd FileType go,make setlocal noexpandtab
" turn on spell check
autocmd FileType gitcommit setlocal spell
" Trim trailing white space when writing
"autocmd FileType python,make,c,cpp,java,php,xml,html,sh,vim
"\ autocmd BufWritePre <buffer> if ! &diff | :%s/\s\+$//e | endif
" Use ":DiffOrig" to see the differences
" between the current buffer and the file it was loaded from.
" see ":help DiffOrig"
if !exists(':DiffOrig')
command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
\ | wincmd p | diffthis
endif
" Syntax highlighting sucks for long lines, limit it to 365 characters
set synmaxcol=365
" }}}
" vim:foldmethod=marker:foldlevel=0:ts=2:noet