Closed teranex closed 4 years ago
Does d64f3e0 help?
No this doesn't seem to make any difference.
I added some :echom
statements and it seems the &buftype
is empty for a terminal as well.
That doesn't sound right. &buftype
should be terminal
in a terminal window (see :help buftype
and :help options-in-terminal
). I just tried it on vim and nvim and it was terminal
.
Having said that, in vim at least it seems that when :terminal
opens a terminal window in a split and moves the cursor there, the buftype
is not set until after vim-rooter's autocmd has been triggered. Therefore it looks like we cannot detect a new terminal window in a BufEnter
autocmd.
If that's true, the only solution I can think of is for vim-rooter to store the directory it is changing from, whenever it changes directory, and to add a Term(inal)Open
autocmd which changes back to that previous directory (and then clears the variable holding it). It's very much a workaround rather than a clean solution.
I came up with a different solution: a RooterToggle
-command to temporarily disable Rooter. Then the vim-terminal-helper can be wrapper with a RooterToggle
at the beginning and one at the end.
So far it seems to work. It could also be useful in other cases, for example in combination with the Fzf :Files
command to switch to another directory.
I have sent a pull request: https://github.com/airblade/vim-rooter/pull/106
I added :RooterToggle
in 4119f48.
The vim-terminal-help plugin (https://github.com/skywind3000/vim-terminal-help) let's you quickly open a Vim terminal set to the current directory of the file you are currently editing. However in combination with vim-rooter the shell inside the terminal always is set to the root of the project. I guess it is probably somehow possible to exclude terminal buffers from the rooter autocmd, but it's not clear to me how it can be done.