-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
305 lines (249 loc) · 7.72 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
" vim-plug setup
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
if has("win32")
call plug#begin('~/vimfiles/plugged')
else
call plug#begin('~/.vim/plugged')
endif
let g:plug_window="enew"
Plug 'tpope/vim-sensible'
Plug 'sheerun/vim-polyglot'
Plug 'lifepillar/vim-solarized8'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'Raimondi/delimitMate'
Plug 'Shougo/neocomplcache'
Plug 'godlygeek/tabular'
Plug 'henrik/vim-indexed-search'
Plug 'honza/vim-snippets'
Plug 'mattn/emmet-vim'
Plug 'mileszs/ack.vim'
Plug 'scrooloose/syntastic'
Plug 'sirver/ultisnips'
Plug 'sjl/gundo.vim'
Plug 'spiiph/vim-space'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-endwise'
Plug 'tpope/vim-eunuch'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-unimpaired'
Plug 'tpope/vim-vinegar'
Plug 'vim-scripts/ZoomWin'
call plug#end()
syntax on
filetype plugin indent on
" ---------------
" no swap/backup
" ---------------
set noswapfile
set nobackup
set nowb
" ---------------
" Color
" ---------------
if !has('gui_running')
set t_Co=16
endif
set background=light
let g:solarized_old_cursor_style=1
colorscheme solarized8
" ---------------
" UI
" ---------------
set ruler " Ruler on
set nu " Line numbers on
set wrap " Line wrapping on
set laststatus=2 " Always show the statusline
set cmdheight=2 " Make the command area two lines high
set gcr=a:blinkon0 "Disable cursor blink
set encoding=utf-8
set cursorline
let g:netrw_liststyle = 3 " tree
" ---------------
" Behaviors
" ---------------
set autoread " Automatically reload changes if detected
set hidden " Change buffer - without saving
set history=768 " Number of things to remember in history.
set cf " Enable error files & error jumping.
" set clipboard+=unnamed " Yanks go on clipboard instead.
set autowrite " Writes on make/shell commands
set timeoutlen=500 " Time to wait for a command (after leader for example)
set foldlevelstart=99 " Remove folds
set formatoptions=crql
set iskeyword+=$,@ " Add extra characters that are valid parts of variables
set splitbelow
set splitright
" ---------------
" Text Format
" ---------------
set tabstop=2
set backspace=2 " Delete everything with backspace
set shiftwidth=2 " Tabs under smart indent
set cindent
set autoindent
set smarttab
set expandtab
" Display tabs and trailing spaces visually
set list listchars=tab:▸\ ,trail:·
" ---------------
" Searching
" ---------------
set ignorecase " Case insensitive search
set smartcase " Non-case sensitive search
set incsearch
set hlsearch
" ---------------
" Visual
" ---------------
set showmatch " Show matching brackets.
set matchtime=2 " How many tenths of a second to blink
" ---------------
" Sounds
" ---------------
set noerrorbells
set visualbell
set t_vb=
" ---------------
" Mouse
" ---------------
set mousehide " Hide mouse after chars typed
set mouse=a " Mouse in all modes
" Better complete options to speed it up
set complete=.,w,b,u,U
" ================ Completion =======================
set wildmode=longest,full
set wildmenu "enable ctrl-n and ctrl-p to scroll thru matches
set wildignore+=*.o,*.obj,*.exe,*.so,*.dll,*.pyc,.svn,.hg,.bzr,.git,.sass-cache,*.class,*.scssc
set wildignore+=*/vim/backups*
set wildignore+=*/DS_Store*
set wildignore+=*.gem
set wildignore+=*.png,*.jpg,*.gif
" ================ Scrolling ========================
set scrolloff=4 "Start scrolling when we're 4 lines away from margins
set sidescrolloff=15
set sidescroll=1
" ----------------------------------------
" Remove Trailing Whitespaces
" ----------------------------------------
" via: http://rails-bestpractices.com/posts/60-remove-trailing-whitespace
" Strip trailing whitespace
function! <SID>StripTrailingWhitespaces()
" Preparation: save last search, and cursor position.
let _s=@/
let l = line(".")
let c = col(".")
" Do the business:
%s/\s\+$//e
" Clean up: restore previous search history, and cursor position
let @/=_s
call cursor(l, c)
endfunction
command! StripTrailingWhitespaces call <SID>StripTrailingWhitespaces()
" Some file types should wrap their text
function! s:setupWrapping()
set wrap
set linebreak
set textwidth=80
set nolist
setl spell
if exists('+colorcolumn')
setl colorcolumn=80 " Color the 80th column differently
endif
endfunction
" ----------------------------------------
" Auto Commands
" ----------------------------------------
if has("autocmd")
" In Makefiles, use real tabs, not tabs expanded to spaces
au FileType make setlocal noexpandtab
" Make sure all mardown files have the correct filetype set and setup wrapping
au BufRead,BufNewFile *.txt,*.md,*.markdown,*.mdown,*.mkd,*.mkdn,*.txt setf markdown | call s:setupWrapping()
" Enable wrapping for asciidoc(tor) files
au BufRead,BufNewFile *.adoc call s:setupWrapping()
" GoLag settings
autocmd FileType go setlocal noexpandtab shiftwidth=2 tabstop=2 softtabstop=2 nolist
" No formatting on o key newlines
autocmd BufNewFile,BufEnter * set formatoptions-=o
" No more complaining about untitled documents
autocmd FocusLost silent! :wa
" Remember last location in file, but not for commit messages.
" see :help last-position-jump
au BufReadPost * if &filetype !~ '^git\c' && line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal! g`\"" | endif
" Fix trailing whitespace in my most used programming langauges
autocmd BufWritePre *.c,*.cpp,*.h,*.m,*.mm,*.swift,*.java,*.go,*.py,*.js,*.rb,*.scss,*.less: silent! :StripTrailingWhitespaces
" If the only cmdline argument is a directory, change into it at start
autocmd VimEnter * if argc() == 1 && isdirectory(argv(0)) | exe "silent! cd ".argv(0)."|Explore" | endif
endif
" ----------------------------------------
" General Key mappings
" ----------------------------------------
let mapleader=","
noremap \ ,
" use jk to exit insert mode
inoremap jk <Esc>
" Map the arrow keys to be based on display lines, not physical lines
map <Down> gj
map <Up> gk
" buffer next/previous
nnoremap <silent> <leader>< :bp<CR>
nnoremap <silent> <leader>> :bn<CR>
" meta-opt- left/right for tab movement
nnoremap <silent> <D-A-Left> gT
inoremap <silent> <D-A-Left> <esc>gT
nnoremap <silent> <D-A-Right> gt
inoremap <silent> <D-A-Right> <esc>gt
" meta j/k for tab movement
nnoremap <silent> <D-j> gT
inoremap <silent> <D-j> <esc>gT
nnoremap <silent> <D-k> gt
inoremap <silent> <D-k> <esc>gt
" Create window splits easier. The default
" way is Ctrl-w,v and Ctrl-w,s. I remap
" this to vv and ss
nnoremap <silent> vv <C-w>v
nnoremap <silent> ss <C-w>s
" Easy close windows with Q
nnoremap <silent> Q <C-w>c
nnoremap <leader>w :StripTrailingWhitespaces<CR>
" reindent complete file without losing position
nnoremap <leader>f mqHmwgg=G`wzt`q
"Clear current search highlight by double tapping //
nnoremap <silent> // :nohlsearch<CR>
" Bubble single lines
nmap <C-Up> [e
nmap <C-Down> ]e
nmap <C-k> [e
nmap <C-j> ]e
" Bubble multiple lines
vmap <C-Up> [egv
vmap <C-Down> ]egv
vmap <C-k> [egv
vmap <C-j> ]egv
" Zoom Window to Full Size
nnoremap <silent> <leader>z :ZoomWin<CR>
"---------------
" External plugin config
"---------------
exe 'source ~/.vim/plugins.vim'
"---------------
" Local config
"---------------
" Use local vimrc if available
if filereadable(expand("~/.vimrc.local"))
source ~/.vimrc.local
endif
" Use local gvimrc if available and gui is running
if has('gui_running')
if filereadable(expand("~/.gvimrc.local"))
source ~/.gvimrc.local
endif
endif