Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if <plug> has been assigned with hasmapto() #106

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion doc/vinegar.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ MAPPINGS *vinegar-mappings*
*vinegar--*
- Open the parent directory of the current file. This
is the only mapping available outside of netrw
buffers.
buffers. If you have already mapped - to somthing else,
you'll need to map one of these plugs:

<Plug>VinegarUp
<Plug>VinegarTabUp
<Plug>VinegarSplitUp
<Plug>VinegarVerticalSplitUp

*vinegar-~*
~ Open $HOME.
Expand Down
11 changes: 7 additions & 4 deletions plugin/vinegar.vim
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,17 @@ endif
unlet! s:netrw_up

nnoremap <silent> <Plug>VinegarUp :call <SID>opendir('edit')<CR>
if empty(maparg('-', 'n'))
nmap - <Plug>VinegarUp
endif

nnoremap <silent> <Plug>VinegarTabUp :call <SID>opendir('tabedit')<CR>
nnoremap <silent> <Plug>VinegarSplitUp :call <SID>opendir('split')<CR>
nnoremap <silent> <Plug>VinegarVerticalSplitUp :call <SID>opendir('vsplit')<CR>

if empty(mapcheck('-', 'n')) && !hasmapto('<Plug>VinegarUp') &&
\ !hasmapto('<Plug>VinegarSplitUp') &&
\ !hasmapto('<Plug>VinegarVerticalSplitUp') &&
\ !hasmapto('<Plug>VinegarTabUp')
nmap - <Plug>VinegarUp
endif

function! s:opendir(cmd) abort
let df = ','.s:dotfiles
if expand('%:t')[0] ==# '.' && g:netrw_list_hide[-strlen(df):-1] ==# df
Expand Down