-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc.local
214 lines (165 loc) · 6.34 KB
/
.vimrc.local
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
colorscheme vividchalk
set number
nmap <script> <SID>: :<C-R>=getcmdline() =~ ',' ? "\0250" : ""<CR>
nmap <script> d<CR> <SID>:Dispatch<CR>
nmap <script> D<CR> :execute "Dispatch bundle exec rspec %:" . line(".")<CR>
nmap <script> d<Space> <SID>:Dispatch<Space>
nmap <script> d! <SID>:Dispatch!
nmap <script> <SID>make <SID>:<C-R>=exists(':Make') > 1 ? 'Make' : 'make'<CR>
nmap <script> m<CR> <SID>make<CR>
nmap <script> m<Space> <SID>make<Space>
nmap <script> m! <SID>make!
" Is there a better mnemonic than =?
nmap <script> =<CR> :<C-R>=exists(':Start') > 1 ? 'Start' : 'shell'<CR><CR>
nmap <script> =<Space> :<C-R>=exists(':Start') > 1 ? 'Start ' : '!'<CR>
nmap <script> =! :<C-R>=exists(':Start') > 1 ? 'Start!' : '!'<CR>
nmap <script> =c :Console<CR>
" https://github.com/stefanoverna/vim-i18n
vmap <Leader>z :call I18nTranslateString()<CR>
vmap <Leader>dt :call I18nDisplayTranslation()<CR>
" use jsx synx highlighting for js files
let g:jsx_ext_required = 0
let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\"
let &t_SR = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=2\x7\<Esc>\\"
let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\"
" ??
" nnoremap ]c :call search('^\s*'.substitute(escape(&cms, '\.*[]^$'), '%s', '.*', '').'\s*$')<CR>
" nnoremap [c :call search('^\s*'.substitute(escape(&cms, '\.*[]^$'), '%s', '.*', '').'\s*$', 'b')<CR>
au FileType xhtml,xml,xslt so ~/.vim/bundle/HTML-AutoCloseTag/ftplugin/html_autoclosetag.vim
augroup XML
autocmd!
autocmd FileType xml setlocal foldmethod=indent foldlevelstart=999 foldminlines=0
augroup END
set shiftwidth=2 tabstop=2 expandtab
let g:fugitive_bitbucket_domains = ['stash']
" tabular mapping
" http://vimcasts.org/episodes/aligning-text-with-tabular-vim/
inoremap <silent> <Bar> <Bar><Esc>:call <SID>align()<CR>a
function! s:align()
let p = '^\s*|\s.*\s|\s*$'
if exists(':Tabularize') && getline('.') =~# '^\s*|' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p)
let column = strlen(substitute(getline('.')[0:col('.')],'[^|]','','g'))
let position = strlen(matchstr(getline('.')[0:col('.')],'.*|\s*\zs.*'))
Tabularize/|/l1
normal! 0
call search(repeat('[^|]*|',column).'\s\{-\}'.repeat('.',position),'ce',line('.'))
endif
endfunction
" markdown preview with github flavoring
let vim_markdown_preview_github=1
" So F8, 9, and 10 run the test on this line, this file, and whole suite
" respecitvely.
map <F8> :execute "Dispatch bundle exec rspec %:" . line(".")<CR>
map <F9> :Dispatch bundle exec rspec %<CR>
map <F10> :Dispatch bundle exec rspec spec<CR>
" Search in project for word under cursor
map <leader>* :Ggrep --untracked <cword><CR><CR>
" Search in project for word under cursor, regular version
map <leader>& :grep -R <cword> * --exclude-dir={.git,tmp,log}<CR><CR>
" Insert Markdown header timestamps
map <leader>D :put =strftime('# %a %Y-%m-%d %H:%M:%S%z')<CR>
"
command! -nargs=0 -bar Qargs execute 'args' QuickfixFilenames()
function! QuickfixFilenames()
let buffer_numbers = {}
for quickfix_item in getqflist()
let buffer_numbers[quickfix_item['bufnr']] = bufname(quickfix_item['bufnr'])
endfor
return join(map(values(buffer_numbers), 'fnameescape(v:val)'))
endfunction
" vertical to horizontal ( | -> -- )
noremap <c-w>- <c-w>t<c-w>K
" horizontal to vertical ( -- -> | )
noremap <c-w>\| <c-w>t<c-w>H
" https://sheerun.net/2014/03/21/how-to-boost-your-vim-productivity/
vmap v <Plug>(expand_region_expand)
vmap <C-v> <Plug>(expand_region_shrink)
call expand_region#custom_text_objects('ruby', {
\ 'im' :0,
\ 'am' :0,
\ })
nnoremap <c-h> :SidewaysLeft<cr>
nnoremap <c-l> :SidewaysRight<cr>
command! -nargs=+ Gca :r!git log -n100 --pretty=format:"\%an <\%ae>" | grep -i '<args>' | head -1 | xargs echo "Co-authored-by:"
if getcwd() =~# '^\(/Users/colin/code/new-test\|/another/safe/path/\)'
set secure exrc
endif
" open merginal
map <leader>gm :MerginalToggle<CR>
" gitlab
map <leader>gp :Git push -u origin HEAD
" visual mode mappings for
" ctrl-j, k, $, and ^
" vnoremap <S-j> gj
" vnoremap <S-k> gk
" vnoremap <S-4> g$
" vnoremap <S-6> g^
" normal mode mappings for
" ctrl-j, k, $, and ^
" nnoremap <S-j> gj
" nnoremap <S-k> gk
" nnoremap <S-4> g$
" nnoremap <S-6> g^
let s:wrapenabled = 0
function! ToggleWrap()
set wrap nolist
if s:wrapenabled
set nolinebreak
unmap j
unmap k
unmap 0
unmap ^
unmap $
let s:wrapenabled = 0
else
set linebreak
nnoremap j gj
nnoremap k gk
nnoremap 0 g0
nnoremap ^ g^
nnoremap $ g$
vnoremap j gj
vnoremap k gk
vnoremap 0 g0
vnoremap ^ g^
vnoremap $ g$
let s:wrapenabled = 1
endif
endfunction
map <leader>w :call ToggleWrap()<CR>
" Git Yank: Copy URL to current line(s)
nnoremap <Leader>gy :.GBrowse!<CR>
xnoremap <Leader>gy :'<'>GBrowse!<CR>
" round indents
set shiftround
map <silent><Leader>g :call setbufvar(winbufnr(popup_atcursor(systemlist("cd " . shellescape(fnamemodify(resolve(expand('%:p')), ":h")) . " && git log --no-merges -n 1 -L " . shellescape(line("v") . "," . line(".") . ":" . resolve(expand("%:p")))), { "padding": [1,1,1,1], "pos": "botleft", "wrap": 0 })), "&filetype", "git")<CR>
let g:blamer_delay = 700
let g:blamer_show_in_insert_modes = 0
let g:blamer_template = '<summary>'
let g:git_messenger_include_diff = "current"
let g:git_messenger_always_into_popup = v:true
let g:git_messenger_max_popup_height = 35
" https://github.com/vim/vim/issues/4738
function! OpenURLUnderCursor()
let s:uri = expand('<cWORD>')
let s:uri = substitute(s:uri, '?', '\\?', '')
let s:uri = shellescape(s:uri, 1)
if s:uri != ''
silent exec "!open '".s:uri."'"
:redraw!
endif
endfunction
nnoremap gx :call OpenURLUnderCursor()<CR>
" define line highlight color
highlight LineHighlight ctermbg=darkgray guibg=darkgray
" highlight the current line
nnoremap <silent> <Leader>l :call matchadd('LineHighlight', '\%'.line('.').'l')<CR>
" clear all the highlighted lines
nnoremap <silent> <Leader>c :call clearmatches()<CR>
" disable for now, delay is annoying
" nmap <script>n<CR> :tab drop tmp/notes.md<CR>
let g:markdown_fenced_languages = ['coffee', 'css', 'erb=eruby', 'javascript', 'js=javascript', 'json=javascript', 'ruby', 'sass', 'xml', 'vim']
" reselect pasted text
nnoremap gp `[v`]
" maximize current split or return to previous
noremap <C-w>m :MaximizerToggle<CR>