From 9edf57e665820c5dff20425236fb309c4fb48ff6 Mon Sep 17 00:00:00 2001 From: Barrett Ruth <62671086+barrettruth@users.noreply.github.com> Date: Thu, 16 Jul 2026 13:26:01 -0500 Subject: 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. --- runtime/lua/nvim/dir.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'runtime/lua/nvim/dir.lua') diff --git a/runtime/lua/nvim/dir.lua b/runtime/lua/nvim/dir.lua index 3448fb3eab..daf5bd7a09 100644 --- a/runtime/lua/nvim/dir.lua +++ b/runtime/lua/nvim/dir.lua @@ -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('', '(nvim-dir-open)') - map('-', '(nvim-dir-up)') + default_map('-', '(nvim-dir-up)') map('R', '(nvim-dir-reload)') end -- cgit