-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
312 lines (258 loc) · 7.08 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
execute pathogen#infect()
" targets.vim
" vader.vim
" vim-after-object
" vim-bufkill
" vim-commentary
" vim-easyalign
" vim-exchange
" vim-flame
" vim-matchup
" vim-peekaboo
" vim-qf
" vim-repeat
" vim-slime
" vim-surround
" vim-tradewinds
" vim-usnip
" vimagit
" general settings {{{
filetype plugin indent on
syntax on
colorscheme colours
set background=light
set encoding=utf-8
set tabstop=8
set shiftwidth=4
set smarttab
set expandtab
set autoindent
set ttimeout
set ttimeoutlen=10
set backspace=indent,eol,start
set formatoptions+=j
set nojoinspaces
set incsearch
set hlsearch
set noshowmode
set laststatus=2
set display+=lastline
set scrolloff=1
set fillchars=vert:\ ,fold:-
set foldmethod=marker
set numberwidth=5
set relativenumber
set hidden
set sessionoptions-=options
set history=512
set tabpagemax=16
set wildmenu
" runtime macros/matchit.vim
let mapleader = ' '
let maplocalleader = ' '
let g:tex_flavor = "latex"
" }}}
" key bindings {{{
nnoremap <silent> <C-j> :move +1<CR>
nnoremap <silent> <C-k> :move -2<CR>
nnoremap <silent> <C-l> :nohlsearch<C-r>=has('diff')
\ ?'<Bar>diffupdate':''<CR><CR><C-l>
nnoremap <silent> @R :set operatorfunc=util#repeat<CR>g@
nnoremap ]b :bnext<CR>
nnoremap [b :bprev<CR>
nnoremap ]t :tabn<CR>
nnoremap [t :tabp<CR>
nnoremap <silent> gb :<C-u>call util#break()<CR>
nnoremap gp p`[
nnoremap gP P`[
nnoremap <silent> gw :let _s=@/ <Bar> :%s/\s\+$//e <Bar>
\ :let @/=_s <Bar> :nohl <Bar> :unlet _s<CR>
nnoremap Q @q
nnoremap Y y$
nnoremap <leader>e :e <C-r>=expand("%:p:h").'/'<CR>
nnoremap <leader>q :quit<CR>
nnoremap <leader>t :set relativenumber!<CR>
nnoremap <leader>u :update<CR>
nnoremap <leader>w <C-w>
nnoremap <leader>. :let @/=@"<CR>/<CR>cgn<C-r>.<Esc>
nnoremap <leader>/ :execute 'vimgrep /'.@/.'/g %'<CR>:copen<CR>
inoremap <C-u> <C-g>u<C-u>
xnoremap <silent> <C-j> :move '>+1<CR>gv
xnoremap <silent> <C-k> :move -2<CR>gv
xnoremap . :normal .<CR>
xnoremap @ :<C-u>call util#repeat()<CR>
vnoremap <silent> *
\ :<C-u>
\ let old_reg=getreg('"')<Bar>
\ let old_regtype=getregtype('"')<CR>
\ gvy/<C-r><C-r>=substitute(
\ escape(@", '/\.*$^~['), '\_s\+', '\\_s\\+', 'g')<CR><CR>
\ gV
\ :call setreg('"', old_reg, old_regtype)<CR>
vnoremap <silent> #
\ :<C-u>
\ let old_reg=getreg('"')<Bar>
\ let old_regtype=getregtype('"')<CR>
\ gvy?<C-r><C-r>=substitute(
\ escape(@", '?\.*$^~['), '\_s\+', '\\_s\\+', 'g')<CR><CR>
\ gV
\ :call setreg('"', old_reg, old_regtype)<CR>
cnoremap <C-a> <Home>
" }}}
" commands {{{
command! -bar -range=% Reverse <line1>,<line2>g/^/m<line1>-1 | nohl
command! -nargs=0 Lint :silent call util#togglelint()
command! -nargs=1 Count execute printf('%%s/%s//gn', escape(<q-args>, '/'))
\ | normal! ``
command! -nargs=* -complete=file Make
\ :silent call async#run(&makeprg, <f-args>)
command! -nargs=0 Stop
\ :silent call async#stop(<f-args>)
" }}}
" autocommands {{{
augroup guess
autocmd!
autocmd StdinReadPost,FilterReadPost,FileReadPost,BufReadPost
\ * call start#guess()
augroup END
augroup makefile
autocmd!
autocmd FileType * call util#makefile()
augroup END
augroup lint
autocmd!
autocmd BufWritePost *.S,*.c,*.cpp Make
augroup END
augroup git
autocmd!
autocmd BufNewFile,BufReadPost * call git#detect(expand('<amatch>:p:h'))
autocmd BufEnter * call git#detect(expand('%:p:h'))
augroup END
augroup status
autocmd!
autocmd VimEnter,WinEnter,BufEnter * call status#refresh()
augroup END
" }}}
" text objects {{{
" cancel object {{{
noremap <Plug>(EmptyObject) <Nop>
inoremap <expr> <Plug>(EmptyObject) exists('#emptyobj')?"\<Esc>":''
" }}}
" buffer object {{{
xnoremap i% GoggV
onoremap i% :normal vi%<CR>
" }}}
" fold object {{{
xnoremap iz :<C-u>silent! normal! [zV]z<CR>
onoremap iz :normal viz<CR>
" }}}
" indent object {{{
xnoremap ii :<C-u>call textobj#indent(0)<CR>
onoremap ii :<C-u>call textobj#indent(0)<CR>
xnoremap ai :<C-u>call textobj#indent(1)<CR>
onoremap ai :<C-u>call textobj#indent(1)<CR>
" }}}
" comment object {{{
xmap <silent> ic :<C-u>call textobj#comment(1)<CR><Plug>(EmptyObject)
omap <silent> ic :<C-u>call textobj#comment(0)<CR><Plug>(EmptyObject)
" }}}
" line object {{{
xnoremap il g_o^
onoremap il :normal vil<CR>
xnoremap al $o0
onoremap al :normal val<CR>
" }}}
" path object {{{
xnoremap <silent> if
\ :<C-u>
\ let pr='\(\/\([0-9a-zA-Z_\-\.]\+\)\)\+' <Bar>
\ let l=line('.') <Bar>
\ let epos = searchpos(pr, 'ceW', l) <Bar>
\ if epos == [0, 0] <Bar>
\ let epos = searchpos(pr, 'bceW', l) <Bar>
\ endif <Bar>
\ let spos = searchpos('\f\+', 'bcW', l) <Bar>
\ call textobj#select(spos, epos)<CR>
onoremap <silent> if :normal vif<CR>
" }}}
" search pattern object {{{
xnoremap <silent> i/
\ :<C-u>
\ let spos = searchpos(@\, 'c') <Bar>
\ let epos = searchpos(@\, 'ce') <Bar>
\ :call textobj#select(spos, epos)<CR>
onoremap <silent> i/ :normal vi/<CR>
xnoremap <silent> i?
\ :<C-u>
\ let spos = searchpos(@\, 'bc') <Bar>
\ let epos = searchpos(@\, 'ce') <Bar>
\ :call textobj#select(spos, epos)<CR>
onoremap <silent> i? :normal vi?<CR>
" }}}
" }}}
" highlight groups {{{
highlight! User1 ctermfg=7 ctermbg=6 cterm=bold
highlight! User2 ctermfg=7 ctermbg=3 cterm=bold
highlight! User3 ctermfg=7 ctermbg=1 cterm=bold
highlight! User4 ctermfg=7 ctermbg=2 cterm=bold
highlight! User5 ctermfg=7 ctermbg=5 cterm=bold
highlight! User6 ctermfg=7 ctermbg=8
highlight! User7 ctermfg=7 ctermbg=9
highlight! LineNr ctermfg=12 ctermbg=8
" }}}
" plugin settings {{{
" after-object {{{
autocmd VimEnter * call after_object#enable(['[', ']'],
\ '!', '#', '%', '*', '-', '=', ':', ';', ',', '?', '/')
" }}}
" easyalign {{{
xmap ga <Plug>(EasyAlign)
nmap ga <Plug>(EasyAlign)
" }}}
" exchange {{{
vmap x <Plug>(Exchange)
" }}}
" flame {{{
nmap gl <Plug>(FlameLine)
nmap gL <Plug>(FlameToggle)
" }}}
" magit {{{
let g:magit_show_magit_mapping = '<leader>m'
let g:magit_stage_hunk_mapping = 's'
let g:magit_commit_mapping = 'cm'
let g:magit_commit_amend_mapping = 'ca'
let g:magit_commit_fixup_mapping = 'cf'
let g:magit_close_commit_mapping = 'cq'
let g:magit_ignore_mapping = "<Nop>"
let g:magit_jump_next_hunk = 'n'
let g:magit_jump_prev_hunk = 'N'
let g:magit_git_cmd = 'git'
" }}}
" matchup {{{
let g:matchup_matchparen_offscreen = {'method': 'popup'}
let g:matchup_motion_cursor_end = 0
let g:matchup_motion_override_Npercent = 0
nnoremap <leader>n :<C-u>MatchupWhereAmI??<CR>
highlight! MatchParen ctermfg=13 ctermbg=224 cterm=italic
highlight! MatchWord ctermfg=13 ctermbg=224 cterm=italic
highlight! Pmenu ctermfg=13 ctermbg=224 cterm=italic
" }}}
" peekaboo {{{
let g:peekaboo_window = 'vert bo 40new'
" }}}
" qf {{{
nmap ]c <Plug>(qf_qf_next)
nmap [c <Plug>(qf_qf_previous)
nmap ]l <Plug>(qf_loc_next)
nmap [l <Plug>(qf_loc_previous)
" }}}
" slime {{{
let g:slime_target = "kitty"
let g:slime_no_mappings = 1
xmap <leader>s <Plug>SlimeRegionSend
nmap <leader>s <Plug>SlimeParagraphSend
" }}}
" targets {{{
let g:targets_nl = 'nN'
" }}}
" }}}