Open ArtAndreev opened 11 months ago
Well, netrw has the same behavior, nvim-tree too (issue https://github.com/nvim-tree/nvim-tree.lua/issues/2127)
Maybe issue should be converted from bug to feature request.
a workaround for now can be adding a autocmd like this in your config:
-- oil fix relative path
vim.api.nvim_create_augroup('OilRelPathFix', {})
vim.api.nvim_create_autocmd("BufLeave", {
group = 'OilRelPathFix',
pattern = "oil:///*",
callback = function ()
vim.cmd("cd .")
end
})
Did you check the docs and existing issues?
Neovim version (nvim -v)
v0.9.4
Operating system/version
macOS 14.1.1 (23B81)
Describe the bug
Oil
opens new buffers with files, that are relative to current nvim working directory, using their absolute paths. Better to understand by looking at example below.I expect relative paths, because files are relative and some code expects these buffers to have relative paths in names too.
Steps To Reproduce
nvim -u repro.lua file1
:echo expand('%')
| This printsfile1
.:Oil
file2
(j
), press<CR>
:echo expand('%')
| This prints/Users/<username>/path/to/cwd/file2
.Expected Behavior
Expected printed buffer names after calling
expand
:file1
file2
Directory structure
file1 file2
Repro
Did you check the bug with a clean config?
nvim -u repro.lua
using the repro.lua file above.