-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.vimrc
More file actions
271 lines (218 loc) · 8.23 KB
/
.vimrc
File metadata and controls
271 lines (218 loc) · 8.23 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
let mapleader="," " remap leader from \ to ,
let maplocalleader=","
"" Vundle and bundles configuration
source ~/.vim/bundles.vim
syntax enable
set encoding=utf-8
set showcmd " display incomplete commands
set noshowmode " never display the current mode; powerline does this
filetype plugin indent on " load file type plugins + indentations
set modelines=0 " don't read modelines
set nomodeline " disable modelines for security
set mouse=a " enable the mouse
set autoread " auto reload file if changed outside vim but not inside vim
set noerrorbells " disable error bells
set novisualbell " disable visual bells
set visualbell t_vb= " don't beep or flash at all
set lazyredraw " don't redraw screen during macro playback
"set t_Co=256 " use 256 colors in terminal
set background=dark
colorscheme base16-default
set guifont=Inconsolata\ for\ Powerline:h13
" Persistent undo
set undofile
set undolevels=1000
set undoreload=1000
" Centralize backups, swapfiles and undo history
set backupdir=~/.vim/backups
set directory=~/.vim/swaps
if exists("&undodir")
set undodir=~/.vim/undo
endif
"" Whitespace
set nowrap " don't wrap lines
set showbreak=↪ " if breaking lines, show this char at beginning of line
set tabstop=4 shiftwidth=4 " use four space tabs
set softtabstop=4 " backspace by four spaces
set shiftround " force indents to multiples of shiftwidth
set expandtab " use spaces not tabs
set backspace=indent,eol,start " backspace works on everything
set autoindent
set copyindent " copy the previous indentation when autoindenting
set list " show invisible chars
set listchars=tab:▸\ ,extends:❯,precedes:❮,trail:·
"" Searching
set path+=** " when using :find, search in subdirs too
set hlsearch " highlight matches
set incsearch " incremental searching
set ignorecase " case insensitive searching
set smartcase " case sensitive if search contains capitals
set gdefault " by default, apply substitutions globally
" Use normal regexes when searching
nnoremap / /\v
vnoremap / /\v
"" Editor interface
set textwidth=0
set number " show line numbers
set ruler " show line and column number of cursor
set cursorline " highlight the current line
set laststatus=2 " always show status line
set nrformats=hex " make <C-x> and <C-a> handle numbers with leadings 0s
set colorcolumn=81 " draw a line at 81 columns
set scrolloff=3 " cursor is always three lines from top/bottom edge of screen
set sidescroll=4 " scroll horizontally by four chars, at minimum
set sidescrolloff=8 " cursor is always eight lines from left/right edge of screen
set splitright " open vertical splits on the right
set splitbelow " open horizontal splits below
set wildmenu " show completions above command line
set wildmode=full " complete next full match
set wildignore+=*.o,*.d,*.class
set ttyfast " fast terminal connection
set pastetoggle=<F2> " <F2> enables paste mode, which disables autoindent
set nojoinspaces " when joining line, use one space after '.'
"" Key remappings
nnoremap ; :
"nnoremap : ;
" up/down works on logical lines, not real file lines
nnoremap j gj
nnoremap k gk
nnoremap <Down> gj
nnoremap <Up> gk
nnoremap gj j
nnoremap gk k
vnoremap j gj
vnoremap k gk
vnoremap <Down> gj
vnoremap <Up> gk
vnoremap gj j
vnoremap gk k
inoremap <Down> <C-o>gj
inoremap <Up> <C-o>gk
" Yank to end of line; parallels C and D
nnoremap Y y$
" Make 'a jump to line and col and `a jump to col
" This reverses the default behaviour
nnoremap ' `
nnoremap ` '
" Use Q for formatting current paragraph or selection
vnoremap Q gq
nnoremap Q gqap
" Easier window navigation
map <C-h> <C-w>h
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-l> <C-w>l
" Shortcuts for saving
nnoremap ;; :w<CR>
nnoremap <C-s> :w<CR>
inoremap <C-s> <ESC>:w<CR>a
" Keep visual block selected when changing indent
vmap > >gv
vmap < <gv
" Emacs-like beginning and end of line
imap <C-e> <C-o>$
imap <C-a> <C-o>^
nmap L $
nmap H ^
"" Mapleader - custom mappings
nnoremap <leader>t :tabnew<CR>
nnoremap <leader>q :q<CR>
"" Quickly edit/reload vimrc
nnoremap <silent> <leader>ev :e $MYVIMRC<CR>
nnoremap <silent> <leader>sv :so $MYVIMRC<CR>
" Strip all trailing whitespace
nnoremap <leader>W :%s/\s\+$//<cr>:let @/=''<CR>
" Yank/paste to OS clipboard
nnoremap <leader>y "*y
nnoremap <leader>Y "*yy
nnoremap <leader>p "*p
nnoremap <leader>P "*P
" Clear highlighted searches
nnoremap <silent> <leader>/ :nohlsearch<CR>
nnoremap <leader>n :call NumberToggle()<CR>
nnoremap <leader>u :GundoToggle<CR>
" CtrlP mappings
let g:ctrlp_map='<leader>f'
nnoremap <leader>b :CtrlPBuffer<CR>
nnoremap <leader>m :CtrlPMRU<CR>
nnoremap <leader>x :CtrlPMixed<CR>
" Syntastic mappings
nnoremap <leader>e :Errors<CR>
nnoremap <leader>s :SyntasticCheck<CR>
" Custom functions
" Toggle relative/absolute numbers
" http://jeffkreeftmeijer.com/2012/relative-line-numbers-in-vim-for-super-fast-movement/
function! NumberToggle()
if(&relativenumber == 1)
set number
else
set relativenumber
endif
endfunc
" In terminal vim, let ESC leave insert mode faster
" Side-effect of using Powerline
if ! has('gui_running')
set ttimeoutlen=10
augroup FastEscape
autocmd!
au InsertEnter * set timeoutlen=0
au InsertLeave * set timeoutlen=1000
augroup END
endif
"" Configure plugins
" vim-ruby
" Highlight Ruby operators
let ruby_operators=1
" Powerline
set runtimepath+=~/.vim/bundle/powerline/powerline/bindings/vim
" Fugitive
" Delete hidden Fugitive buffers
autocmd BufReadPost fugitive://* set bufhidden=delete
" Mapping for .. when browsing git objects
autocmd User fugitive
\ if fugitive#buffer().type() =~# '^\%(tree\|blob\)$' |
\ nnoremap <buffer> .. :edit %:h<CR> |
\ endif
" Syntastic
" Run a syntax check when loading a file
let g:syntastic_check_on_open=1
" Adjust the colours for errors and warnings
highlight SyntasticErrorSign guifg=white guibg=red
highlight SyntasticWarningSign guifg=white guibg=blue
" Change the Syntastic error/warning symbols
let g:syntastic_error_symbol='✘'
let g:syntastic_style_error_symbol='●'
let g:syntastic_warning_symbol='✘'
let g:syntastic_style_warning_symbol='●'
" Don't show tooltip errors
let g:syntastic_enable_ballons=0
" CtrlP
" Ignore files
let g:ctrlp_custom_ignore='\v\.(o|d|class)$'
" ## added by OPAM user-setup for vim / base ## 93ee63e278bdfc07d1139a748ed3fff2 ## you can edit, but keep this line
let s:opam_share_dir = system("opam config var share")
let s:opam_share_dir = substitute(s:opam_share_dir, '[\r\n]*$', '', '')
let s:opam_configuration = {}
function! OpamConfOcpIndent()
execute "set rtp^=" . s:opam_share_dir . "/ocp-indent/vim"
endfunction
let s:opam_configuration['ocp-indent'] = function('OpamConfOcpIndent')
function! OpamConfOcpIndex()
execute "set rtp+=" . s:opam_share_dir . "/ocp-index/vim"
endfunction
let s:opam_configuration['ocp-index'] = function('OpamConfOcpIndex')
function! OpamConfMerlin()
let l:dir = s:opam_share_dir . "/merlin/vim"
execute "set rtp+=" . l:dir
endfunction
let s:opam_configuration['merlin'] = function('OpamConfMerlin')
let s:opam_packages = ["ocp-indent", "ocp-index", "merlin"]
let s:opam_check_cmdline = ["opam list --installed --short --safe --color=never"] + s:opam_packages
let s:opam_available_tools = split(system(join(s:opam_check_cmdline)))
for tool in s:opam_packages
" Respect package order (merlin should be after ocp-index)
if count(s:opam_available_tools, tool) > 0
call s:opam_configuration[tool]()
endif
endfor
" ## end of OPAM user-setup addition for vim / base ## keep this line