aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/nvim/dir.lua
diff options
context:
space:
mode:
authorBarrett Ruth <62671086+barrettruth@users.noreply.github.com>2026-07-16 13:26:01 -0500
committerGitHub <noreply@github.com>2026-07-16 14:26:01 -0400
commit9edf57e665820c5dff20425236fb309c4fb48ff6 (patch)
treed30c52db6c6a7f96f695f3b1378e4249986747ae /runtime/lua/nvim/dir.lua
parentc15ac3d64cb41fb9da03d520a4d2bdbf8ba01c52 (diff)
downloadrneovim-9edf57e665820c5dff20425236fb309c4fb48ff6.tar.gz
rneovim-9edf57e665820c5dff20425236fb309c4fb48ff6.tar.bz2
rneovim-9edf57e665820c5dff20425236fb309c4fb48ff6.zip
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.
Diffstat (limited to 'runtime/lua/nvim/dir.lua')
-rw-r--r--runtime/lua/nvim/dir.lua9
1 files changed, 8 insertions, 1 deletions
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('<CR>', '<Plug>(nvim-dir-open)')
- map('-', '<Plug>(nvim-dir-up)')
+ default_map('-', '<Plug>(nvim-dir-up)')
map('R', '<Plug>(nvim-dir-reload)')
end