comparison plugin/lawrencium.vim @ 9:82a49134a85c

Added keyboard shortcuts to Hgstatus window.
author Ludovic Chabant <ludovic@chabant.com>
date Mon, 12 Dec 2011 10:59:46 -0800
parents 1e155bfa94ad
children 7d16084d40a9
comparison
equal deleted inserted replaced
8:1e155bfa94ad 9:82a49134a85c
285 285
286 " Add some handy mappings. 286 " Add some handy mappings.
287 nnoremap <buffer> <silent> <C-N> :call search('^[MARC\!\?I ]\s.', 'We')<cr> 287 nnoremap <buffer> <silent> <C-N> :call search('^[MARC\!\?I ]\s.', 'We')<cr>
288 nnoremap <buffer> <silent> <C-P> :call search('^[MARC\!\?I ]\s.','Wbe')<cr> 288 nnoremap <buffer> <silent> <C-P> :call search('^[MARC\!\?I ]\s.','Wbe')<cr>
289 nnoremap <buffer> <silent> <cr> :execute <SID>HgStatus_FileEdit()<cr> 289 nnoremap <buffer> <silent> <cr> :execute <SID>HgStatus_FileEdit()<cr>
290 nnoremap <buffer> <silent> <C-D> :execute <SID>HgStatus_FileDiff(0)<cr>
291 nnoremap <buffer> <silent> <C-V> :execute <SID>HgStatus_FileDiff(1)<cr>
290 nnoremap <buffer> <silent> q :bdelete<cr> 292 nnoremap <buffer> <silent> q :bdelete<cr>
291 endfunction 293 endfunction
292 294
293 function! s:HgStatus_FileEdit() abort 295 function! s:HgStatus_FileEdit() abort
296 " Get the path of the file the cursor is on.
297 let l:filename = s:HgStatus_GetSelectedPath()
298
299 " Go back to the previous window and open the file there, or open an
300 " existing buffer.
301 wincmd p
302 if bufexists(l:filename)
303 execute 'buffer ' . l:filename
304 else
305 execute 'edit ' . l:filename
306 endif
307 endfunction
308
309 function! s:HgStatus_FileDiff(vertical) abort
310 " Get the path of the file the cursor is on.
311 let l:filename = s:HgStatus_GetSelectedPath()
312
313 " Go back to the previous window and call HgDiff.
314 wincmd p
315 call s:HgDiff(l:filename, a:vertical)
316 endfunction
317
318 function! s:HgStatus_GetSelectedPath() abort
294 let l:repo = s:hg_repo() 319 let l:repo = s:hg_repo()
295 let l:line = getline('.') 320 let l:line = getline('.')
296 " Yay, awesome, Vim's regex syntax is fucked up like shit, especially for 321 " Yay, awesome, Vim's regex syntax is fucked up like shit, especially for
297 " look-aheads and look-behinds. See for yourself: 322 " look-aheads and look-behinds. See for yourself:
298 let l:filename = matchstr(l:line, '\([MARC\!\?I ]\s\)\@<=.*') 323 let l:filename = matchstr(l:line, '\([MARC\!\?I ]\s\)\@<=.*')
299 let l:filename = l:repo.GetFullPath(l:filename) 324 let l:filename = l:repo.GetFullPath(l:filename)
300 " Go back to the previous window and open the file there, or open an 325 return l:filename
301 " existing buffer.
302 wincmd p
303 if bufexists(l:filename)
304 execute 'buffer ' . l:filename
305 else
306 execute 'edit ' . l:filename
307 endif
308 endfunction 326 endfunction
309 327
310 call s:AddMainCommand("Hgstatus :execute s:HgStatus()") 328 call s:AddMainCommand("Hgstatus :execute s:HgStatus()")
311 329
312 " }}} 330 " }}}