elihunter173 / dirbuf.nvim

A file manager for Neovim which lets you edit your filesystem like you edit text
GNU Affero General Public License v3.0
423 stars 7 forks source link

Only set mapping if filetype is `dirbuf`. #13

Closed seblj closed 2 years ago

seblj commented 2 years ago

Currently, the plugin maps - to go a directory up even if the filetype isn't dirbuf. It would be nice if it could only set the mapping when the filetype is dirbuf

elihunter173 commented 2 years ago

Should be resolved. Adding this to your init.vim will disable the - mapping for going up a directory globally but not when filetype=dirbuf. (You can also map - to anything else and it will still disable the dirbuf mapping.)

nnoremap - <nop>

The new behavior is that - is only globally mapped to going up a directory if - isn't already taken by another mapping and <Plug>(dirbuf_up) isn't already mapped to by something else. For filetype=dirbuf mappings, they are only made if a mapping to the <Plug> version does not exist.

So for your case, doing nnoremap - <nop> (or anything else) will cause the global mapping to not be assigned, but assuming you don't map <Plug>(dirbuf_up) to anything, then when you open a dirbuf the - mapping for going up a directory will be set.

This new behavior is documented in :help dirbuf-mappings.