voldikss / vim-floaterm

:computer: Terminal manager for (neo)vim
MIT License
2.47k stars 78 forks source link

toggle floaterm in current file directory instead of working directory? #352

Open shaeinst opened 2 years ago

shaeinst commented 2 years ago

gone through the docs and reamdme but didn't find what i am looking for. So, is there any way to toggle floaterm in current file directory (directory of current buffer) instead of working directory?

QiangZiBro commented 1 year ago

This can be achieved in command mode by:

:FloatermNew --cwd %:h

where, %:h refers to full path to current file without filename itself. Check link here to know how files/directories are named in vim.

QiangZiBro commented 1 year ago

A shortcut for this feature is also nice, I use <leader>7

noremap <silent><leader>7   :FloatermNew --cwd %:h<CR>
shaeinst commented 1 year ago

i use penvim to detect and change working directory to project root directory. :FloatermNew --cwd %:h<CR> don't work. it just opens the floaterm to root directory instead of current file directory

QiangZiBro commented 1 year ago

Just checked, only :FloatermNew --cwd=<buffer> works, and :FloatermNew --cwd <buffer> still open in <root>