-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
390 lines (297 loc) · 10.3 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
379
380
381
382
383
384
385
386
387
388
389
390
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" .vimrc | Christoph Schorn
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Detect OS
let s:is_win = has('win16') || has('win32')
" GUI running
let s:gui = has('gui_running')
" Start maximized
if s:gui
" GUI is running or is about to start.
if s:is_win
" Use ~x on an English Windows version or ~n for French.
au GUIEnter * simalt ~x
else
set lines=999 columns=999
endif
endif
" Save vimfiles path
let s:vimfiles = s:is_win ? '$HOME/vimfiles' : '$HOME/.vim'
" Local vimrc path
let s:localvimrc = $HOME . "/" . (s:is_win ? "_" : ".") . "vimrc.local"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" Plugins
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Using plug.vim
call plug#begin(s:vimfiles.'/plugged')
Plug 'ctrlpvim/ctrlp.vim' " fuzzy file opening
Plug 'gabrielelana/vim-markdown'
if s:gui
Plug 'Yggdroot/indentLine' " show indent line
endif
Plug 'scrooloose/nerdtree' " folder view
Plug 'scrooloose/syntastic' " syntax checking
Plug 'sjl/gundo.vim' " change history tracking
Plug 'tpope/vim-fugitive' " git in vim
Plug 'tpope/vim-surround'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'vim-python/python-syntax' " advanced python highlighting
"Plug 'ajh17/VimCompletesMe'
Plug 'vim-scripts/AutoComplPop' " opens completion popup while typing
Plug 'qpkorr/vim-bufkill' " allows to close buffer without closing window/split
if has('python') || has('python3')
" Might fail to install, visit their README if it does
" Use the python launcher on windows
" Kind of a heavy plugin, but very IDE-like completion
" Plug 'Valloric/YouCompleteMe', { 'do': (s:is_win ? 'py ' : './') . 'install.py' }
endif
" I like colorschemes
Plug 'altercation/vim-colors-solarized'
Plug 'tomasr/molokai'
Plug 'morhetz/gruvbox'
Plug 'w0ng/vim-hybrid'
Plug 'jordwalke/flatlandia'
Plug 'sjl/badwolf'
Plug 'rakr/vim-one'
Plug 'jnurmine/Zenburn'
Plug 'notpratheek/vim-luna'
"Plug 'vim-scripts/SlateDark'
"Plug 'miyakogi/slateblue.vim'
"Plug 'cocopon/iceberg.vim'
"Plug 'nightsense/vimspectr'
"Plug 'Badacadabra/vim-archery'
"Plug 'zsoltf/vim-maui'
"Plug 'reedes/vim-colors-pencil'
"Plug 'nanotech/jellybeans.vim'
"Plug 'mhartington/oceanic-next'
"Plug 'limadm/vim-blues'
"Plug 'NLKNguyen/papercolor-theme'
"Plug 'chriskempson/base16-vim'
"Plug 'xolox/vim-misc' | Plug 'xolox/vim-colorscheme-switcher'
call plug#end()
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" General
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Sets how many lines of history VIM has to remember
set history=500
" Enable filetype plugins
filetype plugin on
filetype indent on
" Set to auto read when a file is changed from the outside
set autoread
" Set utf8 as standard encoding
set encoding=utf-8
" Allow hiding of modified buffers
set hidden
" Turn backup off, since most stuff is in SVN, git et.c anyway...
set nobackup
set nowb
set noswapfile
" Always keep top/bottom of file x lines away from the cursor
set scrolloff=8
" Turn on the Wild menu (suggestions for command line autocomplete)
set wildmenu
" Ignore compiled files
set wildignore=*.o,*~,*.pyc,*.git,*.hg,*.svn
" Always show current position
set ruler
" Height of the command bar
set cmdheight=2
" Configure backspace so it acts as it should act
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
" Ignore case when searching
set ignorecase
" When 'ignorecase' and 'smartcase' are both on, if a pattern contains an uppercase letter, it is case sensitive
set smartcase
" Highlight search results
set hlsearch
" Makes search act like search in modern browsers
set incsearch
" Don't redraw while executing macros (good performance config)
"set lazyredraw " might cause vim to exit with non-zero codes
" For regular expressions turn magic on
set magic
" Show matching brackets when text indicator is over them
set showmatch
" How many tenths of a second to blink when matching brackets
set mat=2
" No annoying sound on errors
set noerrorbells visualbell t_vb=
autocmd GUIEnter * set visualbell t_vb=
" Add extra margin to the left
set foldcolumn=0
" Show line numbers
set number
"set relativenumber
" show command in bottom bar
set showcmd
" highlight current line
if s:gui
set cursorline
endif
" Always show the status line
set laststatus=2
" Don't just delete the thing instantly when 'c<motion>'
set cpoptions+=$
" Make clipboard behave like a normal program
set clipboard=unnamed
" Show a highlighted column
if s:gui
set colorcolumn=80
endif
" Don't hide quotation marks (e.g. in json files)
set conceallevel=0
" Add spellfiles
if s:gui
set spell
endif
set spelllang=en,de
execute ':set spellfile=' . s:vimfiles . '/spell/words.utf-8.add'
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" Text, tab and indent related
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Use spaces instead of tabs
set expandtab
" Be smart when using tabs
set smarttab
" 1 tab == 4 spaces
set shiftwidth=4
set tabstop=4
" Smart indents on new line
set autoindent
set smartindent
" Wrap line if longer than window with, and only break whole words
set wrap linebreak nolist
" Show whitespace
set list
set listchars=tab:\ \ ,trail:·
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" Colors & Fonts
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Enable syntax highlighting
syntax enable
" Set gui/non-gui options
if s:gui
" colorscheme
set background=dark
silent! colorscheme solarized
let g:airline_theme='solarized'
call togglebg#map("<F9>")
" gui options
set guioptions-=T "remove toolbar
" set guioptions-=e "remove tab pages
set guioptions-=m "remove menu bar
set guioptions-=r "remove right-hand scroll bar
set guioptions-=L "remove left-hand scroll bar
set t_Co=256
set guitablabel=%M\ %t
set guifont=Hack:h10,Consolas:h11
" Better font rendering
if has('directx') && s:is_win
set renderoptions=type:directx,gamma:1.2,contrast:1,level:0.75,geom:1,renmode:5,taamode:1
endif
else " no gui
set background=dark
silent! colorscheme default
let g:solarized_termtrans=1
let g:airline_theme='dark'
"set term=xterm
"set t_Co=88
"let &t_AB="\e[48;5;%dm"
"let &t_AF="\e[38;5;%dm"
endif
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" Key mappings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Use jk/kj to exit insert mode, use it like a single keystroke!
inoremap jk <Esc>
inoremap kj <ESC>
" With a map leader it's possible to do extra key combinations
" like <leader>w saves the current file
let mapleader = ","
let g:mapleader = ","
" Fast saving
nmap <leader>w :w<cr>
" Edit vimrc file
nmap <silent> <leader>ev :e $MYVIMRC<CR>
nmap <silent> <leader>sv :so $MYVIMRC<CR>
execute "nmap <silent> <leader>elv :e " . s:localvimrc . "<CR>"
execute "nmap <silent> <leader>slv :so " . s:localvimrc . "<CR>"
" Turn off highlight search markings
nmap <silent> <leader>n :nohls<CR>
" Go to current file's directory
nmap <silent> <leader>cd :cd %:p:h<CR>
nmap <silent> <leader>cdw :lcd %:p:h<CR> "Only for current window
" Paste from "+ register (copy from external windows)
nmap <silent> <leader>pe :normal "+p<CR>
" Toggle indent lines
nmap <silent> <leader>il :IndentLinesToggle<CR>
" Close buffer but not split/window
nmap <leader>bd :BD<CR>
" Move a line of text using ALT+[jk] or Command+[jk] on mac
nmap <M-j> mz:m+<cr>`z
nmap <M-k> mz:m-2<cr>`z
vmap <M-j> :m'>+<cr>`<my`>mzgv`yo`z
vmap <M-k> :m'<-2<cr>`>my`<mzgv`yo`z
" Move between windows easier
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
" Toggle NERDTree
map <C-n> :NERDTreeToggle<CR>
" Toggle Gundo tree
nnoremap <F5> :GundoToggle<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" Filetype specific settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
autocmd Filetype yaml setlocal nospell autoindent sw=2 ts=2 expandtab
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" NERDTree settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if s:gui
let g:NERDTreeDirArrowExpandable = '▸'
let g:NERDTreeDirArrowCollapsible = '▾'
endif
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" airline settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if s:gui
let g:airline_powerline_fonts = 1
"let g:airline#extensions#whitespace#symbol = "\u2021" "Default symbol (12 pointed star) might not be available
endif
let g:airline#extensions#whitespace#enabled = 0 "Disable whitespace extension
let g:airline_skip_empty_sections = 1 "Do not draw separators for empty sections (only for the active window)
let g:airline#extensions#tabline#enabled = 1 "Shows a tab view
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" VimCompletesMe settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let b:vcm_tab_complete = ''
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" ctrlp settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:ctrlp_reuse_window = 'startify' "Allow to use the empty window when starting gvim without a file
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" indent guides settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:indentLine_char = '┊'
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" Gundo settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:gundo_prefer_python3 = 1 "Gundo tries to use Python 2.4+ *really* hard
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" Python syntax highlighting
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:python_highlight_all = 1
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" Set syntastic to passive mode
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:syntastic_mode_map = { 'mode': 'passive', 'active_filetypes': [],'passive_filetypes': [] }
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" Local system overwrites
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if filereadable(s:localvimrc)
execute "source " . s:localvimrc
endif