-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvimrc
378 lines (301 loc) · 12.2 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
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
" -----------------------------------------------------------------------------
" Vundle setup
" -----------------------------------------------------------------------------
" IMPORTANT CAVEAT
" Oreder matters! Make sure that:
" * vim-sensible is the latest bundle on the list
" * syntastic bundle has been put before vim-signify
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" Let Vundle manage Vundle
Plugin 'VundleVim/Vundle.vim'
" vim look & feel plugins
Plugin 'tomasr/molokai'
Plugin 'ayu-theme/ayu-vim'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
" Text editing helper plugins
" -------------------------
" Text object support (prerequisite for vim-textobj-rubyblock)
Plugin 'kana/vim-textobj-user'
" Improved dot key
Plugin 'tpope/vim-repeat'
" Smart surroundings (brackets, quotes, etc)
Plugin 'tpope/vim-surround'
" Useful mapping pairs
Plugin 'tpope/vim-unimpaired'
" Visual search improvements
Plugin 'nelstrom/vim-visual-star-search'
" Smart tab completion
Plugin 'ervandew/supertab'
" Wisely add 'end' in Ruby/BASH/etc
Plugin 'tpope/vim-endwise'
" Text alignment
Plugin 'godlygeek/tabular'
" Text folding improvments
Plugin 'HarnoRanaivo/vim-neatfoldtext'
" Comment plugin
Plugin 'tpope/vim-commentary'
" Really cool and useful file finder
Plugin 'kien/ctrlp.vim'
" Shell/OS integration plugins
Plugin 'tpope/vim-dispatch'
" better ack, C vs Perl
if executable('ag')
Plugin 'rking/ag.vim'
endif
" Show differences for recovered files
Plugin 'chrisbra/Recover.vim'
" Snipmate & dependecies + snippets
Plugin 'MarcWeber/vim-addon-mw-utils'
Plugin 'tomtom/tlib_vim'
Plugin 'garbas/vim-snipmate'
Plugin 'honza/vim-snippets'
" Faster YAML processing
" Plugin 'avakhov/vim-yaml'
Plugin 'ingydotnet/yaml-vim'
" Ruby block selection
Plugin 'nelstrom/vim-textobj-rubyblock'
" Generic Ruby helpers for vim users
Plugin 'vim-ruby/vim-ruby'
" Chef plugin
Plugin 'dougireton/vim-chef'
" JSON plugin
Plugin 'elzr/vim-json'
" Markdown plugin
Plugin 'tpope/vim-markdown'
" Syntax checker
Plugin 'scrooloose/syntastic'
" Syntax, indent and filetype detection for Git files
Plugin 'tpope/vim-git'
" Git wrapper for vim
Plugin 'tpope/vim-fugitive'
" Git repository viewer for vim
Plugin 'gregsexton/gitv'
" Show a VCS diff using Vim's sign column
Plugin 'mhinz/vim-signify'
" Nice tree explorer for vim
Plugin 'scrooloose/nerdtree'
" Auto-completion for quotes, brackets, etc.
Plugin 'Raimondi/delimitMate'
" VCL syntax highlightning
Plugin 'smerrill/vcl-vim-plugin'
" Better whitespace highlighting
Plugin 'ntpeters/vim-better-whitespace'
" Go support
Plugin 'fatih/vim-go'
" Display indent levels in code
" Plugin 'nathanaelkane/vim-indent-guides'
" Plugin 'Yggdroot/indentLine'
" HashiCorp tools
Plugin 'hashivim/vim-consul'
Plugin 'hashivim/vim-packer'
Plugin 'hashivim/vim-terraform'
Plugin 'hashivim/vim-vagrant'
" Vim alignment plugin
Plugin 'junegunn/vim-easy-align'
" A plugin to color colornames and codes
Plugin 'chrisbra/Colorizer'
" Vim defaults everyone can agree
"
" WARNING - this bundle should be included as the last one
"
" * enables syntax
" * turns on file decetions
" * status bar (powerline)
if !has('nvim')
Plugin 'tpope/vim-sensible'
end
" A collection of language packs for Vim
" Plugin 'sheerun/vim-polyglot'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" -----------------------------------------------------------------------------
" moving around, searching and patterns
" -----------------------------------------------------------------------------
set nostartofline " keep cursor in same column for long-range motion cmds
set hlsearch " highlight all matches for the last used search pattern
set incsearch " show match for partly typed search command
set ignorecase " ignore case when using a search pattern
set smartcase " override 'ignorecase' if pattern has upper case characters
set autochdir " automatically change window's cwd to file's dir
" -----------------------------------------------------------------------------
" displaying text
" -----------------------------------------------------------------------------
set scrolloff=3 " number of screen lines to show around the cursor
set linebreak " for lines longer than the window, wrap intelligently
" set showbreak=↪\ \ " string to put before wrapped screen lines
set sidescrolloff=2 " min # of columns to keep left/right of cursor
set number " always display line numbers
" -----------------------------------------------------------------------------
" syntax, highlighting and spelling
" -----------------------------------------------------------------------------
syntax on
set background=dark
set t_Co=256
set cursorline " Highlight current line
set cc=81 " Draw 81 column line
set termguicolors
let ayucolor="dark"
colorscheme ayu
" -----------------------------------------------------------------------------
" multiple windows
" -----------------------------------------------------------------------------
" Window split shourtcuts
map <Leader>h :sp<CR>
map <Leader>v :vsp<CR>
" Moving between windows
map <c-j> <c-w>j
map <c-k> <c-w>k
map <c-l> <c-w>l
" Ctrl-H doesn't work in NeoVim by default, see:
" https://github.com/neovim/neovim/issues/2048#issuecomment-98307896
map <c-h> <c-w>h
" -----------------------------------------------------------------------------
" multiple tab pages
" -----------------------------------------------------------------------------
" -----------------------------------------------------------------------------
" terminal
" -----------------------------------------------------------------------------
set ttyfast
" -----------------------------------------------------------------------------
" using the mouse
" -----------------------------------------------------------------------------
" -----------------------------------------------------------------------------
" printing
" -----------------------------------------------------------------------------
" -----------------------------------------------------------------------------
" messages and info
" -----------------------------------------------------------------------------
set noshowmode " don't display the current mode (Insert, Visual, Replace) in
" the status line. This info is already shown in the Airline
" status bar
" -----------------------------------------------------------------------------
" selecting text
" -----------------------------------------------------------------------------
" -----------------------------------------------------------------------------
" editing text
" -----------------------------------------------------------------------------
set nojoinspaces " Use only one space after '.' when joining lines,
" instead of two
set completeopt+=longest " better omni-complete menu
set nrformats-=octal " don't treat numbers with leading zeros as octal
" when incrementing/decrementing
" -----------------------------------------------------------------------------
" tabs and indenting
" -----------------------------------------------------------------------------
set tabstop=4 " tab = 4 spaces
set softtabstop=4 " remove 4 spaces when removing indentation
set shiftwidth=4 " autoindent indents 4 spaces
set shiftround " round to 'shiftwidth' for "<<" and ">>"
set expandtab " always use spaces instead of tab characters
" Make code indendation easier
vnoremap < <gv
vnoremap > >gv
" -----------------------------------------------------------------------------
" folding
" -----------------------------------------------------------------------------
if has('folding')
set nofoldenable " when opening files, all folds open by default
set foldtext=NeatFoldText() " use a custom foldtext function
endif
" -----------------------------------------------------------------------------
" diff mode
" -----------------------------------------------------------------------------
set diffopt+=vertical " start diff mode with vertical splits by default
" -----------------------------------------------------------------------------
" mapping
" -----------------------------------------------------------------------------
" -----------------------------------------------------------------------------
" reading and writing files
" -----------------------------------------------------------------------------
set modeline " make vim annotations useful
set autoread " automatically re-read files changed outside of vim
" Organize swap and backup files
set nobackup
set noswapfile
" -----------------------------------------------------------------------------
" the swap file
" -----------------------------------------------------------------------------
" -----------------------------------------------------------------------------
" command line editing
" -----------------------------------------------------------------------------
set history=1000 " save more commands in history
set wildmode=list:longest,full " command line completion mode
set wildmenu " enable command line completion
" -----------------------------------------------------------------------------
" executing external commands
" -----------------------------------------------------------------------------
" -----------------------------------------------------------------------------
" running make and jumping to errors
" -----------------------------------------------------------------------------
" -----------------------------------------------------------------------------
" language specific
" -----------------------------------------------------------------------------
" -----------------------------------------------------------------------------
" multi-byte characters
" -----------------------------------------------------------------------------
set encoding=utf8
" -----------------------------------------------------------------------------
" misc
" -----------------------------------------------------------------------------
" scrolling fix in iterm2
set mouse=nicr
" https://stackoverflow.com/a/16114535/6802186
set nofixendofline
" toogle NerdTree
map <F2> :NERDTreeToggle<CR>
" toogle paste-mode
set pastetoggle=<F3>
" remove higligth from vim
noremap <C-n> :nohl<CR>
vnoremap <C-n> :nohl<CR>
inoremap <C-n> :nohl<CR>
" use <leader>l to toggle display of whitespace
nmap <leader>l :set list!<CR>
" replace default characters with a nicer one
set listchars=tab:»\ ,eol:¬
" Fix for non-visible end line characters in ayu theme
"
" https://github.com/ayu-theme/ayu-vim/issues/18
hi NonText ctermfg=7 guifg=gray
" map sort function to a key
vnoremap <Leader>s :sort<CR>
" remove trailing whitespaces shourtcat
nnoremap <silent> <F5> :call Preserve("%s/\\s\\+$//e")<CR>
" convert spaces to tabs
map <Leader>t :set noexpandtab<CR>:%retab!<CR>
" sudo write
cmap w!! w !sudo tee > /dev/null %
" ruby autocompletion
inoremap <C-@> <c-x><c-o>
" disable f1
nmap <F1> <nop>
" Disable python & ruby providers
let g:loaded_python_provider = 1
let g:loaded_python3_provider = 1
let g:loaded_ruby_provider = 1
" -----------------------------------------------------------------------------
" autocmds
" -----------------------------------------------------------------------------
" set correct indentation level
autocmd Filetype ruby,eruby,yaml setlocal ts=2 sts=2 sw=2
autocmd Filetype terraform setlocal ts=2 sts=2 sw=2
" get rid of whitespaces on save from specified files
autocmd BufWritePre *.py,*.rb,*.erb,*.json :call Preserve("%s/\\s\\+$//e")
" autoformat specified files on save
autocmd BufWritePre *.json :call Preserve("normal gg=G")
" disable paste mode when leaving Insert Mode
autocmd InsertLeave * set nopaste
" Align GitHub-flavored Markdown tables
au FileType markdown vmap <Leader><Bslash> :EasyAlign*<Bar><Enter>
" Increase max number of charactes in each line for Markdown files
au FileType markdown setlocal textwidth=120 colorcolumn=+1
" Limit syntax highlighting for ruby files
" autocmd FileType ruby,ruby.chef,eruby,eruby.chef set synmaxcol=80
" Jenkinsfiles
au BufReadPost Jenkinsfile set syntax=groovy