Closed esn89 closed 5 months ago
I'm very confused by this bug report. You're mentioning using :tcd
to change directories, but you're running pwd in the shell (:!pwd
) instead of getting vim's cwd (:pwd
or :=vim.fn.getcwd()
). I also don't see how oil plays into this at all if you're just issuing vim commands.
Could you provide the exact steps you are taking, the exact commands you are running, and what the output is?
Hi @stevearc
What I mean by this is:
I had expected that the :tcd would also change the directory from where I opened up neovim
.
So say I opened up vim in ~/Documents/Projects/app1, if I :tcd upwards, pwd should show ~/Documents/Projects
This should absolutely be the case. If you run
nvim --clean
:pwd
:tcd ..
:pwd
I will be shocked if the second pwd
doesn't show the parent directory of the first.
Again, I'm not quite sure what this has to do with oil.nvim?
I have a similar problem.
Sometimes when i use the Oil keymap for actions.cd
it does nothing
@stevearc
Yes, when I run your following 4 commands, it does EXACTLY what I need!
However, in oil.nvim, not so much. And similar to @eric-marin , actions.cd
does nothing for me as well.
In that case I will ask for what is requested in the bug report form:
repro.lua
file that is a full, minimal config. A template is provided to make it easy for you.For me, the bug only occurs when I open a file directly from dashboard-nvim, so it might be a dashboard issue.
@stevearc
cat repro.lua
-- save as repro.lua
-- run with nvim -u repro.lua
-- DO NOT change the paths
local root = vim.fn.fnamemodify('./.repro', ':p')
-- set stdpaths to use .repro
for _, name in ipairs({ 'config', 'data', 'state', 'runtime', 'cache' }) do
vim.env[('XDG_%s_HOME'):format(name:upper())] = root .. '/' .. name
end
-- bootstrap lazy
local lazypath = root .. '/plugins/lazy.nvim'
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
'git',
'clone',
'--filter=blob:none',
'--single-branch',
'https://github.com/folke/lazy.nvim.git',
lazypath,
})
end
vim.opt.runtimepath:prepend(lazypath)
-- install plugins
local plugins = {
'folke/tokyonight.nvim',
{
'stevearc/oil.nvim',
config = function()
require('oil').setup({
-- add any needed settings here
{
default_file_explorer = true,
columns = {
'icon',
},
keymaps = {
['<C-v>'] = 'actions.select_vsplit',
['<C-s>'] = 'actions.select_split',
['<C-f>'] = 'actions.preview_scroll_up',
['<C-b>'] = 'actions.preview_scroll_down',
['<C-i'] = 'actions.cd',
['<C-o'] = 'actions.tcd',
},
preview = {
-- Width dimensions can be integers or a float between 0 and 1 (e.g. 0.4 for 40%)
-- min_width and max_width can be a single value or a list of mixed integer/float types.
-- max_width = {100, 0.8} means "the lesser of 100 columns or 80% of total"
max_width = 0.9,
-- min_width = {40, 0.4} means "the greater of 40 columns or 40% of total"
min_width = { 40, 0.4 },
-- optionally define an integer/float for the exact width of the preview window
width = nil,
-- Height dimensions can be integers or a float between 0 and 1 (e.g. 0.4 for 40%)
-- min_height and max_height can be a single value or a list of mixed integer/float types.
-- max_height = {80, 0.9} means "the lesser of 80 columns or 90% of total"
max_height = 0.9,
-- min_height = {5, 0.1} means "the greater of 5 columns or 10% of total"
min_height = { 5, 0.1 },
-- optionally define an integer/float for the exact height of the preview window
height = nil,
border = 'rounded',
win_options = {
winblend = 0,
},
-- Whether the preview window is automatically updated when the cursor is moved
update_on_cursor_moved = true,
},
},
})
end,
},
-- add any other plugins here
}
require('lazy').setup(plugins, {
root = root .. '/plugins',
})
vim.cmd.colorscheme('tokyonight')
-- add anything else here
Here I entered into ~/venv:
img And oil says that I am in venv.
So I tried hitting the ` and the ~ and it does nothing.
So I just hit enter and went inside of it. And that is when I did :pwd:
But still shows that I am in ~
Here are my steps with the repro file you gave
cd /private/tmp
mkdir -p testdir
nvim -u repro.lua .
:pwd
/private/tmp
testdir/
and <CR>
to enter the directory:pwd
/private/tmp/testdir
:!pwd
/private/tmp/testdir
Nothing surprising, everything working as intended. Can you provide equally detailed steps that you are taking, with the associated output?
Aaaaaaaah. Okay, so this is me using it wrong.
I did not know that I had to first ENTER the directory with
I thought that by pressing `, it will enter & :cd into it.
My bad.
Did you check the docs and existing issues?
Neovim version (nvim -v)
NVIM v0.10.0
Operating system/version
MacOS 14.5
Describe the bug
:cd and :tcd does not actually change directories.
Before, I am in
~/.config/nvim/lua/plugins
: withpwd
showing thatThen, I do
:tcd
into the oil dir:.
The top right gets updated. But when I do
pwd
it is still in the same dirWhat is the severity of this bug?
breaking (some functionality is broken)
Steps To Reproduce
Expected Behavior
I expect the directory to be changed and reflected in
pwd
Directory structure
No response
Repro
Did you check the bug with a clean config?
nvim -u repro.lua
using the repro.lua file above.