The ConqueTerm Vim plugin provides GUI-based instances of Vim with a fairly robust terminal emulation. It requires Vim 7.0+ (7.3+ for Windows) compiled with +python
or +python3
; MacVim satisfies these requirements.
Here is a function and binding that re-implements the functionality of the normal-mode K
command using ConqueTerm (you can put it in your .vimrc
):
:function! ConqueMan()
let cmd = &keywordprg . ' '
if cmd ==# 'man ' || cmd ==# 'man -s '
if v:count > 0
let cmd .= v:count . ' '
else
let cmd = 'man '
endif
endif
let cmd .= expand('<cword>')
execute 'ConqueTermSplit' cmd
:endfunction
:map K :<C-U>call ConqueMan()<CR>
:ounmap K
After a few hours of diving into a wide variety of GitHub issues and man-pages I've found a setup that works for me, achieving what I believe you set out to achieve.
I am using rxvt-unicode v9.22, tmux 2.9a, neovim v0.4.2 and zsh 5.7.1 under Arch Linux.
My setup is configured to use non-blinking beam cursor in insert mode, and non-blinking block cursor in normal mode.
For zsh, I use vi-mode with the following in my .zshrc:
bindkey -v
export KEYTIMEOUT=1
# Change cursor with support for inside/outside tmux
function _set_cursor() {
if [[ $TMUX = '' ]]; then
echo -ne $1
else
echo -ne "\ePtmux;\e\e$1\e\\"
fi
}
function _set_block_cursor() { _set_cursor '\e[2 q' }
function _set_beam_cursor() { _set_cursor '\e[6 q' }
function zle-keymap-select {
if [[ ${KEYMAP} == vicmd ]] || [[ $1 = 'block' ]]; then
_set_block_cursor
else
_set_beam_cursor
fi
}
zle -N zle-keymap-select
# ensure beam cursor when starting new terminal
precmd_functions+=(_set_beam_cursor) #
# ensure insert mode and beam cursor when exiting vim
zle-line-init() { zle -K viins; _set_beam_cursor }
For my tmux configuration, the only important lines are:
set -g default-terminal "tmux-256color"
set -ga terminal-overrides '*:Ss=\E[%p1%d q:Se=\E[ q'
To make sure that neovim behaves correctly for urxvt, $TERM needs to be correct. I do this with .Xresources with the following line (don't forget to merge afterwards with xrdb -merge ~/.Xresources
):
URxvt*termName: rxvt-256color
Now for neovim, no configuration should be necessary, other than making sure not to tamper with guicursor
. Some GitHub issues mention setting set guicursor=
in your init.vim, however my setup does not work if I add that.
Hope this setup is reproducible given what I've provided, otherwise my dotfiles are available on GitHub.
Best Answer
You might try the patch mentioned in a related thread (“OSX 10.6.5 , Terminal.app, iTerm.app pbpaste, pbcopy do not work under tmux”) from the tmux-users mailing list (actually hosted at sf.net, but I abhor their archive interface).
Note: the patch was, at one time, applied to the MacPorts port, but it was later reverted when it was suspected to be causing other errors. However, those errors might have actually been caused by liking against the wrong version of libevent (and it seems that recent versions of tmux will work with either version of libevent).
Since helgeg brought it up, I’ll mention my notes on my attempt to use the above referenced patch.
Summary: I found the patch unreliable. It allowed pasteboard access, but it triggered many warning messages from my installation of libevent version 2 (maybe version 1 is less affected). It also prevents the tmux server from doing its normal fork(2) (via daemon(3)), which is a significant change to how the server process was designed to work.
I ended up publishing a program that works around the problem without patching tmux. People that have had problems using the pasteboard under tmux (and those for which the above patch does not work satisfactorily) might want to give my workaround a try.