Skip to content

Commit ca88fd7

Browse files
committed
Provide d maps for :Dispatch
Picking a fight with Netrw here, which seems to think that mkdir is important enough to completely take over the letter d. This is a dubious strategy, and I'll abandon it for a different map (maybe backtick?) if people have issues.
1 parent 7f16447 commit ca88fd7

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

doc/dispatch.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,15 @@ COMMANDS *dispatch-commands*
118118

119119
MAPS *dispatch-maps*
120120

121+
*dispatch-d<CR>*
122+
d<CR> Equivalent to |:Dispatch|<CR>.
123+
124+
*dispatch-d<Space>*
125+
d<Space> Equivalent to |:Dispatch|<Space>.
126+
127+
*dispatch-d!*
128+
d! Equivalent to |:Dispatch!|.
129+
121130
*dispatch-m<CR>*
122131
m<CR> Equivalent to |:Make|<CR>.
123132

plugin/dispatch.vim

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,22 @@ nmap <script> <SID>:. :<C-R>=getcmdline() =~ ',' ? "\0250" : ""<CR>
5757
call s:map('n', 'm<CR>', '<SID>:.Make<CR>')
5858
call s:map('n', 'm<Space>', '<SID>:.Make<Space>')
5959
call s:map('n', 'm!', '<SID>:.Make!')
60+
call s:map('n', 'd<CR>', '<SID>:.Dispatch<CR>')
61+
call s:map('n', 'd<Space>', '<SID>:.Dispatch<Space>')
62+
call s:map('n', 'd!', '<SID>:.Dispatch!')
6063

6164
function! DispatchComplete(id) abort
6265
return dispatch#complete(a:id)
6366
endfunction
6467

68+
function! s:hijack_netrw_maps() abort
69+
let rhs = maparg('d', 'n')
70+
if len(rhs)
71+
exe 'nnoremap <buffer> <silent> d' rhs
72+
exe 'nnoremap <buffer> <silent> dd' rhs
73+
endif
74+
endfunction
75+
6576
if !exists('g:dispatch_handlers')
6677
let g:dispatch_handlers = [
6778
\ 'tmux',
@@ -79,4 +90,5 @@ augroup dispatch
7990
\ if &buftype ==# 'quickfix' && empty(getloclist(winnr())) && get(w:, 'quickfix_title') =~# '^:noautocmd cgetfile\>\|^:\d*Dispatch\>' |
8091
\ call dispatch#quickfix_init() |
8192
\ endif
93+
autocmd FileType netrw call s:hijack_netrw_maps()
8294
augroup END

0 commit comments

Comments
 (0)