refactor(defaults): edit global cwd on "1-" #41254

Problem:
`1-` does nothing from a directory buffer, because we are already in the
buffer-local CWD. It's also unintuitive that this mapping behaves
differently based on the resolved CWD.

Solution:
Have `1-` open the global CWD.
This commit is contained in:
Nathan Zeng
2026-08-11 01:08:33 -07:00
committed by GitHub
parent 2757f6eef9
commit 4a3197f2ad
3 changed files with 10 additions and 2 deletions

View File

@@ -64,7 +64,7 @@ To disable the built-in directory browser, set this before startup: >lua
GLOBAL MAPPINGS *dir-mappings*
• - opens the parent directory of the current file or directory.
• {count}- is like -, but a count of 1 opens the current working directory,
• {count}- is like -, but a count of 1 opens the global working directory,
and a higher count goes up that many levels.
BUFFER-LOCAL MAPPINGS *dir-buffer-mappings*

View File

@@ -12,9 +12,10 @@ end, { silent = true, desc = 'Open directory entry' })
vim.keymap.set('n', '<Plug>(nvim-dir-up)', function()
if vim.v.count == 1 then
-- Edits global CWD
api.nvim_cmd({
cmd = 'edit',
args = { '.' },
args = { vim.fn.getcwd(-1, -1, -1) },
mods = { keepalt = vim.b.nvim_dir ~= nil },
magic = { file = false, bar = false },
}, {})

View File

@@ -433,6 +433,13 @@ describe('nvim.dir', function()
assert_directory(cwd)
edit(file)
feed('-')
poke_eventloop()
feed('1-')
poke_eventloop()
assert_directory(cwd)
edit(file)
feed('2-')
poke_eventloop()