fix(dir): custom 3P directory-browser #40725

Problem:
Third-party directory browsers do not have a documented way to take over local
directory buffers from nvim.dir.

Solution:
Document deleting the nvim.dir augroup and handling FileType directory as the
after-startup handoff, and avoid installing the built-in buffer-local "-" mapping
when "-" is already mapped.
This commit is contained in:
Barrett Ruth
2026-07-16 13:26:01 -05:00
committed by GitHub
parent c15ac3d64c
commit 9edf57e665
3 changed files with 60 additions and 15 deletions

View File

@@ -185,8 +185,15 @@ local function set_maps(buf)
vim.keymap.set('n', lhs, plug, { buffer = buf, silent = true })
end
end
---@param lhs string
---@param plug string
local function default_map(lhs, plug)
if vim.fn.mapcheck(lhs, 'n') == '' and vim.fn.hasmapto(plug, 'n') == 0 then
vim.keymap.set('n', lhs, plug, { buffer = buf, silent = true })
end
end
map('<CR>', '<Plug>(nvim-dir-open)')
map('-', '<Plug>(nvim-dir-up)')
default_map('-', '<Plug>(nvim-dir-up)')
map('R', '<Plug>(nvim-dir-reload)')
end