-
Notifications
You must be signed in to change notification settings - Fork 6
/
sample_vimrc
290 lines (259 loc) · 8.28 KB
/
sample_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
"==================
" Plugin Management
"==================
if has('nvim')
let s:vim_plug_file="~/.local/share/nvim/site/autoload/plug.vim"
let s:vim_plug_dir="~/.local/share/nvim/plugged"
let s:local_init_file="~/.config/nvim/local_init.vim"
let s:local_plugins_file="~/.config/nvim/local_plugins.vim"
else
let s:vim_plug_file="~/.vim/autoload/plug.vim"
let s:vim_plug_dir="~/.vim/plugged"
let s:local_init_file="~/.vim/local_init.vim"
let s:local_plugins_file="~/.vim/local_plugins.vim"
endif
" Download vim-plug if it's not already present.
" Remove these lines to disable automatic downloading of vim-plug
if !filereadable(expand(s:vim_plug_file))
echom system("curl -fLo " . s:vim_plug_file . " --create-dirs "
\ . "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim")
endif
" Specify a directory for plugins
call plug#begin(s:vim_plug_dir)
" To see the description/code for the plugin loaded by the line
"
" Plug 'user/repo'
"
" go to https://github.com/user/repo.
Plug 'vim-scripts/a.vim'
Plug 'tyok/ack.vim'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'vim-scripts/drawit'
Plug 'gregsexton/gitv'
Plug 'valloric/ListToggle'
Plug 'lifepillar/vim-solarized8'
Plug 'scrooloose/nerdcommenter'
Plug 'scrooloose/nerdtree'
Plug 'tyok/nerdtree-ack'
Plug 'mklabs/split-term.vim'
Plug 'tpope/tpope-vim-abolish'
Plug 'SirVer/ultisnips'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'moll/vim-bbye'
Plug 'ntpeters/vim-better-whitespace'
Plug 'rhysd/vim-clang-format'
Plug 'tpope/vim-fugitive'
Plug 'weynhamz/vim-plugin-minibufexpl'
Plug 'tpope/vim-sleuth'
Plug 'wesQ3/vim-windowswap'
Plug 'valloric/YouCompleteMe'
" If you add additional "Plug 'user/repo'" lines in the file specified by
" s:local_plugins_file, those plugins will be loaded as well.
if filereadable(expand(s:local_plugins_file))
exec "source " . s:local_plugins_file
endif
" Initialize plugin system
call plug#end()
"============================================
" Set leader. This is used for many mappings.
"============================================
let mapleader=";"
"=========================================
" Settings/Mappings for particular plugins
"=========================================
"-----------
" Solarized8
"-----------
" This sets Solarized8 to use true Solarized colors in gVim and Neovim while
" falling back to the 256 color approximation in terminal Vim.
if (has("termguicolors"))
set termguicolors
else
set t_Co=256
" Uncomment the following line if you've set up your terminal to use
" Solarized colors.
"let g:solarized_use16=1
endif
silent! colorscheme solarized8_flat
"--------------
" YouCompleteMe
"--------------
" Jump to definition.
nnoremap <leader>gg :YcmCompleter GoTo<cr>
let g:ycm_always_populate_location_list=1
" Apply fix-it suggestion.
nnoremap <leader>fi :YcmCompleter FixIt<cr>
"------
" a.vim
"------
" Toggle between header/source (Using a.vim)
nnoremap <leader>a :A<cr>
"-----------
" ListToggle
"-----------
" Toggle the location list on and off. Useful for checking YouCompleteMe
" results.
let g:lt_location_list_toggle_map = '<leader>lo'
" Toggle the quickfix list on and off.
let g:lt_quickfix_list_toggle_map = '<leader>lq'
"----------
" ctrlp.vim
"----------
let g:ctrlp_working_path_mode = 'rw'
let g:ctrlp_custom_ignore = '\v[\/](build|doc)$'
" Launch CtrlP. Use this and then start typing fragments of the file path.
nnoremap <leader>ff :CtrlP<cr>
"------------
" vim-airline
"------------
set laststatus=2
set showtabline=2
"-------------------
" vim-airline-themes
"-------------------
let g:airline_theme='sol'
"-----
" gitv
"-----
" Launch Gitv
nnoremap <leader>gv :Gitv<cr>
"---------
" nerdtree
"---------
" Launch NerdTree (file system viewer).
nnoremap <leader>nt :NERDTree<cr>
" Launch NerdTree with the current file selected.
nnoremap <leader>nf :NERDTreeFind<cr>
"-------------
" vim-fugitive
"-------------
" Show the diff to HEAD for the current file.
nnoremap <leader>gd :Gdiff<cr>
" Show the git status of the repo.
nnoremap <leader>gs :Gstatus<cr>
" Fold method
set foldmethod=syntax
"-----------------
" vim-clang-format
"-----------------
let g:clang_format#detect_style_file=1
" Call clang-format on the current file.
autocmd FileType c,cpp,objc nnoremap <buffer><leader>cf :<C-u>ClangFormat<CR>
" Call clang-format on the selected portion of the current file.
autocmd FileType c,cpp,objc vnoremap <buffer><leader>cf :ClangFormat<CR>
"------------------------
" vim-windowswap Settings
"------------------------
let g:windowswap_map_keys = 0 "prevent default bindings
" Swap the contents of two windows. Press <leader>ss while in the first
" window, then navigate to the second window and press <leader>ss again.
nnoremap <silent> <leader>ss :call WindowSwap#EasyWindowSwap()<CR>
"===================================================================
" Other settings/mappings that are useful when working with Drake
"===================================================================
"----------------------------
" Highlight the 80-th column.
"----------------------------
autocmd FileType c,cpp set cc=80
"-------------------------------------------
" Ignore CamelCase words when spell checking
"-------------------------------------------
fun! IgnoreCamelCaseSpell()
syn match CamelCase /\<[A-Z][a-z]\+[A-Z].\{-}\>/ contains=@NoSpell transparent
syn cluster Spell add=CamelCase
endfun
autocmd BufRead,BufNewFile * :call IgnoreCamelCaseSpell()
"----------------------------------------
" Recognize doxygen comments as comments.
"----------------------------------------
autocmd Filetype c,cpp set comments^=:///
"---------------
" Misc. Settings
"---------------
" Use filetype plugins.
filetype plugin on
" Do not highlight all search matches.
set nohlsearch
" Show line numbers
set number
"=============================================================
" Other settings/mappings that may be useful in general. YYMV.
"=============================================================
"---------------------
" Buffer configuration
"---------------------
set hidden
" Open next buffer in the current window.
nmap ff :bnext<CR>
" Open previous buffer in the current window.
nmap FF :bprevious<CR>
"-----------------------
" 'Ergonomics' mappings.
"-----------------------
" Make getting from INSERT to NORMAL less of a stretch.
imap jj <Esc>
" Use <leader> + navigation keys to jump between windows in both NORMAL and
" INSERT modes.
nnoremap <leader>J <c-w>j
nnoremap <leader>K <c-w>k
nnoremap <leader>H <c-w>h
nnoremap <leader>L <c-w>l
inoremap <leader>J <Esc><c-w>j
inoremap <leader>K <Esc><c-w>k
inoremap <leader>H <Esc><c-w>h
inoremap <leader>L <Esc><c-w>l
" Save the current file.
nnoremap <leader>ww :w<cr>
" Close the current file.
nnoremap <leader>qq :q<cr>
" Save and close the current file.
nnoremap <leader>wq :w<cr>:q<cr>
" Close all files.
nnoremap <leader>qa :qa<cr>
" Use <leader><leader> as a replacement for ":".
nnoremap <leader><leader> :
"----------------------------------
" Terminal management (Neovim only)
"----------------------------------
if has('nvim')
" Open a new terminal in a horizontal split.
nnoremap <leader>tj :Term<cr><C-\><C-n><c-w>x<c-w>ji
" Open a new terminal in a vertical split.
nnoremap <leader>tl :VTerm<cr>
" Go from TERMINAL mode to NORMAL mode.
tnoremap <leader>tq <C-\><C-n>
" Go to the next tab while in TERMINAL mode.
tnoremap <leader>gt <C-\><C-n>gt
" Move to an adjacent window while in TERMINAL mode.
tnoremap <leader>J <C-\><C-n><c-w>j<Esc>
tnoremap <leader>K <C-\><C-n><c-w>k<Esc>
tnoremap <leader>H <C-\><C-n><c-w>h<Esc>
tnoremap <leader>L <C-\><C-n><c-w>l<Esc>
let g:disable_key_mappings=1
set splitright
autocmd TermOpen * setlocal nonumber
endif
"----------------------
" Edit/source this file
"----------------------
let s:current_file=expand('<sfile>:p')
if !exists("*EditVimrc")
function EditVimrc()
execute 'split' s:current_file
endfunction
endif
if !exists("*SourceVimrc")
function SourceVimrc()
execute 'source' s:current_file
endfunction
endif
" Edit this file.
nnoremap <leader>ev :call EditVimrc()<CR>
" Source this file.
nnoremap <leader>sv :call SourceVimrc()<CR>
" If you put more mappings or other magic in the file specified by
" s:local_init_file, those will be added here.
if filereadable(expand(s:local_init_file))
exec "source " . s:local_init_file
endif