@acandael Can you please open an issue on the vim-tmux-navigator
repo rather than posting in this thread?
hi,
when I run run Rspec from within Vim, my spec file is replaced with a new window that runs the spec file. When I hit return I return to the spec file. However I would prefer that the spec is run in a new pane, like in the tutorial video.
I installed the .dotfiles with the Thoughtbot Laptop script.
In my .vimrc file the following lines specify the vim-rspec configuration:
" vim-rspec mappings
nnoremap <Leader>t :call RunCurrentSpecFile()<CR>
nnoremap <Leader>s :call RunNearestSpec()<CR>
nnoremap <Leader>l :call RunLastSpec()<CR>
am I missing something?
Thanks for your help,
Anthony
Likely. dispatch.vim
.
Thanks Ben. Yesterday I found this blog post on dispatch.vim:
greetings,
Anthony
When I use Vim from within tmux, the delete key (or Ctrl-H
) sends a ^?
character instead of a backspace, i.e.:
YOU WILL BE DELETED^?^?^?^?^?^?^?^?
This doesnāt happen elsewhere in tmux, not does it happen in Vim outside tmux. This is surely related to my other problem with Ctrl-H failing to switch panes. As was the case there, toggling the Delete Sends Ctrl-H
setting has no effect here. Any idea what the ^?
is or whatās wrong with my Ctrl-H
?
@captain_zoom not sure what the specific issue is, but if you are only seeing this behavior in Vim, you can check what the mapping in Vim is by running: nmap <C-h>
.
Other things to look at would be comparing the behavior in and out of tmux, and looking into your tmux mappings if youāre using Vim-Tmux-Navigator.
Thanks @christoomey ā I just removed all the <c-h>
mappings in my .vimrc, and the problem persists. I now have:
:imap <c-h>
no mapping found
:nmap <c-h>
no mapping found
:map <c-h>
s <C-H> * <C-G>c
I can remove that last mapping by typing unmap <c-h>
, but that doesnāt change anything. (Interestingly, unmap <c-h>
doesnāt work when itās the last line in my .vimrc. Somehow that mapping is getting set after .vimrc loads?)
Regardless, I donāt think a mapping is the problem, because the problem is unique to Vim inside tmux. I have no issues (with or without my normal C-h
mappings) in gui MacVim, terminal MacVim, or the default Vim, as long as they are run outside of tmux. Not using Vim-Tmux-Navigator at the moment.
I have applied some the tmux and vim configuration in this course. But now when I use vim inside iTerm but outside of tmux, every time I leave insert mode the string tmux; is inserted in the current buffer.
This only happens inside the terminal NOT in Macvim.
Any clues?
Hello @geraldspreer, Not sure what the cause of that would be, although you can likely rule out the tmux.conf file as you said this is happening outside of tmux. I would try disabling parts of the new configuration to try to lock down what line is causing it.
Found the solution:
Updated my .vimrc to:
if exists('$TMUX')
let &t_SI = "\<Esc>[3 q"
let &t_EI = "\<Esc>[0 q"
" these two lines were outside the if statement
" putting them here solves this issue although the cursor shape stays
" the same in any mode outside tmux - but that's OK.
let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\"
let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\"
endif
Thank you for pointing me towards this.
Hi @geraldspreer, are you using Neovim? Neovim had an issue until very recent builds, but even if you arenāt using Neovim thereās some interesting info about terminal types and emulation. Hereās the issue report:
I had this issue only in tmux for a while. I mapped <C-h>
to be the backspace key in normal mode to work around it until the recent fix.
Thanks for the hint.
When I try to run the specs in the current file, vim-rspec seems to be getting the path wrong. It assumes the path to be
/path/to/project/root/current_spec.rb
and not
/path/to/project/root/spec/subdir/current_spec.rb
This is even if I cd to the spec fileās subdirectory and launch vim with the spec as a command line argument. At first I thought it was because I was finding the file with Ctrl-P, but thatās not it.
EDIT: Actually, Iām wrong. If I launch vim in the subdirectory containing the spec file, when Vim-Rspec passes off that filename, RSpec has no problem loading it. BUT in this case, Rspec canāt load ārails_helperā which is in the require line of that spec file. So if Iām in project root, vim-rspec isnāt telling Rspec where the spec file is located ā itās just letting RSpec assume that itās the same directory from which vim was launched. And if launched from the subdirectory, Rspec doesnāt know where to look for the helper files. Either way, the lack of awareness of where the file is located is fatal.
Note that running āAll Specsā works just fine. Itās just the commands that require a specific filename that are getting broken.
@MatthewMDavis, have you tried running from the root?
For reference, rspec.vim uses @% to determine the file path. You can confirm the output by running :echo @%
in Vim. This should match the path you would need to run in vim.
One other setting to look at is autochdir
. You can determine the value by running :verbose set autochdir?
. Youāll either see noautochdir
, or the last file that set it. If set, that could be interfering.
I had just found out that a directory switch within vim was causing my problem right before I saw your message, and now I know what .vimrc setting was doing it to me: yes, vim was autochdirāing to the spec fileās directory, and vim in turn was spawning a tmux runner pane, in a subdirectory where rspec didnāt know how to locate rails_helper.
Having turned off autochdir, things are working as expected (as long as Iām working in the Rails project root).
That was a bear of a morning. Thanks for your help. Nice course, too. I donāt know if Iāll spend 100% of my time in Tmux, but the number is definitely going way up.
Happy to help! If youāre anything like me then tmuxās addictive efficiency will soon take you over.
Great job @christoomey ! Really !
But iāve got a problem with vim-tmux-runner.
When I try to launch RunNearestSpec, Iāve got an error in the runner pane :
^Lrspec spec/models/
There is a ^L before the command !
How can I fix it ?
(FYI, when iām using :VtrSendLinesToRunner, there is no problem at all, it works)
Thanks for your answer
Hello @krichtof, thanks for the kind words!
The ^L
is purposeful, it is meant to clear the terminal before running the command but it seems like your terminal is not interpreting the ^L
as a clear.
Not sure why this is, but you can change the keys used to clear by changing the VtrClearSequence or disable this entirely with the VtrClearBeforeSend setting.
Thanks for your answer. When I disable the VtrClear, it works
Hi @christoomey, thanks for putting this together, itās pretty awesome.
Iāve always used C-l to clear the terminal and C-k to delete the rest of the line Iām on. With the tmux key bindings that you have setup to navigate panes, those keystrokes are being caught by tmux and never making it to the terminal. I was thinking that I could create a config where hitting C-l C-l would do the same thing, but that gets complicated with the vim integration that was just added. Any suggestions?
Thanks.