-
Notifications
You must be signed in to change notification settings - Fork 2
/
vimrc
332 lines (272 loc) · 11.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
source ~/.config/nvim/init.vim
finish
if filereadable("~/.vim/bundle/neobundle.vim")
set runtimepath+=~/.vim/bundle/neobundle.vim/
call neobundle#begin(expand('~/.vim/bundle/'))
NeoBundleFetch 'Shougo/neobundle.vim'
" NeoBundle 'Shougo/vimproc', {'build': {'mac': 'make -f make_mac.mak'}}
" " TODO: get rid of vim-sensible
" NeoBundle 'tpope/vim-sensible' " sane general defaults
NeoBundle 'tpope/vim-repeat' " makes some plugins repeatable
NeoBundle 'tpope/vim-abolish' " I mostly use :S for smart replace
NeoBundle 'tpope/vim-fugitive' " git stuff, mostly :Gblame
NeoBundle 'tpope/vim-surround' " add and change braces and quotes
NeoBundle 'tpope/vim-unimpaired' " list navigation, option toggling
NeoBundle 'tpope/vim-commentary' " motion to comment out ranges
" NeoBundle 'tpope/vim-sleuth' " automatic indentation settings
" NeoBundle 'tpope/vim-dispatch' " run commands in background
" NeoBundle 'tpope/vim-speeddating.git' " increment dates and times
NeoBundle 'tpope/vim-tbone' " interact with tmux panes
" NeoBundle 'idanarye/vim-merginal' " work with git branches
NeoBundle 'coderifous/textobj-word-column.vim' " work on columns
NeoBundle 'michaeljsmith/vim-indent-object' " work same indentation
NeoBundle 'jeetsukumaran/vim-indentwise' " move by indentation
" NeoBundle 'ntpeters/vim-better-whitespace' " show and fix trailing space
" NeoBundle 'nelstrom/vim-qargs' " populate args with quickfix files
" NeoBundle 'osyo-manga/vim-over' " interactive substitution
NeoBundle 'AndrewRadev/linediff.vim' " diff blocks of lines
" " NeoBundle 'vim-scripts/diffchar.vim' " show diffs character by character (messes with unimpaired maps)
NeoBundle 'rking/ag.vim' " search in local files :Ag
NeoBundle 'kien/ctrlp.vim' " fuzzy find files
NeoBundle 'tommcdo/vim-lion' " align operator glip'
NeoBundle 'tommcdo/vim-exchange' " operator to exchange text
" NeoBundle 'tommcdo/vim-ninja-feet' " operate to ends of text objects
NeoBundle 'bruno-/vim-vertical-move' " move up and down in same column
" NeoBundle 'epeli/slimux' " interact with tmux panes
NeoBundle 'airblade/vim-gitgutter' " show git changes with signs
" NeoBundle 'kshenoy/vim-signature' " show and navigate marks
NeoBundle 'AndrewRadev/writable_search.vim' " search and replace across multiple files
NeoBundle 'idbrii/vim-mark' " highlight different words
NeoBundle 'bronson/vim-visual-star-search' " search for visual selection
" NeoBundle 'haya14busa/incsearch.vim' " highlight all incsearch matches
" NeoBundle 'sjl/splice.vim'
NeoBundle 'neomake/neomake'
" " language support
" NeoBundle 'b4winckler/vim-objc' " objective c
" NeoBundle 'vim-scripts/javacomplete' " java
" NeoBundle 'kana/vim-filetype-haskell' " haskell
" NeoBundle 'tpope/vim-markdown' " markdown
NeoBundle 'fatih/vim-go' " go
" NeoBundle 'exu/pgsql.vim' " postgres syntax highlighting
" NeoBundle 'wellle/vim-simpledb' " sql repl (switch mappings)
" " color schemes
" NeoBundle 'zenorocha/dracula-theme', {'rtp': 'vim/'}
NeoBundle 'flazz/vim-colorschemes'
" NeoBundle 'vim-scripts/Colour-Sampler-Pack'
" NeoBundle 'chriskempson/base16-vim'
" NeoBundle 'wellle/vim-colors-solarized'
" NeoBundle 'mtglsk/mushroom'
" NeoBundle 'wellsjo/wells-colorscheme.vim'
" NeoBundle 'ajgrf/sprinkles'
" NeoBundle 'vim-scripts/random.vim' " pseudo colorscheme to pick random one
" " NeoBundle 'wellle/delimitMate'
NeoBundle 'wellle/targets.vim' " advanced text objects
NeoBundle 'wellle/tmux-complete.vim' " complete words from panes
NeoBundle 'wellle/visual-split.vim'
" NeoBundle 'wellle/grapple.vim' " yank without moving
" if has('nvim')
" NeoBundle 'Valloric/YouCompleteMe', {'build':{'mac':'./install.sh'}}
" let g:tmuxcomplete#trigger = 'omnifunc'
" endif
NeoBundleCheck
call neobundle#end()
endif
" default
" let g:targets_seekRanges = 'lr rr ll lb ar ab lB Ar aB Ab AB rb al rB Al bb aa bB Aa BB AA'
" never seek
" let g:targets_seekRanges = 'lr lb ar ab lB Ar aB Ab AB'
" only seek current line
" let g:targets_seekRanges = 'lr rr ll'
" let g:targets_separator = [
" \ ', . ; : + - = ~ _ * # / | \ & $',
" \ ['x', '[^a-zA-Z]'],
" \ ]
let g:targets_seekRanges = 'cr cb cB lc ac Ac lr lb ar ab lB Ar aB Ab AB'
" let delimitMate_expand_cr = 1
silent! colorscheme hybrid
" colorscheme tomorrow
" set quoteescape=]^\[\\-
" set quoteescape=
" map / <Plug>(incsearch-forward)
" map ? <Plug>(incsearch-backward)
" map g/ <Plug>(incsearch-stay)
" TODO: disable [e [b ]b ]e mappingns for diffchar
" http://stackoverflow.com/questions/16059716/vim-remove-mapping-created-by-vim-plugin#comment22920168_16059873
" nmap <Plug>JumpDiffCharPrevStart <Plug>JumpDiffCharPrevStart
" nmap <Plug>JumpDiffCharNextStart <Plug>JumpDiffCharNextStart
" nmap <Plug>JumpDiffCharPrevEnd <Plug>JumpDiffCharPrevEnd
" nmap <Plug>JumpDiffCharNextEnd <Plug>JumpDiffCharNextEnd
nmap <Leader>hp <Plug>GitGutterPreviewHunk
let g:ag_highlight = 1
" let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_trailing_whitespace_error = 0
set hidden
set ignorecase " affects command line completion too
set tabstop=4 shiftwidth=4 softtabstop=4 expandtab
set listchars=tab:▸\ ,trail:·,extends:❯,precedes:❮
set fillchars=fold:۰,diff:·
set showbreak=↪\ "
set shortmess+=I
set mouse=a
set nostartofline
set lazyredraw
set splitbelow
set splitright
set nowrap
set autoread
set foldopen-=block
set guifont=Fantasque\ Sans\ Mono:h18
set guioptions-=r
" from vim-sensible
if has('autocmd')
filetype plugin indent on
endif
if has('syntax') && !exists('g:syntax_on')
syntax enable
endif
set incsearch
set laststatus=2
set ruler
set showcmd
set wildmenu
set autoindent
set backspace=indent,eol,start
set complete-=i
set smarttab
set nrformats-=octal
set ttimeout
set ttimeoutlen=100
set display+=lastline
set encoding=utf-8
" set formatoptions+=j " Delete comment character when joining commented lines
set fileformats+=mac
set history=1000
set viminfo^=!
inoremap <C-U> <C-G>u<C-U>
" fix some error highlighting in shell scripts
" https://groups.google.com/forum/?fromgroups#!topic/vim_dev/9f-sqmbpyyQ
let g:is_posix = 1
if exists("+breakindent")
set breakindent
set breakindentopt=shift:4
endif
if has("persistent_undo")
set swapfile directory=~/.vimtemp/swap//
set backup backupdir=~/.vimtemp/backup//
set undofile undodir=~/.vimtemp/undo//
endif
nnoremap <Leader>a <c-^>
nnoremap <Leader>s :write \| source %<CR>
cnoremap <c-a> <home>
cnoremap <c-e> <end>
cnoremap <c-p> <up>
cnoremap <c-n> <down>
set runtimepath+=$GOROOT/misc/vim
" set runtimepath+=~/.fzf
let loaded_matchit = 1
runtime! plugin/sensible.vim
set gdefault
set wildmode=longest,full
set scrolloff&
set matchpairs+=<:>
nnoremap Y y$
nnoremap gV `[v`]
nnoremap Q @q
" disable roman numerals
" runtime! plugin/speeddating.vim
" SpeedDatingFormat! %v
" SpeedDatingFormat! %^v
set statusline=
set statusline+=%f
" set statusline+=%(\ [%{fugitive#head()}%Y%R%W%M]%) " TODO: make this optional
set statusline+=%=
set statusline+=[%(%l,%c%V%)]
set statusline+=\ %P
" highlight user1 cterm=bold ctermbg=0 ctermfg=11
if has("autocmd")
augroup autocommands
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | execute "normal! g`\"" | endif
autocmd BufReadPost *.sql nnoremap <buffer> <enter> m':'{,'}SimpleDBExecuteSql<cr>g`'
" autocmd BufWritePost .vimrc source %
augroup END
endif
vmap . :normal .<CR>
let g:netrw_liststyle=3
" set t_ti= t_te= " don't clear scrollback buffer
nnoremap <leader>fs :set foldmethod=syntax<CR>
nnoremap <leader>fm :set foldmethod=manual<CR>
" change current word and prepare to repeat next occurence (like *cgn)
nnoremap c* :<C-U>let @/='\<'.expand("<cword>").'\>'<CR>:set hlsearch<CR>cgn
nnoremap <silent> <leader>gi :GoImports<CR>
" go test in right pane
nnoremap <silent> <leader>gt :w<CR>:call tbone#send_keys('right', "<C-V><C-C><C-V><C-L>got<C-V><CR>")<CR>
" rerun previous command in right pane
nnoremap <silent> <leader>tp :w<CR>:call tbone#send_keys('right', "<C-V><C-C><C-V><C-L><C-V><C-P><C-V><CR>")<CR>
" experimental
onoremap ae :<C-U>normal! ggVG<CR>
xnoremap ae :<C-U>normal! ggVG<CR>
let g:SignatureMap = {
\ 'GotoNextLineAlpha' : "",
\ 'GotoPrevLineAlpha' : "",
\ 'GotoNextSpotAlpha' : "",
\ 'GotoPrevSpotAlpha' : "",
\ }
" filter only visually selected text, not linewise
" http://stackoverflow.com/questions/9637921/vim-filter-only-visual-selection-not-the-entire-line
" TODO: extract plugin vim-visual-filter?
" TODO: doesn't seem to be working for visual block mode. remove?
nnoremap <silent> <Leader>! :set opfunc=ProgramFilter<cr>g@
vnoremap <silent> <Leader>! :<c-u>call ProgramFilter(visualmode(), 1)<cr>
function! ProgramFilter(vt, ...)
let [qr, qt] = [getreg('"'), getregtype('"')]
let [oai, ocin, osi, oinde] = [&ai, &cin, &si, &inde]
setl noai nocin nosi inde=
let [sm, em] = ['[<'[a:0], ']>'[a:0]]
exe 'norm!`' . sm . a:vt . '`' . em . 'x'
call inputsave()
let cmd = input('!')
call inputrestore()
let out = system(cmd, @")
let out = substitute(out, '\n$', '', '')
exe "norm!i\<c-r>=out\r"
let [&ai, &cin, &si, &inde] = [oai, ocin, osi, oinde]
call setreg('"', qr, qt)
endfunction
" https://gist.github.com/wellle/9289224
" TODO: make repeatable
" nnoremap <silent> <Leader>a :set opfunc=Append<CR>g@
" nnoremap <silent> <Leader>i :set opfunc=Insert<CR>g@
" function! Append(type, ...)
" call feedkeys("`]a", 'n')
" endfunction
" function! Insert(type, ...)
" call feedkeys("`[i", 'n')
" endfunction
" TODO: check what takes long with `vim --startuptime filename` and optimize
" idea: add completion mode for last inserted texts that start with the
" current insertion
" example: itext1<esc>Afoo<esc>Itex<^X^@> would complete to text1
" TODO: make % work like this:
" - dV% should delete linewise, not characterwise
" - di% should delete inside
" - da% should delete around (like d% already does)
" NOTE: it works this way, but the matchit plugin breaks this
" /usr/local/share/vim/macros/matchit.vim
" TODO: make f,dt. repeatable?
" TODO: vi{ inside {} should select zero characters, so that a subsequent c
" basically starts inserting inside the {}. so is needed to make cin{ work in
" that case. workaround: use f{a instead, but doesn't handle repetition over
" empty and nonempty pairs
" TODO: autocommand issue: insert line "foo bar ". At end of line press `cb`
" to change "bar". Notice how trailing whitespaces are now highlighted while
" being in insert mode
" idea: motion z% jump to matching fold start/end
" idea: add insert mode to vim-surround that closes all unmatched parens:
" `ysipiif (false) {<esc>` would close the `{` after the block in one stroke
" idea: ^N^X^L should complete lines that contain the completed word
" TODO: fix on this text, visually select lines containing =, run `:norm df=A,`, doesn't work
" aoeu
" x = b
" y = c
" snth