-
Notifications
You must be signed in to change notification settings - Fork 2
/
.vimrc
342 lines (290 loc) · 8.54 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
"
" /\ \__
" ___ ___ __ \ \ ,_\ ____ __
" /' __` __`\ /'__`\ \ \ \/ /\_ ,`\ /'__`\
" /\ \/\ \/\ \/\ \L\.\_\ \ \_\/_/ /_/\ __/
" \ \_\ \_\ \_\ \__/.\_\\ \__\ /\____\ \____\
" \/_/\/_/\/_/\/__/\/_/ \/__/ \/____/\/____/
"
" Author: matthias.vogelgesang[at]gmail[dot]com
" Blog: http://bloerg.net
"
"{{{ Settings
" General
" set showmatch " Show matching parentheses
set nocompatible " Disable vi compatibility
set modeline " Enable modeline
set noshowcmd
set nocursorline " Do not highlight cursor line
set nocursorcolumn " Do not highlight current cursor column
set ruler " Show cursor position
set laststatus=2 " Show status line
set noerrorbells " No beeps
set history=1000 " Maximum history
set wildmenu " Tab completion
set wildignore+=*/.git/*,*/.bzr/*,*~,*/build/*,*.pyc
set hidden " Allow buffers to be hidden
set scrolloff=2 " At least two lines and ...
set sidescrolloff=2 " two columns context
set mouse=a " Mouse support
set ttyfast
set ttimeoutlen=0 " Timeout for keycodes, esp. <Esc>
set dir=~/.vim " Location for .swp files
let mapleader = "\<Space>"
" Searching
set ignorecase " Case insensitive search
set smartcase " Ignore ignorecase
set hlsearch " Show search results
set wrapscan " Continue search at the top
set incsearch " Incremental search
" Textformatting, indenting, tabs
set textwidth=80 " Yay, history!
set autoindent " ...
set smartindent " ...
set tabstop=4 " Number of spaces per tab
set shiftwidth=4 " Default number of spaces for >> and <<
set softtabstop=4 " Number of spaces per tab
set expandtab " Spaces instead of tabs
set smarttab " Add/remove spaces instead of tabs
set linebreak " Break lines nicer
set number " Show line numbers
set listchars=tab:»\ ,trail:·,eol:¬
set fillchars=fold:·
set backspace=indent,eol,start
" Highlighting, colors, fonts
set t_Co=256
syntax enable
if has("gui_running")
set lines=60 " More lines ...
set columns=120 " and columns in GUI mode
set gfn=Monospace\ 9
set guioptions-=m
set guioptions-=T
set guioptions-=l
set guioptions-=L
set guioptions-=r
set guioptions-=R
set guioptions-=b
endif
" Folding
set foldenable
set foldmethod=marker
" Omni completion
set omnifunc=syntaxcomplete#Complete
set completeopt=menu
" Makeprg
set makeprg=wrapped-make
"}}}
"{{{ Plugins
call plug#begin('~/.vim/plugged')
Plug 'ekalinin/Dockerfile.vim' "{{{
"}}}
Plug 'itchyny/lightline.vim' "{{{
let g:lightline = {
\ 'colorscheme': 'jellybeans',
\ 'component': {
\ 'readonly': '%{&readonly?"✖":""}',
\ },
\ 'active': {
\ 'right': [['lineinfo'], ['percent']],
\ },
\ }
"}}}
Plug 'nanotech/jellybeans.vim' "{{{
"}}}
Plug 'justinmk/vim-sneak' "{{{
let g:sneak#streak = 1
hi link SneakPluginTarget Type
hi link SneakPluginScope Function
hi link SneakStreakTarget Type
hi link SneakStreakMask Function
nmap f <Plug>Sneak_f
nmap F <Plug>Sneak_F
xmap f <Plug>Sneak_f
xmap F <Plug>Sneak_F
omap f <Plug>Sneak_f
omap F <Plug>Sneak_F
"}}}
Plug 'junegunn/goyo.vim', { 'on': 'Goyo' } "{{{
"}}}
Plug 'kien/ctrlp.vim'"{{{
let g:ctrlp_switch_buffer = 0
let g:ctrlp_extensions = ['tag']
let g:ctrlp_user_command = {
\ 'types': {
\ 1: ['.git', 'cd %s && git ls-files . --cached --exclude-standard --others'],
\ 2: ['.hg', 'hg --cwd %s locate -I .'],
\ },
\ 'fallback': 'ag %s -l --nocolor -g ""'
\ }
"}}}
Plug 'ludovicchabant/vim-gutentags'"{{{
let g:gutentags_cache_dir = '/tmp'
"}}}
Plug 'matze/vim-golang', { 'for': 'go' } "{{{
"}}}
Plug 'matze/vim-lilypond'", { 'for': 'lilypond' } {{{
"}}}
Plug 'matze/vim-markdown'"{{{
let g:markdown_fold_override_foldtext = 0
"}}}
Plug 'matze/vim-move'"{{{
let g:move_map_keys = 0
vmap j <Plug>MoveBlockDown
vmap k <Plug>MoveBlockUp
nmap j <Plug>MoveLineDown
nmap k <Plug>MoveLineUp
"}}}
Plug 'matze/vim-tex-fold'", { 'for': 'tex' } {{{
let g:tex_fold_additional_envs = ['tikzpicture']
"}}}
Plug 'matze/vim-ini-fold'"{{{
"}}}
Plug 'mileszs/ack.vim'"{{{
let g:ackprg="ag --nogroup --nocolor --column"
"}}}
Plug 'nanotech/jellybeans.vim'"{{{
"}}}
Plug 'nvie/vim-flake8'", { 'for': 'python' } {{{
"}}}
Plug 'petRUShka/vim-opencl'", { 'for': 'opencl' } {{{
"}}}
Plug 'reedes/vim-wordy'"{{{
"}}}
Plug 'Shougo/neosnippet'"{{{
let g:neosnippet#snippets_directory='~/.vim/snippets'
imap <C-e> <Plug>(neosnippet_expand_or_jump)
smap <C-e> <Plug>(neosnippet_expand_or_jump)
"}}}
Plug 'Shougo/neosnippet-snippets'"{{{
"}}}
Plug 'spolu/dwm.vim'"{{{
let g:dwm_map_keys = 0
nmap <C-J> <C-W>w
nmap <C-K> <C-W>W
nmap <C-N> <Plug>DWMNew
nmap <C-X> <Plug>DWMClose
nmap <C-L> <Plug>DWMGrowMaster
nmap <C-H> <Plug>DWMShrinkMaster
nmap <C-E> <Plug>DWMFocus
"}}}
Plug 'tpope/vim-commentary'"{{{
autocmd FileType cmake set commentstring=#\ %s
"}}}
Plug 'tpope/vim-dispatch'"{{{
"}}}
Plug 'ajh17/Spacegray.vim'"{{{
"}}}
Plug 'wting/rust.vim'", { 'for': 'rust' } {{{
"}}}
Plug 'zah/nimrod.vim'"{{{
"}}}
"{{{ lua-only
if has('lua')
Plug 'Shougo/neocomplete' "{{{
let g:neocomplete#enable_at_startup = 1
let g:neocomplete#enable_smart_case = 1
let g:neocomplete#enable_auto_select = 1
let g:neocomplete#auto_completion_start_length = 3
let g:neocomplete#manual_completion_start_length = 3
let g:neocomplete#max_list = 20
let g:neocomplete#sources#syntax#min_keyword_length = 3
function! s:my_cr_function()
return neocomplete#close_popup() . "\<CR>"
endfunction
inoremap <silent><CR> <C-r>=<SID>my_cr_function()<CR>
nmap <Leader>nce :NeoCompleteEnable<CR>
nmap <Leader>ncd :NeoCompleteDisable<CR>
"}}}
else
Plug 'Shougo/neocomplcache' "{{{
let g:neocomplcache_enable_at_startup = 1
let g:neocomplcache_enable_smart_case = 1
let g:neocomplcache_enable_auto_select = 1
let g:neocomplcache_enable_camel_case_completion = 1
let g:neocomplcache_enable_underbar_completion = 1
let g:neocomplcache_auto_completion_start_length = 3
let g:neocomplcache_manual_completion_start_length = 3
let g:neocomplcache_min_syntax_length = 3
if !exists('g:neocomplcache_keyword_patterns')
let g:neocomplcache_keyword_patterns = {}
endif
let g:neocomplcache_keyword_patterns['default'] = '\h\w*'
function! s:my_cr_function()
return neocomplcache#smart_close_popup() . "\<CR>"
endfunction
inoremap <silent><CR> <C-r>=<SID>my_cr_function()<CR>
nmap <Leader>nce :NeoComplCacheEnable<CR>
nmap <Leader>ncd :NeoComplCacheDisable<CR>
"}}}
end
"}}}
call plug#end()
silent! colorscheme jellybeans
"}}}
"{{{ Functions
function! DefaultFoldText()
let foldline = getline(v:foldstart)
let line = substitute(foldline, '[^{]{{' . '{', '\1', '') . ' '
return '+-' . v:folddashes . line
endfunction
function! TagJumpBack()
try | foldclose! | catch | | endtry
pop
endfunction
function! TagJumpForward()
execute "tag " . expand("<cword>")
try | foldopen! | catch | | endtry
endfunction
set foldtext=DefaultFoldText()
"}}}
"{{{ Keymaps
" paste multiple lines without overwriting content
vnoremap <silent> p p`]
nnoremap <silent> p p`]
nnoremap <CR> za
nnoremap <silent> <C-i> :call TagJumpForward()<CR>
nnoremap <silent> <C-t> :call TagJumpBack()<CR>
" for some reason this is mapped to :call TagJumpForward
nnoremap <tab> <nop>
" select pasted text
noremap gV `[v`]
nnoremap <F5> <Esc>:w!<CR>:make!<CR><CR>
nnoremap <F6> <Esc>:w!<CR>:Make<CR><CR>
nnoremap <Right> :bn<CR>
nnoremap <Left> :bp<CR>
nnoremap <C-f> :Ack! <C-r><C-w><CR><CR>
nnoremap <C-b> :CtrlPTag<CR>
nnoremap cn <Esc>:cn<CR>
nnoremap cp <Esc>:cp<CR>
nnoremap <Leader>w :w!<CR>
nnoremap <Leader>h :silent noh<CR>
nmap <Leader>r1 yypVr=
nmap <Leader>r2 yypVr-
nmap <Leader>fw :%s/\s\+$//<CR>
nmap <Leader>se :setlocal spell spelllang=en<CR>
nmap <Leader>sd :setlocal spell spelllang=de<CR>
nmap <Leader>sn :setlocal nospell<CR>
nmap <Leader>ss 1z=
nmap <Leader>d :bd<CR>
vmap <Leader>y "+y
vmap <Leader>d "+d
vmap <Leader>p "+p
vmap <Leader>P "+P
nmap <Leader>p "+p
nmap <Leader>P "+P
" Tabs
nmap o :tabnew<CR>
nmap n :tabnext<CR>
nmap p :tabprevious<CR>
"}}}
"{{{ Autocmds
" Allow using <CR> on quickfix entries
autocmd BufReadPost quickfix nnoremap <buffer> <CR> <CR>
" Show quickfix after :make, taken from
" http://vim.wikia.com/wiki/Automatically_open_the_quickfix_window_on_:make
autocmd QuickFixCmdPost [^l]* nested cwindow
autocmd QuickFixCmdPost l* nested lwindow
" Reset fold background to reduce distraction
autocmd VimEnter * hi Folded ctermbg=None
"}}}