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:
@@ -1,5 +1,9 @@
|
||||
let s:tmux_option = '@vim'.substitute($TMUX_PANE, '%', '\\%', 'g')
|
||||
|
||||
function! tmux#inSession() abort
|
||||
return $TMUX !=# ''
|
||||
endfunction
|
||||
|
||||
function! tmux#setNavigationFlag() abort
|
||||
call system('tmux set-window-option '.s:tmux_option.' 1')
|
||||
endfunction
|
||||
@@ -7,3 +11,11 @@ endfunction
|
||||
function! tmux#unsetNavigationFlag() abort
|
||||
call system('tmux set-window-option -u '.s:tmux_option)
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user