FTerm.nvim
FTerm.nvim copied to clipboard
Automatic CWD on every enter.
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.