Refactor tmux and set-clipboard detection
Move logic to `autoload/tmux.vim` to detect the `vim` is being run inside a `tmux` sessions and if the `set-clipboard` option is enabled. This cleans up adding the optional `oscyank.vim` plugin when needed.
This commit is contained in:
parent
76acb9cd90
commit
c17f7ea0d9
@ -1,5 +1,9 @@
|
|||||||
let s:tmux_option = '@vim'.substitute($TMUX_PANE, '%', '\\%', 'g')
|
let s:tmux_option = '@vim'.substitute($TMUX_PANE, '%', '\\%', 'g')
|
||||||
|
|
||||||
|
function! tmux#inSession() abort
|
||||||
|
return $TMUX !=# ''
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! tmux#setNavigationFlag() abort
|
function! tmux#setNavigationFlag() abort
|
||||||
call system('tmux set-window-option '.s:tmux_option.' 1')
|
call system('tmux set-window-option '.s:tmux_option.' 1')
|
||||||
endfunction
|
endfunction
|
||||||
@ -7,3 +11,11 @@ endfunction
|
|||||||
function! tmux#unsetNavigationFlag() abort
|
function! tmux#unsetNavigationFlag() abort
|
||||||
call system('tmux set-window-option -u '.s:tmux_option)
|
call system('tmux set-window-option -u '.s:tmux_option)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! tmux#isSetClipboardOn() abort
|
||||||
|
if !tmux#inSession()
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
let l:set_clipboard = trim(system('tmux show-options -g set-clipboard'))
|
||||||
|
return l:set_clipboard ==# 'set-clipboard on'
|
||||||
|
endfunction
|
||||||
|
@ -77,7 +77,7 @@ nnoremap <leader>tm :tabmove<Space>
|
|||||||
" Clear search highlights
|
" Clear search highlights
|
||||||
nnoremap <leader><Space> :nohlsearch<CR>
|
nnoremap <leader><Space> :nohlsearch<CR>
|
||||||
|
|
||||||
if g:use_osc52
|
if exists('loaded_oscyank')
|
||||||
noremap <leader>y :Oscyank<CR>
|
noremap <leader>y :Oscyank<CR>
|
||||||
else
|
else
|
||||||
" System clipboard yank/put
|
" System clipboard yank/put
|
||||||
|
4
vimrc
4
vimrc
@ -200,9 +200,7 @@ Pack 'jrozner/vim-antlr'
|
|||||||
|
|
||||||
" Plugins for remote integrations
|
" Plugins for remote integrations
|
||||||
Pack 'greymd/oscyank.vim', {'type': 'opt'}
|
Pack 'greymd/oscyank.vim', {'type': 'opt'}
|
||||||
let g:use_osc52 = $TMUX !=# '' &&
|
if tmux#isSetClipboardOn()
|
||||||
\ trim(system('tmux show-options -g set-clipboard')) ==# 'set-clipboard on'
|
|
||||||
if g:use_osc52 && isdirectory(expand('~/.vim/pack/minpac/opt/oscyank.vim'))
|
|
||||||
packadd oscyank.vim
|
packadd oscyank.vim
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user