-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathvimrc
290 lines (249 loc) · 7.42 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
" vim: nowrap fdm=marker
scriptencoding utf-8
if !has('nvim')
unlet! skip_defaults_vim
source $VIMRUNTIME/defaults.vim
endif
source ~/dotfiles/packages.vim
" Personal preferences not set by sensible.vim
let g:mapleader=','
set history=5000
set showcmd
set nojoinspaces
set complete-=t
" set listchars=tab:▸\ ,eol:¬
set foldlevelstart=99
set noswapfile
if has('mouse')
set mouse=nv
endif
set diffopt=filler,vertical
set ruler
if has('nvim')
set inccommand=nosplit
endif
" Define a group for autocommands
augroup vimrc
autocmd!
augroup END
function! FormatprgLocal(filter)
if !empty(v:char)
return 1
else
let l:command = v:lnum.','.(v:lnum+v:count-1).'!'.a:filter
echo l:command
execute l:command
endif
endfunction
if has('autocmd')
augroup ragtag_filetypes
autocmd!
autocmd FileType markdown call RagtagInit()
augroup END
let g:pandoc_pipeline = 'pandoc --from=html --to=markdown'
let g:pandoc_pipeline .= ' | pandoc --from=markdown --to=html'
autocmd vimrc FileType html setlocal formatexpr=FormatprgLocal(pandoc_pipeline)
endif
" Colorscheme
set termguicolors
set background=light
silent! colorscheme solarized8_light
set hidden
" Plugin configuration {{{1
" netrw.vim {{{2
let g:netrw_banner=0
" Don't show undo files in the explorer
let g:netrw_list_hide='\.un\~$'
" neomake {{{2
let g:neomake_javascript_enabled_makers = ['eslint']
if exists(':Neomake')
autocmd! vimrc BufWritePost * Neomake
endif
" if emoji#available()
" let g:neomake_warning_sign = { 'text': emoji#for('exclamation') }
" let g:neomake_error_sign = { 'text': emoji#for('x') }
" let g:neomake_info_sign = { 'text': emoji#for('8ball') }
" let g:neomake_message_sign = { 'text': emoji#for('pencil2') }
" endif
" syntastic {{{2
let g:syntastic_mode_map = {
\ 'mode': 'passive',
\ 'active_filetypes': [
\ 'javascript'
\ ],
\ 'passive_filetypes': [
\ 'html',
\ 'ruby'
\ ]
\ }
let g:syntastic_ruby_checkers=['bx rubocop', 'mri']
nnoremap ZS :SyntasticCheck<CR>
nnoremap ZT :SyntasticToggle<CR>
" Vim-ruby {{{2
" let ruby_fold=1
" Vim-rspec {{{2
map <Leader>t :w<bar>:call RunCurrentSpecFile()<CR>
map <Leader>s :w<bar>:call RunNearestSpec()<CR>
map <Leader>l :w<bar>:call RunLastSpec()<CR>
map <Leader>a :w<bar>:call RunAllSpecs()<CR>
let g:rspec_command = 'Dispatch rspec {spec}'
" Markdown {{{2
let g:markdown_fenced_languages = ['ruby', 'javascript']
" FIXME:
" Markdown files have foldmethod=syntax when both of these options are set:
" let ruby_fold=1
" let g:markdown_fenced_languages = ['ruby', 'javascript']
" to debug, run :verbose set foldmethod?
"
" Solarized8 {{{2
nnoremap <leader>B :<c-u>exe "colors" (g:colors_name =~# "dark"
\ ? substitute(g:colors_name, 'dark', 'light', '')
\ : substitute(g:colors_name, 'light', 'dark', '')
\ )<cr>
function! Solarized8Contrast(delta)
let l:schemes = map(['_low', '_flat', '', '_high'], '"solarized8_".(&background).v:val')
exe 'colors' l:schemes[((a:delta+index(l:schemes, g:colors_name)) % 4 + 4) % 4]
endfunction
nmap <leader>- :<c-u>call Solarized8Contrast(-v:count1)<cr>
nmap <leader>+ :<c-u>call Solarized8Contrast(+v:count1)<cr>
" Ctlr-P {{{2
let g:ctrlp_jump_to_buffer = 0
let g:ctrlp_working_path_mode = 0
let g:ctrlp_user_command = 'find %s -type f'
" Denite {{{2
" vim/after/plugin/denite.vim
" Ragel {{{2
augroup ragel
autocmd!
autocmd BufNewFile,BufRead *.rl setfiletype ragel
augroup END
let g:ragel_default_subtype='ruby'
" Mappings and commands {{{1
" Override defaults {{{2
nnoremap Q <Nop>
command! -nargs=0 -bang Qa qall!
command! -nargs=0 -bang QA qall!
" File opening {{{2
cnoremap <expr> %% getcmdtype() == ':' ? fnameescape(expand('%:h')).'/' : '%%'
map <leader>ew :e %%
map <leader>es :sp %%
map <leader>ev :vsp %%
map <leader>et :tabe %%
" Prompt to open file with same name, different extension
map <leader>er :e <C-R>=expand("%:r")."."<CR>
" Fix the & command in normal+visual modes {{{2
nnoremap & :&&<Enter>
xnoremap & :&&<Enter>
" Strip trailing whitespace {{{2
function! Preserve(command)
let l:save = winsaveview()
execute a:command
call winrestview(l:save)
endfunction
command! TrimWhitespace call Preserve("%s/\\s\\+$//e")
nmap _$ :TrimWhitespace<CR>
" Visual line repeat {{{2
xnoremap . :normal .<CR>
xnoremap @ :<C-u>call ExecuteMacroOverVisualRange()<CR>
function! ExecuteMacroOverVisualRange()
echo '@'.getcmdline()
execute ":'<,'>normal @".nr2char(getchar())
endfunction
" Experimental mappings {{{2
nnoremap g" /\v<<C-r>"><CR>
command! Path :call EchoPath()
function! EchoPath()
echo join(split(&path, ','), "\n")
endfunction
command! TagFiles :call EchoTags()
function! EchoTags()
echo join(split(&tags, ','), "\n")
endfunction
" let g:EasyClipUseSubstituteDefaults = 1
" nmap <silent> gs <plug>SubstituteOverMotionMap
" nmap gss <plug>SubstituteLine
" xmap gs p
" let g:EasyClipUseCutDefaults = 0
" nmap x <Plug>MoveMotionPlug
" xmap x <Plug>MoveMotionXPlug
" nmap xx <Plug>MoveMotionLinePlug
nmap cp <Plug>TransposeCharacters
nnoremap <Plug>TransposeCharacters xp
\:call repeat#set("\<Plug>TransposeCharacters")<CR>
" ember-cli {{{2
command! -nargs=* Ember :echo system('ember <args>')
if exists('*smartinput#define_rule')
call smartinput#clear_rules()
call smartinput#define_rule({
\'at': '{\%#',
\'char': '{',
\'input': '{}}<Left><Left>',
\'filetype': ['html.handlebars']
\ })
call smartinput#define_rule({
\'at': '\%#}}',
\'char': '}',
\'input': '<Right><Right>',
\'filetype': ['html.handlebars']
\ })
call smartinput#define_rule({
\'at': '}}\%#',
\'char': '}',
\'input': '',
\'filetype': ['html.handlebars']
\ })
call smartinput#define_rule({
\'at': '{{\%#}}',
\'char': '<BS>',
\'input': '<BS><BS><Del><Del>',
\'filetype': ['html.handlebars']
\ })
call smartinput#define_rule({
\'at': '{{}}\%#',
\'char': '<BS>',
\'input': '<BS><BS><BS><BS>',
\'filetype': ['html.handlebars']
\ })
endif
augroup javascript
autocmd!
autocmd FileType javascript setlocal suffixesadd+=.debug.js,.js
augroup END
let g:mustache_operators=0
augroup emoji_complete
autocmd!
autocmd FileType markdown setlocal completefunc=emoji#complete
augroup END
if exists(':terminal')
tnoremap <expr> <C-\><C-R> '<C-\><C-N>"'.nr2char(getchar()).'pi'
autocmd vimrc TermOpen * nnoremap <buffer> I I<C-a>
autocmd vimrc TermOpen * nnoremap <buffer> A A<C-e>
autocmd vimrc TermOpen * nnoremap <buffer> C i<C-k>
autocmd vimrc TermOpen * nnoremap <buffer> D i<C-k><C-\><C-n>
autocmd vimrc TermOpen * nnoremap <buffer> cc i<C-e><C-u>
autocmd vimrc TermOpen * nnoremap <buffer> dd i<C-e><C-u><C-\><C-n>
endif
" https://github.com/neovim/neovim/pull/2076#issuecomment-76998265
nnoremap <a-h> <c-w>h
nnoremap <a-j> <c-w>j
nnoremap <a-k> <c-w>k
nnoremap <a-l> <c-w>l
vnoremap <a-h> <c-\><c-n><c-w>h
vnoremap <a-j> <c-\><c-n><c-w>j
vnoremap <a-k> <c-\><c-n><c-w>k
vnoremap <a-l> <c-\><c-n><c-w>l
inoremap <a-h> <c-\><c-n><c-w>h
inoremap <a-j> <c-\><c-n><c-w>j
inoremap <a-k> <c-\><c-n><c-w>k
inoremap <a-l> <c-\><c-n><c-w>l
cnoremap <a-h> <c-\><c-n><c-w>h
cnoremap <a-j> <c-\><c-n><c-w>j
cnoremap <a-k> <c-\><c-n><c-w>k
cnoremap <a-l> <c-\><c-n><c-w>l
if has('nvim')
tnoremap <a-h> <c-\><c-n><c-w>h
tnoremap <a-j> <c-\><c-n><c-w>j
tnoremap <a-k> <c-\><c-n><c-w>k
tnoremap <a-l> <c-\><c-n><c-w>l
tnoremap <Esc> <C-\><C-n>
endif