-
Notifications
You must be signed in to change notification settings - Fork 2
/
vimrc
321 lines (261 loc) · 9.89 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
" This line should not be removed as it ensures that various options
" are properly set to work with the Vim-related packages available in
" Debian.
runtime! debian.vim
" Make Vim non-Vi compatible
set nocompatible
" Vundle plugin manager
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
Plugin 'tpope/vim-fugitive'
Plugin 'Shougo/unite.vim'
Plugin 'Shougo/vimproc.vim'
Plugin 'Shougo/neomru.vim'
Plugin 'Shougo/unite-outline'
Plugin 'tomtom/tcomment_vim'
Plugin 'elzr/vim-json'
Plugin 'henrik/vim-indexed-search'
Plugin 'guns/xterm-color-table.vim'
Plugin 'scrooloose/nerdtree'
Plugin 'kien/ctrlp.vim'
Plugin 'kshenoy/vim-signature'
Plugin 'airblade/vim-gitgutter'
call vundle#end()
"--------------------------------------------------------------------"
" "Syntax and Colors" "
"--------------------------------------------------------------------"
" Indentation rules
filetype plugin indent on
" Syntax highlighting
syntax on
" If using a dark background within the editing area and syntax
" highlighting turn on this option as well
set background=dark
" Color Scheme
colorscheme mint
"--------------------------------------------------------------------"
" "Settings" "
"--------------------------------------------------------------------"
" Uncomment the following to have Vim jump to the last position when
" reopening a file
if has("autocmd")
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif
" Misc
set autoread " auto-reads a file that was changed on disk
set autowrite " auto-save before commands like :next and :make
set hidden " Hide buffers when they are abandoned
set noerrorbells " No beeping
set virtualedit=block " rectangular highlight in visual block mode
" Dimensions
set textwidth=80 " Virtual line width
set colorcolumn=81 " Vertical ruler at 81 characters
" Information
set showcmd " Show (partial) command in status line.
set showmode " Show the current mode
set laststatus=2 " always show status line
" Statusline
set statusline=%F
set statusline+=%{FugitiveStatus()}
" set statusline+=%{StatuslineCurrentHighlight()}
set statusline+=%=
set statusline+=%m
set statusline+=\ %Y
set statusline+=\ %3l/%L[%3p%%]
" Navigation
set nu " Set line numbering
set scrolloff=5 " keep at least 5 lines above/below
set mouse=a " Enable mouse usage (all modes)
set mousehide " Hide the mouse when typing
set cursorline " Highlights the cursor line
" Searching
set ignorecase " Do case insensitive matching
set smartcase " Do smart case matching
set incsearch " Incremental search
set hlsearch " highlight searches
set showmatch " Show matching brackets.
" Tabs (spacing)
set expandtab " Use spaces instead of tabs
set tabstop=4 " How many spaces a tab measures
set shiftwidth=4 " Sets >> and << width
set autoindent
set list " Show hidden characters: tabs, trails
set listchars=trail:·,tab:››
set backspace=indent,eol,start
" Folding
set foldenable " Enables folds
" set foldcolumn=1 " Shows folds in a column
set foldmethod=indent " Folds on indentation
au BufWinLeave * silent! mkview
au BufWinEnter * silent! loadview
" Backups
set nobackup " Remove backup files
set noswapfile " Remove swap files
" Change the <leader> key to ,
let mapleader=","
" External Pasting and Copying options
set pastetoggle=<C-x> " Toggles pasting mode for external paste
nnoremap <leader>n :set nu!<CR>:set foldenable!<CR><C-x>
"--------------------------------------------------------------------"
" "Filetypes" "
"--------------------------------------------------------------------"
au BufRead,BufNewFile *.md set filetype=markdown
au BufRead,BufNewFile *.tex set filetype=tex
set wildignore=*/.git/*,*.pyc,*bin/*,*lib/*,*.pdf,*.aux,*.log
"--------------------------------------------------------------------"
" "Normal Mode bindings" "
"--------------------------------------------------------------------"
" Enter command mode easier
nnoremap ; :
" Refreshes screen
nnoremap <Enter> :nohl<CR><C-l><Enter>
" Mapping keys for multiple windows (navigation and resizing)
nnoremap __ :split
nnoremap <Bar><Bar> :vsplit
nnoremap <C-k> <C-W>k
nnoremap <C-j> <C-W>j
nnoremap <C-h> <C-W>h
nnoremap <C-l> <C-W>l
nnoremap <C-o> <C-w>o
nnoremap + <C-W>+
nnoremap = <C-W>=
nnoremap - <C-W>-
" Change cursor to move along rows, not lines. (useful for long lines)
nnoremap j gj
nnoremap k gk
nnoremap ^ g^
nnoremap 0 g0
nnoremap cc :set cursorcolumn!<CR>
" Remembers last place before jump
nnoremap '' <C-O>
nnoremap ' `
" Centers screen around cursor
nnoremap <space> zz
nnoremap n nzz
nnoremap N Nzz
" Tabs (navigation)
nnoremap tt :tabm
nnoremap tl gt
nnoremap th gT
nnoremap td :tabclose<CR>
" Indent/Unident quicker
nnoremap < <<
nnoremap > >>
" Yanking
nnoremap Y v$y
nnoremap gy "+yy
" Replace surrounded characters
nnoremap c( ci(
nnoremap c[ ci[
nnoremap c< ci<
nnoremap c{ ci{
nnoremap c" ci"
nnoremap c' ci'
"--------------------------------------------------------------------"
" "Insert Mode Bindings" "
"--------------------------------------------------------------------"
" Easier window switching keys
inoremap <C-j> <esc><C-w>j
inoremap <C-k> <esc><C-w>k
inoremap <C-l> <esc><C-w>l
inoremap <C-h> <esc><C-w>h
"--------------------------------------------------------------------"
" "Visual Mode Bindings" "
"--------------------------------------------------------------------"
vnoremap < <gv
vnoremap > >gv
vnoremap gy "+y
vnoremap // y/<c-r>"<cr>
"--------------------------------------------------------------------"
" "Command Mode Bindings" "
"--------------------------------------------------------------------"
" Aliasing accidental shifts
cnoreabbrev W w
cnoreabbrev Q q
cnoreabbrev Qa qa
cnoreabbrev X x
cnoreabbrev sh sh
cnoreabbrev Sh sh
cnoreabbrev sH sh
cnoreabbrev SH sh
" Fugitive
nnoremap <leader>gs :Gstatus<CR>
nnoremap <leader>gc :Gcommit -m "
function! FugitiveStatus()
let branch = fugitive#head()
if !empty(branch)
let branch = " [" . branch . "] "
endif
return branch
endfunction
"--------------------------------------------------------------------"
" "Unite" "
"--------------------------------------------------------------------"
let g:unite_winwidth = 30
let g:unite_winheight = 10
let g:unite_source_history_yank_enable = 1
let g:unite_prompt = '> '
call unite#filters#matcher_default#use(['matcher_fuzzy'])
nnoremap <silent><leader>m :Unite -input= -resume -start-insert buffer file_mru<CR>
nnoremap <silent><leader>f :Unite grep:.<CR>
nnoremap <silent><leader>y :Unite history/yank<CR>
nnoremap <silent><leader>o :<C-u>Unite -vertical -start-insert outline<CR>
call unite#custom_source('file_rec/async,file_mru,buffer,grep',
\ 'ignore_pattern', join([
\ '\.git/',
\ 'lib/',
\ 'bin/',
\ '__pycache__/',
\ '\.d',
\ '\.pdf',
\ '\.aux',
\ '\.log',
\ ], '\|'))
" Custom mappings for unite buffer
autocmd FileType unite call s:unite_settings()
function! s:unite_settings()
nnoremap <silent><buffer><expr> <C-v> unite#do_action('right')
nnoremap <silent><buffer><expr> <C-i> unite#do_action('below')
nnoremap <silent><buffer><expr> <C-t> unite#do_action('tabswitch')
nnoremap <buffer> <Enter> <Enter>
endfunction!
"--------------------------------------------------------------------"
" "NERDTree" "
"--------------------------------------------------------------------"
nnoremap <tab> :NERDTreeToggle<CR>
let NERDTreeShowBookmarks=1 " Show bookmarks by default
let NERDTreeIgnore = ['__pycache__', '\.*pyc$']
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
"--------------------------------------------------------------------"
" "Ctrl-P" "
"--------------------------------------------------------------------"
nnoremap <leader>m :CtrlPBuffer<CR>
"--------------------------------------------------------------------"
" "Signature" "
"--------------------------------------------------------------------"
let g:SignatureMap = {
\ 'PlaceNextMark' : "ma",
\ }
let g:SignatureMarkOrder="\m "
let g:SignatureMarkTextHLDynamic=1
"--------------------------------------------------------------------"
" "Gitgutter" "
"--------------------------------------------------------------------"
nmap ga <Plug>GitGutterStageHunk
nmap gr <Plug>GitGutterRevertHunk
let g:gitgutter_sign_added = '+ '
let g:gitgutter_sign_modified = '* '
let g:gitgutter_sign_removed = '- '
let g:gitgutter_sign_modified_removed = '*-'
"--------------------------------------------------------------------"
" "Syntax Highlighting utility" "
"--------------------------------------------------------------------"
function! StatuslineCurrentHighlight()
let name = synIDattr(synID(line('.'),col('.'),1),'name')
if name == ''
return ''
else
return '[' . name . ']'
endif
endfunction