-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
297 lines (240 loc) · 6.82 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
set nocompatible
filetype off
" Vundle Setup
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" Let Vundle manage Vundle
Plugin 'gmarik/Vundle.vim'
" Plugin list
Plugin 'tpope/vim-abolish'
Plugin 'tpope/vim-bundler'
Plugin 'tpope/vim-commentary'
Plugin 'tpope/vim-dispatch'
Plugin 'tpope/vim-endwise'
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-markdown'
Plugin 'tpope/vim-projectionist'
Plugin 'tpope/vim-rails'
Plugin 'tpope/vim-rake'
Plugin 'tpope/vim-repeat'
Plugin 'tpope/vim-sleuth'
Plugin 'tpope/vim-surround'
Plugin 'tpope/vim-unimpaired'
Plugin 'AndrewRadev/splitjoin.vim'
Plugin 'AndrewRadev/switch.vim'
Plugin 'christoomey/vim-tmux-navigator'
Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'google/vim-jsonnet'
Plugin 'edkolev/tmuxline.vim'
Plugin 'ervandew/supertab'
Plugin 'fatih/vim-go'
Plugin 'godlygeek/tabular'
Plugin 'kana/vim-textobj-user'
Plugin 'nelstrom/vim-textobj-rubyblock'
Plugin 'rodjek/vim-puppet'
Plugin 'scrooloose/syntastic'
Plugin 'terryma/vim-multiple-cursors'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'vim-ruby/vim-ruby'
Plugin 'whatyouhide/vim-gotham'
" Done setting up Vundle
call vundle#end()
syntax on
filetype plugin indent on
if has('python3')
silent! python3 1
endif
" Misc Runtime
runtime macros/matchit.vim
" CtrlP.vim
let g:ctrlp_working_path_mode = 0
let g:ctrlp_root_markers = ['Gemfile', 'package.json']
" vim-airline
let g:airline_powerline_fonts = 0
let g:airline_theme = "murmur"
let g:airline#extensions#tabline#enabled = 1
let g:airline_section_y = airline#section#create_right(['ffenc'])
" tmuxline.vim
let g:tmuxline_powerline_separators = 0
let g:tmuxline_preset = {
\'a' : '#S',
\'b' : [ '#(whoami)' ],
\'win' : ['#I', '#W'],
\'cwin' : ['#I', '#W', '#F'],
\'x' : ['#(~/.bin/is_plugged_in && echo ⛽️ || echo 🔋 ) #(~/.bin/battery_status)'],
\'y' : ['%R', '%a %d ', '%Y'],
\'z' : '#H'}
" UltiSnips
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<C-f>"
let g:UltiSnipsJumpBackwardTrigger="<C-b>"
let g:UltiSnipsEditSplit="vertical"
" synastic
" Syntastic is more annoying than useful for html files, given that 90% of the
" time there is templating in there as well or partials
let g:syntastic_ignore_files = ['\mhtml$', '\mmain.scss$', '\merb$', '\mhbs$', '\mfeature$']
" Use ag for grep
if executable('ag')
set grepprg=ag\ --nogroup\ --nocolor
command! -nargs=+ -complete=file -bar Ag silent! grep! <args>|cwindow|redraw!
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
let g:ctrlp_use_caching = 0
endif
" Colour settings
set t_Co=256
colorscheme gotham256
hi Comment ctermfg=yellow
" Goto last location in non-empty files and centre it
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$")
\| exe "normal! g`\"zz"
\| endif
" More Natural Splits
set splitbelow
set splitright
" All faux-fuzzy finding
set path+=**
" Relative Number hybrid thing
set number
set relativenumber
" Misc Settings
set ruler
match Error /\s\+$/
set laststatus=2
set ttyfast
set nowrap
set noshowmode
set showcmd
set hidden
set winwidth=84
set autowrite
set updatetime=100
" Fix backspace not deleting new lines
set backspace=indent,eol,start
" Key press timeout
set timeoutlen=500
" Completion
set wildchar=<TAB>
set wildmenu
set wildmode=list:longest
" Visual
set virtualedit=block
" Search
set incsearch
set wrapscan
set ignorecase
set smartcase
" Replace
set gdefault
" Set up .swp files to ~/.vim/tmp
set backupdir=~/.vim/tmp,.
set directory=~/.vim/tmp,.
" Enable mouse if available
if has("mouse")
set mouse=a
endif
" Cursorline Settings
set cursorline
hi CursorLine cterm=NONE ctermbg=236 ctermfg=NONE
" Highlight column when over 80 characters
highlight ColorColumn ctermbg=magenta
call matchadd('ColorColumn', '\%81v', 100)
call matchadd('Error', '\%121v', 100)
" List chars
set list listchars=tab:»·,nbsp:_
" Trim whitespace
autocmd BufWritePre *.* :%s/\s\+$//e
" Automatically split when two files are opened
autocmd VimEnter * call misc#SplitIfTwoFiles()
" Mappings
let mapleader = "\<space>"
let g:mapleader = "\<space>"
nnoremap Y y$
map <Leader>== mmgg=G:w<CR>'mzz
map <Leader>bo :BufOnly<CR>
nnoremap <Leader>] :call misc#NextTabOrBuffer()<CR>
nnoremap <Leader>[ :call misc#PreviousTabOrBuffer()<CR>
map <Leader>pb :call misc#SplitOrCtrlP()<CR>
map <Leader>pm :CtrlPMRUFiles<CR>
map <Leader>pp :CtrlPMixed<CR>
map <Leader>py :CtrlPYankring<CR>
map <Leader>f :CtrlPLine<CR>
nmap j gj
nmap k gk
nmap <Tab> %
omap p i)
cmap w!! w !sudo tee % >/dev/null
command! Qa qa
command! Wqa wqa
command! Wq wq
command! W w
command! Q q
command! Irb silent !tmux split-window -p 25 irb
command! Bc silent !tmux split-window -p 25 "echo Calculator; bc -sq"
command! Vexplore vs | Explore
nnoremap <Leader>vi :tabe $MYVIMRC<CR>
nnoremap <Leader>so :so $MYVIMRC<CR>:noh<CR>
nnoremap <Leader>qq :bdelete<CR>
nnoremap <Leader>mt :call misc#MergeTabs()<CR>
nnoremap <Leader>tm :tabnext<CR>:call misc#MergeTabs()<CR>
nnoremap <Leader>oc :set cursorcolumn!<CR>
nnoremap <Leader><C-]> :vsplit<CR><C-]>
map <Leader>gf :vsplit<CR>gf
nnoremap <Leader>gb :Git blame<CR>
nnoremap <Leader>gd :Gdiff<CR>
nnoremap <Leader>- :Switch<CR>
nnoremap <Leader>cw ^cw
nnoremap <Leader>, A,<CR>
nnoremap <Leader>d, ddk$x
nnoremap <Leader>a, mzA,<Esc>`z:w<CR>
nnoremap <Leader><Up> mz"dyy"dp`z
nnoremap <Leader><Down> mz"dyy"dp`zj
vnoremap <Leader><Down> "dymz"dP`z
nnoremap <Leader><Backspace> mz$x`z:w<CR>
nnoremap <Leader>s<space> :%s/<C-r><C-w>//c<Left><Left>
nnoremap <Leader>s% :%s///c<Left><Left><Left>
nnoremap <Leader>g<space> :g/<C-r><C-w>/
inoremap :w<CR> <Esc>:w<CR>
inoremap :wq<CR> <Esc>:wq<CR>
" Quicker quickfix
nmap <Leader>cn :cnext<CR>
nmap <Leader>cp :cprevious<CR>
nmap <Leader>cc :cclose<CR>
" Jump to end of pasted text
vnoremap <silent> y y`]
vnoremap <silent> p p`]
nnoremap <silent> p p`]
" Auto centering
nnoremap <silent> n nzz
nnoremap <silent> N Nzz
nnoremap <silent> * *zz
nnoremap <silent> # #zz
nnoremap <silent> g* g*zz
nnoremap <silent> g# g#zz
" Vim Go related configs
autocmd FileType go nmap <leader>r <Plug>(go-run)
autocmd FileType go nmap <leader>t <Plug>(go-test)
autocmd FileType go nmap <Leader>gc <Plug>(go-coverage-toggle)
autocmd FileType go nmap <Leader>gi <Plug>(go-info)
" run :GoBuild or :GoTestCompile based on the go file
function! s:build_go_files()
let l:file = expand('%')
if l:file =~# '^\f\+_test\.go$'
call go#test#Test(0, 1)
elseif l:file =~# '^\f\+\.go$'
call go#cmd#Build(0)
endif
endfunction
autocmd FileType go nmap <leader>b :<C-u>call <SID>build_go_files()<CR>
" Sort out imports on save
let g:go_fmt_command = "goimports"
" Don't Overwrite Register on vp
function! RestoreRegister()
let @" = s:restore_reg
return ''
endfunction
function! s:Repl()
let s:restore_reg = @"
return "p@=RestoreRegister()\<cr>"
endfunction
vmap <silent> <expr> p <sid>Repl()