Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic CWD on every enter. #98

Open
bogdan-the-great opened this issue Nov 30, 2023 · 2 comments
Open

Automatic CWD on every enter. #98

bogdan-the-great opened this issue Nov 30, 2023 · 2 comments

Comments

@bogdan-the-great
Copy link

bogdan-the-great commented Nov 30, 2023

Hi, I tried setting up this terminal so it will automatically enter cwd on the current buffer when is opened, but cannot achieve it. Here' s what I tried:

-- this opens normally but doesn't change cwd
vim.api.nvim_create_user_command('FTermToggle', require('FTerm').toggle, { bang = true })

vim.keymap.set('n', '<C-\\>', '<CMD>FTermToggle<CR>')
vim.keymap.set('t', '<C-\\>', '<CMD>FTermToggle<CR>')
-- returns: `No such group or event: FTermToggle * :lcd%:p:h`
vim.cmd("autocmd! FTermToggle * :lcd%:p:h")
-- returns `Invalid 'event': 'FTermToggle'`
vim.api.nvim_create_autocmd("FTermToggle", {
     pattern = "*",
     callback = function()
     vim.cmd('cd ' .. vim.loop.cwd())
end,
})

And tried setting cmd option to:

cmd = os.getenv('SHELL') .. ' -c "cd ' .. vim.cmd(':lcd%:p:h')  .. '"'

But nothing works like it should. Also I have enabled autochdir but it doesn't do anything.

@ilan-schemoul
Copy link

ilan-schemoul commented Jun 17, 2024

I would love to use cwd of current buffer too. Did you manage to do it ?

@bogdan-the-great
Copy link
Author

I don't use any terminal in Neovim right now, but when I deleted all stuff connected to it, my file manager (in Neovim) is now always on cwd of the current buffer (when previously sometimes it would not change).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants