From a6889b4bf4327b89086f53946d7c5dff7fd3eb25 Mon Sep 17 00:00:00 2001 From: "Fabio M. Costa" Date: Wed, 15 May 2013 14:42:38 -0600 Subject: [PATCH 001/138] Updating README with new style Vimux prefixed commands --- README.mkd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.mkd b/README.mkd index abe5471..691a651 100644 --- a/README.mkd +++ b/README.mkd @@ -6,7 +6,7 @@ Easily interact with tmux from vim. What inspired me to write vimux was [tslime.vim](https://github.com/kikijump/tslime.vim), a plugin that lets you send input to tmux. While tslime.vim works well, I felt it wasn't optimized for my primary use case which was having a smaller tmux pane that I would use to run tests or play with a REPL. -My goal with vimux is to make interacting with tmux from vim effortless. By default when you call `RunVimTmuxCommand` vimux will create a 20% tall horizontal pane under your current tmux pane and execute a command in it without losing focus of vim. Once that pane exists whenever you call `RunVimTmuxCommand` again the command will be executed in that pane. As I was using vimux myself I wanted to rerun commands over and over. An example of this was running the current file through rspec. Rather than typing that over and over I wrote `RunLastVimTmuxCommand` that will execute the last command you called with `RunVimTmuxCommand`. +My goal with vimux is to make interacting with tmux from vim effortless. By default when you call `VimuxRunCommand` vimux will create a 20% tall horizontal pane under your current tmux pane and execute a command in it without losing focus of vim. Once that pane exists whenever you call `VimuxRunCommand` again the command will be executed in that pane. As I was using vimux myself I wanted to rerun commands over and over. An example of this was running the current file through rspec. Rather than typing that over and over I wrote `VimuxRunLastCommand` that will execute the last command you called with `VimuxRunCommand`. Other auxiliary functions and the ones I talked about above can be found bellow with a full description and example key binds for your vimrc. From b409314c80c1877adbab1c1341a7e45032275215 Mon Sep 17 00:00:00 2001 From: Anyakichi Date: Tue, 21 May 2013 23:12:59 +0900 Subject: [PATCH 002/138] Escape a semicolon at the end of input. Avoid tmux treating it as a separator. --- plugin/vimux.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 99871f4..1f0163c 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -322,7 +322,7 @@ class TmuxSession end def _escape_command(command) - command.gsub('"', '\"').gsub('$', '\$') + command.gsub('"', '\"').gsub('$', '\$').sub(/;\z/, '\;') end def _run(command) From 6dd26fe7c304f6a3c96ebfe7fc386dc8505d679d Mon Sep 17 00:00:00 2001 From: Ben Mills Date: Thu, 23 May 2013 09:54:57 -0600 Subject: [PATCH 003/138] Update README.mkd --- README.mkd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.mkd b/README.mkd index 691a651..d65edf7 100644 --- a/README.mkd +++ b/README.mkd @@ -2,7 +2,7 @@ Easily interact with tmux from vim. -![vimux](https://www.braintreepayments.com/assets-faccd47687/assets/images/blog/vimux3.png) +![vimux](https://www.braintreepayments.com/assets-a5fdbbf08b/assets/images/blog/vimux3.png) What inspired me to write vimux was [tslime.vim](https://github.com/kikijump/tslime.vim), a plugin that lets you send input to tmux. While tslime.vim works well, I felt it wasn't optimized for my primary use case which was having a smaller tmux pane that I would use to run tests or play with a REPL. From 70433ed91b1c893fe6550d690b5964670e95182b Mon Sep 17 00:00:00 2001 From: Ben Mills Date: Tue, 18 Jun 2013 09:24:24 -0600 Subject: [PATCH 004/138] Remove ruby requirement in README. --- README.mkd | 1 - 1 file changed, 1 deletion(-) diff --git a/README.mkd b/README.mkd index d65edf7..6ebce05 100644 --- a/README.mkd +++ b/README.mkd @@ -18,7 +18,6 @@ Otherwise download the latest [tarball](https://github.com/benmills/vimux/tarbal _Notes:_ -* Vimux requires vim with compiled ruby support. You can confirm you have ruby support by running `vim --version | grep +ruby`. * Vimux assumes a tmux version >= 1.5. Some older versions might work but it is recommeded to use at least version 1.5. ## Platform-specific Plugins From 1a0a8abe713f08cd482bc9b9deaecb7c62cdc684 Mon Sep 17 00:00:00 2001 From: David Davis Date: Wed, 3 Jul 2013 10:18:24 -0400 Subject: [PATCH 005/138] Fix out of range error Fix the following error. This fixes #72. E684: list index out of range: 1 E116: Invalid arguments for function match(panes[i], "(active)") == -1 E15: Invalid expression: match(panes[i], "(active)") == -1 --- plugin/vimux.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 6bcdde4..0459b3b 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -121,9 +121,9 @@ endfunction function! _VimuxNearestPaneIndex() let panes = split(system("tmux list-panes"), "\n") - for i in panes - if match(panes[i], "(active)") == -1 - return split(panes[i], ":")[0] + for pane in panes + if match(pane, "(active)") == -1 + return split(pane, ":")[0] endif endfor From 71b2ac31de56c6c0e23adba028c70aa35d42fb38 Mon Sep 17 00:00:00 2001 From: Jason Bellamy Date: Fri, 5 Jul 2013 11:17:01 -0400 Subject: [PATCH 006/138] Fixed a typo in the *VimuxOpenPane* section of the doc. --- doc/vimux.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/vimux.txt b/doc/vimux.txt index df6d305..c70c44f 100644 --- a/doc/vimux.txt +++ b/doc/vimux.txt @@ -109,7 +109,7 @@ use this command to send keys such as "Enter" or "C-c" to the runner pane. *VimuxOpenPane* VimuxOpenPane~ -This will either opne a new pane or use the nearest pane and set it as the +This will either open a new pane or use the nearest pane and set it as the vimux runner pane for the other vimux commands. You can control if this command uses the nearest pane or always creates a new one with g:VimuxUseNearestPane From be0a60ec701c9a8d124ea677aca89a88e2ad03df Mon Sep 17 00:00:00 2001 From: Ben Mills Date: Sun, 25 Aug 2013 10:28:07 -0700 Subject: [PATCH 007/138] Fix broken image in README. --- README.mkd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.mkd b/README.mkd index 6ebce05..5add096 100644 --- a/README.mkd +++ b/README.mkd @@ -2,7 +2,7 @@ Easily interact with tmux from vim. -![vimux](https://www.braintreepayments.com/assets-a5fdbbf08b/assets/images/blog/vimux3.png) +![vimux](https://www.braintreepayments.com/assets/images/blog/vimux3.png) What inspired me to write vimux was [tslime.vim](https://github.com/kikijump/tslime.vim), a plugin that lets you send input to tmux. While tslime.vim works well, I felt it wasn't optimized for my primary use case which was having a smaller tmux pane that I would use to run tests or play with a REPL. From 635b800f22099293740020ff8c1ed9ddeab7e3eb Mon Sep 17 00:00:00 2001 From: cmar Date: Sat, 31 Aug 2013 14:14:39 -0400 Subject: [PATCH 008/138] add VimuxZoomRunner() to zoom the runner pane on Tmux 1.8 --- doc/vimux.txt | 25 +++++++++++++++++++++---- plugin/vimux.vim | 8 ++++++++ 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/doc/vimux.txt b/doc/vimux.txt index c70c44f..b14ebc1 100644 --- a/doc/vimux.txt +++ b/doc/vimux.txt @@ -15,6 +15,7 @@ CONTENTS *vimux-contents* 2.5 .............................. |VimuxClosePanes| 2.6 .............................. |VimuxInterruptRunner| 2.7 .............................. |VimuxClearRunnerHistory| + 2.8 .............................. |VimuxZoomRunner| 3. Misc ............................ |VimuxMisc| 3.1 Example Keybinding............ |VimuxExampleKeybinding| 3.2 Tslime Replacement............ |VimuxTslimeReplacement| @@ -72,6 +73,7 @@ Furthermore there are several handy commands all starting with 'Vimux': - |VimuxInterruptRunner| - |VimuxPromptCommand| - |VimuxClearRunnerHistory| + - |VimuxZoomRunner| ------------------------------------------------------------------------------ *VimuxRunCommand* @@ -179,6 +181,18 @@ you enter tmux scroll mode inside the runner pane. vc :VimuxClearRunnerHistory < +------------------------------------------------------------------------------ + *VimuxZoomRunner* +VimuxZoomRunner~ + +Zoom the runner pane. Once its zoomed, you will need +to use tmux " z" to restore the runner pane. +Zoom requires tmux version >= 1.8 +> + + " Zoom the tmux runner page + vz :VimuxZoomRunner +< ============================================================================== MISC (3) *VimuxMisc* @@ -193,18 +207,21 @@ Full Keybind Example~ " Prompt for a command to run map vp :VimuxPromptCommand - + " Run last command executed by VimuxRunCommand map vl :VimuxRunLastCommand - + " Inspect runner pane map vi :VimuxInspectRunner - + " Close vim tmux runner opened by VimuxRunCommand map vq :VimuxCloseRunner - + " Interrupt any command running in the runner pane map vx :VimuxInterruptRunner + + " Zoom the runner pane (use z to restore runner pane) + map vz :call VimuxZoomRunner() > ------------------------------------------------------------------------------ diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 0459b3b..3f65345 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -5,6 +5,7 @@ let g:loaded_vimux = 1 command VimuxRunLastCommand :call VimuxRunLastCommand() command VimuxCloseRunner :call VimuxCloseRunner() +command VimuxZoomRunner :call VimuxZoomRunner() command VimuxInspectRunner :call VimuxInspectRunner() command VimuxScrollUpInspect :call VimuxScrollUpInspect() command VimuxScrollDownInspect :call VimuxScrollDownInspect() @@ -74,6 +75,13 @@ function! VimuxCloseRunner() endif endfunction +function! VimuxZoomRunner() + if exists("g:VimuxRunnerPaneIndex") + call system("tmux resize-pane -Z -t ".g:VimuxRunnerPaneIndex) + unlet g:VimuxRunnerPaneIndex + endif +endfunction + function! VimuxInspectRunner() call system("tmux select-pane -t ".g:VimuxRunnerPaneIndex) call system("tmux copy-mode") From 49a048e94e6a027f485420a63d6c930523fc57b1 Mon Sep 17 00:00:00 2001 From: Ryan Glover Date: Sat, 28 Sep 2013 16:32:35 -0400 Subject: [PATCH 009/138] Change variable and function names to be pane/window agnostic --- plugin/vimux.vim | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 0459b3b..3a698da 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -13,7 +13,7 @@ command VimuxPromptCommand :call VimuxPromptCommand() command VimuxClearRunnerHistory :call VimuxClearRunnerHistory() function! VimuxRunLastCommand() - if exists("g:VimuxRunnerPaneIndex") + if exists("g:VimuxRunnerIndex") call VimuxRunCommand(g:VimuxLastCommand) else echo "No last vimux command." @@ -21,8 +21,8 @@ function! VimuxRunLastCommand() endfunction function! VimuxRunCommand(command, ...) - if !exists("g:VimuxRunnerPaneIndex") || _VimuxHasPane(g:VimuxRunnerPaneIndex) == -1 - call VimuxOpenPane() + if !exists("g:VimuxRunnerIndex") || _VimuxHasRunner(g:VimuxRunnerIndex) == -1 + call VimuxOpenRunner() endif let l:autoreturn = 1 @@ -46,36 +46,36 @@ function! VimuxSendText(text) endfunction function! VimuxSendKeys(keys) - if exists("g:VimuxRunnerPaneIndex") - call system("tmux send-keys -t ".g:VimuxRunnerPaneIndex." ".a:keys) + if exists("g:VimuxRunnerIndex") + call system("tmux send-keys -t ".g:VimuxRunnerIndex." ".a:keys) else - echo "No vimux runner pane. Create one with VimuxOpenPane" + echo "No vimux runner pane/window. Create one with VimuxOpenRunner" endif endfunction -function! VimuxOpenPane() +function! VimuxOpenRunner() let height = _VimuxOption("g:VimuxHeight", 20) let orientation = _VimuxOption("g:VimuxOrientation", "v") - let nearestIndex = _VimuxNearestPaneIndex() + let nearestIndex = _VimuxNearestIndex() - if _VimuxOption("g:VimuxUseNearestPane", 1) == 1 && nearestIndex != -1 - let g:VimuxRunnerPaneIndex = nearestIndex + if _VimuxOption("g:VimuxUseNearest", 1) == 1 && nearestIndex != -1 + let g:VimuxRunnerIndex = nearestIndex else call system("tmux split-window -p ".height." -".orientation) - let g:VimuxRunnerPaneIndex = _VimuxTmuxPaneIndex() + let g:VimuxRunnerIndex = _VimuxTmuxIndex() call system("tmux last-pane") endif endfunction function! VimuxCloseRunner() - if exists("g:VimuxRunnerPaneIndex") - call system("tmux kill-pane -t ".g:VimuxRunnerPaneIndex) - unlet g:VimuxRunnerPaneIndex + if exists("g:VimuxRunnerIndex") + call system("tmux kill-pane -t ".g:VimuxRunnerIndex) + unlet g:VimuxRunnerIndex endif endfunction function! VimuxInspectRunner() - call system("tmux select-pane -t ".g:VimuxRunnerPaneIndex) + call system("tmux select-pane -t ".g:VimuxRunnerIndex) call system("tmux copy-mode") endfunction @@ -96,8 +96,8 @@ function! VimuxInterruptRunner() endfunction function! VimuxClearRunnerHistory() - if exists("g:VimuxRunnerPaneIndex") - call system("tmux clear-history -t ".g:VimuxRunnerPaneIndex) + if exists("g:VimuxRunnerIndex") + call system("tmux clear-history -t ".g:VimuxRunnerIndex) endif endfunction @@ -110,7 +110,7 @@ function! _VimuxTmuxSession() return _VimuxTmuxProperty("S") endfunction -function! _VimuxTmuxPaneIndex() +function! _VimuxTmuxIndex() return _VimuxTmuxProperty("P") endfunction @@ -118,7 +118,7 @@ function! _VimuxTmuxWindowIndex() return _VimuxTmuxProperty("I") endfunction -function! _VimuxNearestPaneIndex() +function! _VimuxNearestIndex() let panes = split(system("tmux list-panes"), "\n") for pane in panes @@ -142,6 +142,6 @@ function! _VimuxTmuxProperty(property) return substitute(system("tmux display -p '#".a:property."'"), '\n$', '', '') endfunction -function! _VimuxHasPane(index) +function! _VimuxHasRunner(index) return match(system("tmux list-panes"), a:index.":") endfunction From aa8a444609b20b7f92fa721959fccb29fc826c02 Mon Sep 17 00:00:00 2001 From: Ryan Glover Date: Sat, 28 Sep 2013 17:14:41 -0400 Subject: [PATCH 010/138] Add ability to change runner type between pane and window --- plugin/vimux.vim | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 3a698da..0b02b38 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -63,31 +63,31 @@ function! VimuxOpenRunner() else call system("tmux split-window -p ".height." -".orientation) let g:VimuxRunnerIndex = _VimuxTmuxIndex() - call system("tmux last-pane") + call system("tmux last-"._VimuxRunnerType()) endif endfunction function! VimuxCloseRunner() if exists("g:VimuxRunnerIndex") - call system("tmux kill-pane -t ".g:VimuxRunnerIndex) + call system("tmux kill-"._VimuxRunnerType()." -t ".g:VimuxRunnerIndex) unlet g:VimuxRunnerIndex endif endfunction function! VimuxInspectRunner() - call system("tmux select-pane -t ".g:VimuxRunnerIndex) + call system("tmux select-"._VimuxRunnerType()." -t ".g:VimuxRunnerIndex) call system("tmux copy-mode") endfunction function! VimuxScrollUpInspect() call VimuxInspectRunner() - call system("tmux last-pane") + call system("tmux last-"._VimuxRunnerType()) call VimuxSendKeys("C-u") endfunction function! VimuxScrollDownInspect() call VimuxInspectRunner() - call system("tmux last-pane") + call system("tmux last-"._VimuxRunnerType()) call VimuxSendKeys("C-d") endfunction @@ -119,7 +119,7 @@ function! _VimuxTmuxWindowIndex() endfunction function! _VimuxNearestIndex() - let panes = split(system("tmux list-panes"), "\n") + let panes = split(system("tmux list-"._VimuxRunnerType()."s"), "\n") for pane in panes if match(pane, "(active)") == -1 @@ -130,6 +130,10 @@ function! _VimuxNearestIndex() return -1 endfunction +function! _VimuxRunnerType() + return _VimuxOption("g:VimuxRunnerType", "pane") +endfunction + function! _VimuxOption(option, default) if exists(a:option) return eval(a:option) @@ -143,5 +147,5 @@ function! _VimuxTmuxProperty(property) endfunction function! _VimuxHasRunner(index) - return match(system("tmux list-panes"), a:index.":") + return match(system("tmux list-"._VimuxRunnerType()."s"), a:index.":") endfunction From 7212ae4ee86d9c5f4ad5288c6dd1639c2434d1e2 Mon Sep 17 00:00:00 2001 From: Ryan Glover Date: Sat, 28 Sep 2013 17:26:59 -0400 Subject: [PATCH 011/138] Fix finding index to be based on runner type --- plugin/vimux.vim | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 0b02b38..78c7cb2 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -54,14 +54,19 @@ function! VimuxSendKeys(keys) endfunction function! VimuxOpenRunner() - let height = _VimuxOption("g:VimuxHeight", 20) - let orientation = _VimuxOption("g:VimuxOrientation", "v") let nearestIndex = _VimuxNearestIndex() if _VimuxOption("g:VimuxUseNearest", 1) == 1 && nearestIndex != -1 let g:VimuxRunnerIndex = nearestIndex else - call system("tmux split-window -p ".height." -".orientation) + if _VimuxRunnerType() == "pane" + let height = _VimuxOption("g:VimuxHeight", 20) + let orientation = _VimuxOption("g:VimuxOrientation", "v") + call system("tmux split-window -p ".height." -".orientation) + elseif _VimuxRunnerType() == "window" + call system("tmux new-window") + endif + let g:VimuxRunnerIndex = _VimuxTmuxIndex() call system("tmux last-"._VimuxRunnerType()) endif @@ -111,7 +116,15 @@ function! _VimuxTmuxSession() endfunction function! _VimuxTmuxIndex() - return _VimuxTmuxProperty("P") + if _VimuxRunnerType == "pane" + return _VimuxTmuxPaneIndex() + else + return _VimuxTmuxWindowIndex() + end +endfunction + +function! _VimuxTmuxPaneIndex() + return _VimuxTmuxProperty("P") endfunction function! _VimuxTmuxWindowIndex() From 3cada365383933c60d2a68873397f1db7b03c0fa Mon Sep 17 00:00:00 2001 From: daniely Date: Mon, 14 Oct 2013 20:58:38 +0800 Subject: [PATCH 012/138] Update vimux.txt Fix typo "ths" to "the" --- doc/vimux.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/vimux.txt b/doc/vimux.txt index c70c44f..5bc1b35 100644 --- a/doc/vimux.txt +++ b/doc/vimux.txt @@ -172,7 +172,7 @@ runner pane. *VimuxClearRunnerHistory* VimuxClearRunnerHistory~ -Clear ths tmux history of the runner pane for when +Clear the tmux history of the runner pane for when you enter tmux scroll mode inside the runner pane. > " Clear the tmux history of the runner pane From a74b089c92dba1198015caf2a011385ae3c4b73f Mon Sep 17 00:00:00 2001 From: Larry Lv Date: Tue, 29 Oct 2013 19:52:15 +0800 Subject: [PATCH 013/138] Update vimux.txt --- doc/vimux.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/vimux.txt b/doc/vimux.txt index 5bc1b35..447cc1e 100644 --- a/doc/vimux.txt +++ b/doc/vimux.txt @@ -121,7 +121,7 @@ Prompt for a command and run it in a small horizontal split bellow the current pane. > " Prompt for a command to run map - vp :VimuxPromptCommand + map vp :VimuxPromptCommand < ------------------------------------------------------------------------------ @@ -142,7 +142,7 @@ Move into the tmux runner pane created by `VimuxRunCommand` and enter copy pmode (scroll mode). > " Inspect runner pane map - vi :VimuxInspectRunner + map vi :VimuxInspectRunner < ------------------------------------------------------------------------------ @@ -163,7 +163,7 @@ Interrupt any command that is running inside the runner pane. > " Interrupt any command running in the runner pane map - vs :VimuxInterruptRunner + map vs :VimuxInterruptRunner < @@ -176,7 +176,7 @@ Clear the tmux history of the runner pane for when you enter tmux scroll mode inside the runner pane. > " Clear the tmux history of the runner pane - vc :VimuxClearRunnerHistory + map vc :VimuxClearRunnerHistory < From 53477b16c9377ad5c8b74e5ac872493c852e83df Mon Sep 17 00:00:00 2001 From: Ben Mills Date: Thu, 7 Nov 2013 11:30:24 -0800 Subject: [PATCH 014/138] Correct docs to reflect the true default of VimuxUseNearestPane. Fixes 92 --- doc/vimux.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/vimux.txt b/doc/vimux.txt index 5bc1b35..ff1d649 100644 --- a/doc/vimux.txt +++ b/doc/vimux.txt @@ -275,7 +275,7 @@ Use exising pane (not used by vim) if found instead of running split-window. let VimuxUseNearestPane = 1 -Default: 0 +Default: 1 ------------------------------------------------------------------------------ *VimuxConfiguration_reset_sequence* From f56788990df10da1042725af6d8414fef16e6493 Mon Sep 17 00:00:00 2001 From: Ben Mills Date: Thu, 28 Nov 2013 23:28:16 -0800 Subject: [PATCH 015/138] Update docs to reflect close functions. Fixes #89 --- doc/vimux.txt | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/doc/vimux.txt b/doc/vimux.txt index 61244ed..c18d0c6 100644 --- a/doc/vimux.txt +++ b/doc/vimux.txt @@ -12,10 +12,9 @@ CONTENTS *vimux-contents* 2.2 .............................. |VimuxRunLastCommand| 2.3 .............................. |VimuxInspectRunner| 2.4 .............................. |VimuxCloseRunner| - 2.5 .............................. |VimuxClosePanes| - 2.6 .............................. |VimuxInterruptRunner| - 2.7 .............................. |VimuxClearRunnerHistory| - 2.8 .............................. |VimuxZoomRunner| + 2.5 .............................. |VimuxInterruptRunner| + 2.6 .............................. |VimuxClearRunnerHistory| + 2.7 .............................. |VimuxZoomRunner| 3. Misc ............................ |VimuxMisc| 3.1 Example Keybinding............ |VimuxExampleKeybinding| 3.2 Tslime Replacement............ |VimuxTslimeReplacement| @@ -67,8 +66,6 @@ Furthermore there are several handy commands all starting with 'Vimux': - |VimuxOpenPane| - |VimuxRunLastCommand| - |VimuxCloseRunner| - - |VimuxClosePanes| - - |VimuxCloseWindows| - |VimuxInspectRunner| - |VimuxInterruptRunner| - |VimuxPromptCommand| From e7c2413f30734ae4ce96ec96b63b6327f7dc657a Mon Sep 17 00:00:00 2001 From: Aaron Spiegel Date: Sun, 1 Dec 2013 20:02:35 -0600 Subject: [PATCH 016/138] Update README to mention Vimix (Elixir Mix integration) --- README.mkd | 1 + 1 file changed, 1 insertion(+) diff --git a/README.mkd b/README.mkd index 5add096..3f68a8d 100644 --- a/README.mkd +++ b/README.mkd @@ -30,6 +30,7 @@ _Notes:_ * [vimux-nose-test](https://github.com/pitluga/vimux-nose-test) Run nose tests in vimux * [vimux-golang](https://github.com/benmills/vimux-golang) Run go tests in vimux * [vimux-zeus](https://github.com/jingweno/vimux-zeus) Run zeus commands in vimux +* [vimix](https://github.com/spiegela/vimix) Run Elixir mix commands in vimux ## Usage From 9855936bd17f9360b9a819307e6032bd79426354 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=20Sj=C3=B6berg?= Date: Mon, 2 Dec 2013 22:47:07 +0100 Subject: [PATCH 017/138] Fix condition in _VimuxTmuxIndex() This ensure that we call `_VimuxRunnerType()` instead of `_VimuxRunnerType`. --- plugin/vimux.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 762dd46..a5e2c7f 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -124,7 +124,7 @@ function! _VimuxTmuxSession() endfunction function! _VimuxTmuxIndex() - if _VimuxRunnerType == "pane" + if _VimuxRunnerType() == "pane" return _VimuxTmuxPaneIndex() else return _VimuxTmuxWindowIndex() From efa6a9aa4b830dd8bf393c646ef389bdef666206 Mon Sep 17 00:00:00 2001 From: Ben Mills Date: Fri, 13 Dec 2013 08:46:05 -0800 Subject: [PATCH 018/138] Create LICENSE --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..678e440 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2103 Benjamin Mills + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. From ff54646761832693f3a5e64ac4f024c941cf5b03 Mon Sep 17 00:00:00 2001 From: Josh Davis Date: Sat, 11 Jan 2014 18:31:25 -0600 Subject: [PATCH 019/138] Document VimuxRunnerType option --- doc/vimux.txt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/doc/vimux.txt b/doc/vimux.txt index c18d0c6..1c26054 100644 --- a/doc/vimux.txt +++ b/doc/vimux.txt @@ -314,5 +314,20 @@ the prompt and your input. Default: "Command? " +------------------------------------------------------------------------------ + *VimuxRunnerType* +2.6 g:VimuxRunnerType~ + +The type of view object Vimux should use for the runner. For reference, a +tmux session is a group of windows, and a window is a layout of panes. + + let g:VimuxRunnerType = "window" + +Options: + "pane": for panes + "window": for windows + +Default: "pane" + ============================================================================== vim:tw=78:ts=2:sw=2:expandtab:ft=help:norl: From ba2b2050b04919168fae53e79302c17ab77f43cb Mon Sep 17 00:00:00 2001 From: Josh Davis Date: Sat, 11 Jan 2014 18:33:12 -0600 Subject: [PATCH 020/138] Change pane(s) -> view(s) for clarity Slightly pedantic but it reduces possible confusion. --- plugin/vimux.vim | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index a5e2c7f..295a8fe 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -140,11 +140,11 @@ function! _VimuxTmuxWindowIndex() endfunction function! _VimuxNearestIndex() - let panes = split(system("tmux list-"._VimuxRunnerType()."s"), "\n") + let views = split(system("tmux list-"._VimuxRunnerType()."s"), "\n") - for pane in panes - if match(pane, "(active)") == -1 - return split(pane, ":")[0] + for view in views + if match(view, "(active)") == -1 + return split(view, ":")[0] endif endfor From 17358e51ab4617548e8a8c5fa2cf7d77a5cb0d54 Mon Sep 17 00:00:00 2001 From: Josh Davis Date: Sat, 11 Jan 2014 19:05:34 -0600 Subject: [PATCH 021/138] Should return view name if one is active --- plugin/vimux.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 295a8fe..a9244d7 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -143,7 +143,7 @@ function! _VimuxNearestIndex() let views = split(system("tmux list-"._VimuxRunnerType()."s"), "\n") for view in views - if match(view, "(active)") == -1 + if match(view, "(active)") != -1 return split(view, ":")[0] endif endfor From 94b8b938b2b0bf381e44a2ed0ee36bbb85c06dbe Mon Sep 17 00:00:00 2001 From: Josh Davis Date: Sat, 11 Jan 2014 19:28:56 -0600 Subject: [PATCH 022/138] Match VimuxUseNearest documentation option w/ code --- doc/vimux.txt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/doc/vimux.txt b/doc/vimux.txt index 1c26054..8a83d0d 100644 --- a/doc/vimux.txt +++ b/doc/vimux.txt @@ -110,7 +110,7 @@ VimuxOpenPane~ This will either open a new pane or use the nearest pane and set it as the vimux runner pane for the other vimux commands. You can control if this command -uses the nearest pane or always creates a new one with g:VimuxUseNearestPane +uses the nearest pane or always creates a new one with g:VimuxUseNearest ------------------------------------------------------------------------------ *VimuxPromptCommand* @@ -282,12 +282,13 @@ Options: Default: "v" ------------------------------------------------------------------------------ - *VimuxConfiguration_use_nearest_pane* -2.3 g:VimuxUseNearestPane~ + *VimuxConfiguration_use_nearest* +2.3 g:VimuxUseNearest -Use exising pane (not used by vim) if found instead of running split-window. +Use exising pane or window (not used by vim) if found instead of running +split-window. - let VimuxUseNearestPane = 1 + let VimuxUseNearest = 1 Default: 1 From 8ff22883bd1f82ccf762105eb0916842c81ac56c Mon Sep 17 00:00:00 2001 From: Ton van den Heuvel Date: Tue, 21 Jan 2014 13:55:25 +0100 Subject: [PATCH 023/138] Identify a pane by its window and its pane index By identifying a pane by both its window and pane index, VimuxCloseRunner() will always close the correct pane, even in case VimuxCloseRunner() is called from a Vim instance in a different window than the current window. --- plugin/vimux.vim | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index a5e2c7f..48c2cd6 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -120,7 +120,7 @@ function! VimuxPromptCommand() endfunction function! _VimuxTmuxSession() - return _VimuxTmuxProperty("S") + return _VimuxTmuxProperty("#S") endfunction function! _VimuxTmuxIndex() @@ -132,11 +132,11 @@ function! _VimuxTmuxIndex() endfunction function! _VimuxTmuxPaneIndex() - return _VimuxTmuxProperty("P") + return _VimuxTmuxProperty("#I.#P") endfunction function! _VimuxTmuxWindowIndex() - return _VimuxTmuxProperty("I") + return _VimuxTmuxProperty("#I") endfunction function! _VimuxNearestIndex() @@ -164,9 +164,9 @@ function! _VimuxOption(option, default) endfunction function! _VimuxTmuxProperty(property) - return substitute(system("tmux display -p '#".a:property."'"), '\n$', '', '') + return substitute(system("tmux display -p '".a:property."'"), '\n$', '', '') endfunction function! _VimuxHasRunner(index) - return match(system("tmux list-"._VimuxRunnerType()."s"), a:index.":") + return match(system("tmux list-"._VimuxRunnerType()."s -a"), a:index.":") endfunction From d306d43a594587b1a68331df45760f1e38dfb3ac Mon Sep 17 00:00:00 2001 From: Nate Jones Date: Wed, 22 Jan 2014 14:19:00 -0800 Subject: [PATCH 024/138] update zoom to support pane or window --- plugin/vimux.vim | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index a5e2c7f..1b50780 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -81,9 +81,12 @@ function! VimuxCloseRunner() endfunction function! VimuxZoomRunner() - if exists("g:VimuxRunnerPaneIndex") - call system("tmux resize-pane -Z -t ".g:VimuxRunnerPaneIndex) - unlet g:VimuxRunnerPaneIndex + if exists("g:VimuxRunnerIndex") + if _VimuxRunnerType() == "pane" + call system("tmux resize-pane -Z -t ".g:VimuxRunnerIndex) + elseif _VimuxRunnerType() == "window" + call system("tmux select-window -t ".g:VimuxRunnerIndex) + endif endif endfunction From 3f3ef11f40166fa9c16fdf705e9ced966692af4a Mon Sep 17 00:00:00 2001 From: LIU Yang Date: Fri, 21 Mar 2014 15:42:48 +0800 Subject: [PATCH 025/138] Fixed typo in doc/vimux.txt Add missing `map` --- doc/vimux.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/vimux.txt b/doc/vimux.txt index c18d0c6..785238a 100644 --- a/doc/vimux.txt +++ b/doc/vimux.txt @@ -188,7 +188,7 @@ Zoom requires tmux version >= 1.8 > " Zoom the tmux runner page - vz :VimuxZoomRunner + map vz :VimuxZoomRunner < ============================================================================== From 905e002c816946afe303a3baebb2bbf3e93a646a Mon Sep 17 00:00:00 2001 From: Alex Ozer Date: Wed, 23 Apr 2014 12:27:12 -0400 Subject: [PATCH 026/138] Add VimuxTogglePane --- plugin/vimux.vim | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 6425aa3..707d1d3 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -12,6 +12,7 @@ command VimuxScrollDownInspect :call VimuxScrollDownInspect() command VimuxInterruptRunner :call VimuxInterruptRunner() command VimuxPromptCommand :call VimuxPromptCommand() command VimuxClearRunnerHistory :call VimuxClearRunnerHistory() +command VimuxTogglePane :call VimuxTogglePane() function! VimuxRunLastCommand() if exists("g:VimuxRunnerIndex") @@ -80,6 +81,18 @@ function! VimuxCloseRunner() endif endfunction +function! VimuxTogglePane() + if exists("g:VimuxRunnerIndex") + if _VimuxRunnerType() == "window" + call system("tmux join-pane -d -s ".g:VimuxRunnerIndex." -p "._VimuxOption("g:VimuxHeight", 20)) + let g:VimuxRunnerType = "pane" + elseif _VimuxRunnerType() == "pane" + call system("tmux break-pane -d -t ".g:VimuxRunnerIndex) + let g:VimuxRunnerType = "window" + endif + endif +endfunction + function! VimuxZoomRunner() if exists("g:VimuxRunnerIndex") if _VimuxRunnerType() == "pane" From 6594afdcd0eb0eb4b627dab6cf7777913f714071 Mon Sep 17 00:00:00 2001 From: Alex Ozer Date: Wed, 23 Apr 2014 16:06:24 -0400 Subject: [PATCH 027/138] Use runner window index when converting to window --- plugin/vimux.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 707d1d3..2309fe2 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -87,7 +87,7 @@ function! VimuxTogglePane() call system("tmux join-pane -d -s ".g:VimuxRunnerIndex." -p "._VimuxOption("g:VimuxHeight", 20)) let g:VimuxRunnerType = "pane" elseif _VimuxRunnerType() == "pane" - call system("tmux break-pane -d -t ".g:VimuxRunnerIndex) + let g:VimuxRunnerIndex=substitute(system("tmux break-pane -d -t ".g:VimuxRunnerIndex." -P -F '#{window_index}'"), "\n", "", "") let g:VimuxRunnerType = "window" endif endif From 54858144f919d16f69f1d377226b2ddbce15a8ec Mon Sep 17 00:00:00 2001 From: Alex Ozer Date: Fri, 25 Apr 2014 21:41:51 -0400 Subject: [PATCH 028/138] Stop Vimux from spewing garbage text --- plugin/vimux.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index cf13596..18d0004 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -159,7 +159,7 @@ function! _VimuxNearestIndex() let views = split(system("tmux list-"._VimuxRunnerType()."s"), "\n") for view in views - if match(view, "(active)") != -1 + if match(view, "(active)") == -1 return split(view, ":")[0] endif endfor From b60a52d36ce6aa714ce982f674d08a687b969eb6 Mon Sep 17 00:00:00 2001 From: teoric Date: Sun, 13 Jul 2014 12:08:15 +0200 Subject: [PATCH 029/138] Allow to use VimuxRunCommand as a command use as :VimuxRunCommand "ls -la" --- plugin/vimux.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 18d0004..244a7a2 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -3,6 +3,7 @@ if exists("g:loaded_vimux") || &cp endif let g:loaded_vimux = 1 +command! -nargs=1 VimuxRunCommand :call VimuxRunCommand() command VimuxRunLastCommand :call VimuxRunLastCommand() command VimuxCloseRunner :call VimuxCloseRunner() command VimuxZoomRunner :call VimuxZoomRunner() From b437d32c1baad78dbea620e87ea0f71b7ed6351e Mon Sep 17 00:00:00 2001 From: teoric Date: Sun, 13 Jul 2014 12:10:39 +0200 Subject: [PATCH 030/138] remove exclamation mark --- plugin/vimux.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 244a7a2..c62479d 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -3,7 +3,7 @@ if exists("g:loaded_vimux") || &cp endif let g:loaded_vimux = 1 -command! -nargs=1 VimuxRunCommand :call VimuxRunCommand() +command -nargs=1 VimuxRunCommand :call VimuxRunCommand() command VimuxRunLastCommand :call VimuxRunLastCommand() command VimuxCloseRunner :call VimuxCloseRunner() command VimuxZoomRunner :call VimuxZoomRunner() From 3135ab5e30995a503ffceb10f8c5b3c2bb1b9365 Mon Sep 17 00:00:00 2001 From: teoric Date: Sun, 13 Jul 2014 12:18:28 +0200 Subject: [PATCH 031/138] right number of arguments for :VimuxRunCommand (read docs) --- plugin/vimux.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index c62479d..d4bddb9 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -3,7 +3,7 @@ if exists("g:loaded_vimux") || &cp endif let g:loaded_vimux = 1 -command -nargs=1 VimuxRunCommand :call VimuxRunCommand() +command -nargs=2 VimuxRunCommand :call VimuxRunCommand() command VimuxRunLastCommand :call VimuxRunLastCommand() command VimuxCloseRunner :call VimuxCloseRunner() command VimuxZoomRunner :call VimuxZoomRunner() From e5a9eb74dab9d5cb8839ba041b9022e4121bd3e6 Mon Sep 17 00:00:00 2001 From: Teoric Date: Sun, 13 Jul 2014 12:37:17 +0200 Subject: [PATCH 032/138] :VimuxRunCommand nargs=*, not nargs=2 --- plugin/vimux.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index d4bddb9..4a4acce 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -3,7 +3,7 @@ if exists("g:loaded_vimux") || &cp endif let g:loaded_vimux = 1 -command -nargs=2 VimuxRunCommand :call VimuxRunCommand() +command -nargs=* VimuxRunCommand :call VimuxRunCommand() command VimuxRunLastCommand :call VimuxRunLastCommand() command VimuxCloseRunner :call VimuxCloseRunner() command VimuxZoomRunner :call VimuxZoomRunner() From ab6941c2c59af990b0ae093ae536b1ab7ea2afd2 Mon Sep 17 00:00:00 2001 From: kavinderd Date: Mon, 28 Jul 2014 09:44:38 -0700 Subject: [PATCH 033/138] Add Vundle installation instructions I added the syntax for installing this plugin via Vundle. Tested it on my system and it works. --- README.mkd | 1 + 1 file changed, 1 insertion(+) diff --git a/README.mkd b/README.mkd index 3f68a8d..b502841 100644 --- a/README.mkd +++ b/README.mkd @@ -13,6 +13,7 @@ Other auxiliary functions and the ones I talked about above can be found bellow ## Installation With **[vim-bundle](https://github.com/benmills/vim-bundle)**: `vim-bundle install benmills/vimux` +With **[Vundle](https://github.com/gmarik/Vundle.vim)**: 'Plugin benmills/vimux' in your .vimrc Otherwise download the latest [tarball](https://github.com/benmills/vimux/tarball/master), extract it and move `plugin/vimux.vim` inside `~/.vim/plugin`. If you're using [pathogen](https://github.com/tpope/vim-pathogen), then move the entire folder extracted from the tarball into `~/.vim/bundle`. From d78cd0f8e17b277f35e4df3fdb683761f5801937 Mon Sep 17 00:00:00 2001 From: Matthias Bilger Date: Tue, 19 Aug 2014 08:55:31 +0200 Subject: [PATCH 034/138] Predefined command option for VimuxPromptCommand Added the possibility to specify a predefined command which can be edited or completed in the prompt line. --- plugin/vimux.vim | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 4a4acce..3aaba22 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -11,7 +11,7 @@ command VimuxInspectRunner :call VimuxInspectRunner() command VimuxScrollUpInspect :call VimuxScrollUpInspect() command VimuxScrollDownInspect :call VimuxScrollDownInspect() command VimuxInterruptRunner :call VimuxInterruptRunner() -command VimuxPromptCommand :call VimuxPromptCommand() +command -nargs=? VimuxPromptCommand :call VimuxPromptCommand() command VimuxClearRunnerHistory :call VimuxClearRunnerHistory() command VimuxTogglePane :call VimuxTogglePane() @@ -37,6 +37,7 @@ function! VimuxRunCommand(command, ...) let g:VimuxLastCommand = a:command call VimuxSendKeys(resetSequence) + echo a:command call VimuxSendText(a:command) if l:autoreturn == 1 @@ -131,8 +132,8 @@ function! VimuxClearRunnerHistory() endif endfunction -function! VimuxPromptCommand() - let l:command = input(_VimuxOption("g:VimuxPromptString", "Command? ")) +function! VimuxPromptCommand(command, ...) + let l:command = input(_VimuxOption("g:VimuxPromptString", "Command? "),a:command) call VimuxRunCommand(l:command) endfunction From a772fce3e239e1b4adf17e587d7f075d1f310701 Mon Sep 17 00:00:00 2001 From: Matthias Bilger Date: Tue, 19 Aug 2014 10:02:25 +0200 Subject: [PATCH 035/138] Removed Debug Output Removed debug output of command which was still in there --- plugin/vimux.vim | 1 - 1 file changed, 1 deletion(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 3aaba22..566a8f4 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -37,7 +37,6 @@ function! VimuxRunCommand(command, ...) let g:VimuxLastCommand = a:command call VimuxSendKeys(resetSequence) - echo a:command call VimuxSendText(a:command) if l:autoreturn == 1 From 5a530ca8e40957351324313ef963a5456acc68f0 Mon Sep 17 00:00:00 2001 From: Matthias Bilger Date: Wed, 20 Aug 2014 07:47:21 +0200 Subject: [PATCH 036/138] Updated documentation for VimuxPromptCommand Added description for VimuxPromptCommand optional parameter. --- doc/vimux.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/vimux.txt b/doc/vimux.txt index b9bf364..b0ad5e0 100644 --- a/doc/vimux.txt +++ b/doc/vimux.txt @@ -117,10 +117,12 @@ uses the nearest pane or always creates a new one with g:VimuxUseNearest VimuxPromptCommand~ Prompt for a command and run it in a small horizontal split bellow the current -pane. +pane. A parameter can be supplied to predefine a command or a part of the +command which can be edited in the prompt. > " Prompt for a command to run map map vp :VimuxPromptCommand + map vm :VimuxPromptCommand("make ") < ------------------------------------------------------------------------------ From d21337e01a1a1e2fd90a2ccd58144995a44318ff Mon Sep 17 00:00:00 2001 From: Melissa Xie Date: Wed, 3 Sep 2014 12:20:45 -0400 Subject: [PATCH 037/138] Check for a predefined command for prompt before executing VimuxPromptCommand was accepting 1 or more arguments instead of 0 or more. Vim will complain about this despite nargs being set. --- plugin/vimux.vim | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 566a8f4..8c60be4 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -131,8 +131,9 @@ function! VimuxClearRunnerHistory() endif endfunction -function! VimuxPromptCommand(command, ...) - let l:command = input(_VimuxOption("g:VimuxPromptString", "Command? "),a:command) +function! VimuxPromptCommand(...) + let command = a:0 == 1 ? a:1 : "" + let l:command = input(_VimuxOption("g:VimuxPromptString", "Command? "), command) call VimuxRunCommand(l:command) endfunction From 01c0679223fbdd2e7f20c9d7381f03b0f9f1094b Mon Sep 17 00:00:00 2001 From: Hendrik Purmann Date: Sun, 21 Sep 2014 02:33:49 +0200 Subject: [PATCH 038/138] Added VimuxRunCommandInDir + doc --- doc/vimux.txt | 21 ++++++++++++++++++++- plugin/vimux.vim | 8 ++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/doc/vimux.txt b/doc/vimux.txt index b0ad5e0..6b2e1f1 100644 --- a/doc/vimux.txt +++ b/doc/vimux.txt @@ -15,6 +15,7 @@ CONTENTS *vimux-contents* 2.5 .............................. |VimuxInterruptRunner| 2.6 .............................. |VimuxClearRunnerHistory| 2.7 .............................. |VimuxZoomRunner| + 2.8 .............................. |VimuxRunCommandInDir| 3. Misc ............................ |VimuxMisc| 3.1 Example Keybinding............ |VimuxExampleKeybinding| 3.2 Tslime Replacement............ |VimuxTslimeReplacement| @@ -71,6 +72,7 @@ Furthermore there are several handy commands all starting with 'Vimux': - |VimuxPromptCommand| - |VimuxClearRunnerHistory| - |VimuxZoomRunner| + - |VimuxRunCommandInDir| ------------------------------------------------------------------------------ *VimuxRunCommand* @@ -193,6 +195,23 @@ Zoom requires tmux version >= 1.8 map vz :VimuxZoomRunner < +------------------------------------------------------------------------------ + *VimuxRunCommandInDir* +VimuxRunCommandInDir~ + +Runs the specified command inside the directory of +the currently opened file. Takes two arguments. command and inFile + +command: The command to run +inFile: If 1 the filename will be appended to the command +> + + " Compile currently opened latex file to pdf + autocmd Filetype tex nnoremap rr :update:call VimuxRunCommandInDir('latexmk -pdf', 1) + " Push the repository of the currently opened file + nnoremap gp :call VimuxRunCommandInDir("git push", 0) +< + ============================================================================== MISC (3) *VimuxMisc* @@ -325,7 +344,7 @@ The type of view object Vimux should use for the runner. For reference, a tmux session is a group of windows, and a window is a layout of panes. let g:VimuxRunnerType = "window" - + Options: "pane": for panes "window": for windows diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 8c60be4..e0bf981 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -15,6 +15,14 @@ command -nargs=? VimuxPromptCommand :call VimuxPromptCommand() command VimuxClearRunnerHistory :call VimuxClearRunnerHistory() command VimuxTogglePane :call VimuxTogglePane() +function! VimuxRunCommandInDir(command, useFile) + let l:file = "" + if a:useFile ==# 1 + let l:file = shellescape(expand('%:t'), 1) + endif + call VimuxRunCommand("cd ".shellescape(expand('%:p:h'), 1)." && ".a:command." ".l:file) +endfunction + function! VimuxRunLastCommand() if exists("g:VimuxRunnerIndex") call VimuxRunCommand(g:VimuxLastCommand) From 7b655a7b5c0fae30359763b2d90ac89022eb183f Mon Sep 17 00:00:00 2001 From: Hendrik Purmann Date: Sun, 21 Sep 2014 21:08:54 +0200 Subject: [PATCH 039/138] Going back to formerly active directory after running command --- plugin/vimux.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index e0bf981..f0ce0ee 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -20,7 +20,7 @@ function! VimuxRunCommandInDir(command, useFile) if a:useFile ==# 1 let l:file = shellescape(expand('%:t'), 1) endif - call VimuxRunCommand("cd ".shellescape(expand('%:p:h'), 1)." && ".a:command." ".l:file) + call VimuxRunCommand("cd ".shellescape(expand('%:p:h'), 1)." && ".a:command." ".l:file." && cd - > /dev/null") endfunction function! VimuxRunLastCommand() From 24e9d354a440a9e983d1bc1446ad5136cbb89592 Mon Sep 17 00:00:00 2001 From: Bob Nadler Date: Sat, 31 Jan 2015 12:26:27 -0500 Subject: [PATCH 040/138] Fix typo in docs --- doc/vimux.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/vimux.txt b/doc/vimux.txt index 6b2e1f1..6407792 100644 --- a/doc/vimux.txt +++ b/doc/vimux.txt @@ -92,7 +92,7 @@ vimux from automatically sending a return after the command. *VimuxSendText* VimuxSendText~ -Send raw text to the runer pane. This command will not open a new pane if one +Send raw text to the runner pane. This command will not open a new pane if one does not already exist. You will need to use VimuxOpenPane to do this. This command can be used to interact with REPLs or other interactive terminal programs that are not shells. From 70e16b73f5002179c60e8f7fdbd253799bf5a0dc Mon Sep 17 00:00:00 2001 From: Pawel Palucki Date: Fri, 21 Nov 2014 11:36:08 +0100 Subject: [PATCH 041/138] escape '$' before sending to tmux --- plugin/vimux.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index f0ce0ee..12ae004 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -53,7 +53,7 @@ function! VimuxRunCommand(command, ...) endfunction function! VimuxSendText(text) - call VimuxSendKeys('"'.escape(a:text, '"').'"') + call VimuxSendKeys('"'.escape(a:text, '"$').'"') endfunction function! VimuxSendKeys(keys) From 863e813928ddd6071a786b3128c82fa35cc26a69 Mon Sep 17 00:00:00 2001 From: Pete Yandell Date: Mon, 10 Aug 2015 17:20:39 +1000 Subject: [PATCH 042/138] Allow configuring which tmux binary to use. This is mostly useful for supporting tmate, which is a fork of tmux that uses a different command name. --- doc/vimux.txt | 11 +++++++++++ plugin/vimux.vim | 39 ++++++++++++++++++++++----------------- 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/doc/vimux.txt b/doc/vimux.txt index 6b2e1f1..1c49e23 100644 --- a/doc/vimux.txt +++ b/doc/vimux.txt @@ -351,5 +351,16 @@ Options: Default: "pane" +------------------------------------------------------------------------------ + *VimuxTmuxCommand* +2.7 g:VimuxTmuxCommand~ + +The command that Vimux runs when it calls out to tmux. It may be useful to +redefine this if you're using something like tmate. + + let g:VimuxTmuxCommand = "tmate" + +Default: "tmux" + ============================================================================== vim:tw=78:ts=2:sw=2:expandtab:ft=help:norl: diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 12ae004..5d6dd34 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -58,7 +58,7 @@ endfunction function! VimuxSendKeys(keys) if exists("g:VimuxRunnerIndex") - call system("tmux send-keys -t ".g:VimuxRunnerIndex." ".a:keys) + call _VimuxTmux("send-keys -t ".g:VimuxRunnerIndex." ".a:keys) else echo "No vimux runner pane/window. Create one with VimuxOpenRunner" endif @@ -73,19 +73,19 @@ function! VimuxOpenRunner() if _VimuxRunnerType() == "pane" let height = _VimuxOption("g:VimuxHeight", 20) let orientation = _VimuxOption("g:VimuxOrientation", "v") - call system("tmux split-window -p ".height." -".orientation) + call _VimuxTmux("split-window -p ".height." -".orientation) elseif _VimuxRunnerType() == "window" - call system("tmux new-window") + call _VimuxTmux("new-window") endif let g:VimuxRunnerIndex = _VimuxTmuxIndex() - call system("tmux last-"._VimuxRunnerType()) + call _VimuxTmux("last-"._VimuxRunnerType()) endif endfunction function! VimuxCloseRunner() if exists("g:VimuxRunnerIndex") - call system("tmux kill-"._VimuxRunnerType()." -t ".g:VimuxRunnerIndex) + call _VimuxTmux("kill-"._VimuxRunnerType()." -t ".g:VimuxRunnerIndex) unlet g:VimuxRunnerIndex endif endfunction @@ -93,10 +93,10 @@ endfunction function! VimuxTogglePane() if exists("g:VimuxRunnerIndex") if _VimuxRunnerType() == "window" - call system("tmux join-pane -d -s ".g:VimuxRunnerIndex." -p "._VimuxOption("g:VimuxHeight", 20)) + call _VimuxTmux("join-pane -d -s ".g:VimuxRunnerIndex." -p "._VimuxOption("g:VimuxHeight", 20)) let g:VimuxRunnerType = "pane" elseif _VimuxRunnerType() == "pane" - let g:VimuxRunnerIndex=substitute(system("tmux break-pane -d -t ".g:VimuxRunnerIndex." -P -F '#{window_index}'"), "\n", "", "") + let g:VimuxRunnerIndex=substitute(_VimuxTmux("break-pane -d -t ".g:VimuxRunnerIndex." -P -F '#{window_index}'"), "\n", "", "") let g:VimuxRunnerType = "window" endif endif @@ -105,27 +105,27 @@ endfunction function! VimuxZoomRunner() if exists("g:VimuxRunnerIndex") if _VimuxRunnerType() == "pane" - call system("tmux resize-pane -Z -t ".g:VimuxRunnerIndex) + call _VimuxTmux("resize-pane -Z -t ".g:VimuxRunnerIndex) elseif _VimuxRunnerType() == "window" - call system("tmux select-window -t ".g:VimuxRunnerIndex) + call _VimuxTmux("select-window -t ".g:VimuxRunnerIndex) endif endif endfunction function! VimuxInspectRunner() - call system("tmux select-"._VimuxRunnerType()." -t ".g:VimuxRunnerIndex) - call system("tmux copy-mode") + call _VimuxTmux("select-"._VimuxRunnerType()." -t ".g:VimuxRunnerIndex) + call _VimuxTmux("copy-mode") endfunction function! VimuxScrollUpInspect() call VimuxInspectRunner() - call system("tmux last-"._VimuxRunnerType()) + call _VimuxTmux("last-"._VimuxRunnerType()) call VimuxSendKeys("C-u") endfunction function! VimuxScrollDownInspect() call VimuxInspectRunner() - call system("tmux last-"._VimuxRunnerType()) + call _VimuxTmux("last-"._VimuxRunnerType()) call VimuxSendKeys("C-d") endfunction @@ -135,7 +135,7 @@ endfunction function! VimuxClearRunnerHistory() if exists("g:VimuxRunnerIndex") - call system("tmux clear-history -t ".g:VimuxRunnerIndex) + call _VimuxTmux("clear-history -t ".g:VimuxRunnerIndex) endif endfunction @@ -145,6 +145,11 @@ function! VimuxPromptCommand(...) call VimuxRunCommand(l:command) endfunction +function! _VimuxTmux(arguments) + let l:command = _VimuxOption("g:VimuxTmuxCommand", "tmux") + return system(l:command." ".a:arguments) +endfunction + function! _VimuxTmuxSession() return _VimuxTmuxProperty("#S") endfunction @@ -166,7 +171,7 @@ function! _VimuxTmuxWindowIndex() endfunction function! _VimuxNearestIndex() - let views = split(system("tmux list-"._VimuxRunnerType()."s"), "\n") + let views = split(_VimuxTmux("list-"._VimuxRunnerType()."s"), "\n") for view in views if match(view, "(active)") == -1 @@ -190,9 +195,9 @@ function! _VimuxOption(option, default) endfunction function! _VimuxTmuxProperty(property) - return substitute(system("tmux display -p '".a:property."'"), '\n$', '', '') + return substitute(_VimuxTmux("display -p '".a:property."'"), '\n$', '', '') endfunction function! _VimuxHasRunner(index) - return match(system("tmux list-"._VimuxRunnerType()."s -a"), a:index.":") + return match(_VimuxTmux("list-"._VimuxRunnerType()."s -a"), a:index.":") endfunction From 4153ba4987a4e891268b136e54b6f215dc1a50cf Mon Sep 17 00:00:00 2001 From: John Downey Date: Fri, 21 Aug 2015 12:38:37 -0500 Subject: [PATCH 043/138] Add vimux-cargo to README --- README.mkd | 1 + 1 file changed, 1 insertion(+) diff --git a/README.mkd b/README.mkd index b502841..b343fce 100644 --- a/README.mkd +++ b/README.mkd @@ -32,6 +32,7 @@ _Notes:_ * [vimux-golang](https://github.com/benmills/vimux-golang) Run go tests in vimux * [vimux-zeus](https://github.com/jingweno/vimux-zeus) Run zeus commands in vimux * [vimix](https://github.com/spiegela/vimix) Run Elixir mix commands in vimux +* [vimux-cargo](https://github.com/jtdowney/vimux-cargo) run rust tests and projects using cargo and vimux ## Usage From 8c332d9919dfc5ab02b3f62f8a00024893213ec5 Mon Sep 17 00:00:00 2001 From: Joakim Bergman Date: Fri, 28 Nov 2014 10:57:17 +0100 Subject: [PATCH 044/138] VimuxRunCommandInDir: run in subshell Fixes a problem where the directory is not restored if the command exits with a non-zero code. --- plugin/vimux.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 12ae004..be36acc 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -20,7 +20,7 @@ function! VimuxRunCommandInDir(command, useFile) if a:useFile ==# 1 let l:file = shellescape(expand('%:t'), 1) endif - call VimuxRunCommand("cd ".shellescape(expand('%:p:h'), 1)." && ".a:command." ".l:file." && cd - > /dev/null") + call VimuxRunCommand("(cd ".shellescape(expand('%:p:h'), 1)." && ".a:command." ".l:file.")") endfunction function! VimuxRunLastCommand() From 770ae770927b385ec8962145eeb99c8977ca2405 Mon Sep 17 00:00:00 2001 From: everbot Date: Mon, 31 Aug 2015 20:43:17 +0930 Subject: [PATCH 045/138] Fix #133: escape backslash --- plugin/vimux.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index a85fc53..9170668 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -53,7 +53,7 @@ function! VimuxRunCommand(command, ...) endfunction function! VimuxSendText(text) - call VimuxSendKeys('"'.escape(a:text, '"$').'"') + call VimuxSendKeys('"'.escape(a:text, '\"$').'"') endfunction function! VimuxSendKeys(keys) From 1b9db6392fe3e3298e73782648f2bee35e39cb69 Mon Sep 17 00:00:00 2001 From: Paul Gross Date: Fri, 18 Sep 2015 16:59:17 -0700 Subject: [PATCH 046/138] Add vimux-bazel-test to the list of plugins. --- README.mkd | 1 + 1 file changed, 1 insertion(+) diff --git a/README.mkd b/README.mkd index b343fce..fd4f2a2 100644 --- a/README.mkd +++ b/README.mkd @@ -33,6 +33,7 @@ _Notes:_ * [vimux-zeus](https://github.com/jingweno/vimux-zeus) Run zeus commands in vimux * [vimix](https://github.com/spiegela/vimix) Run Elixir mix commands in vimux * [vimux-cargo](https://github.com/jtdowney/vimux-cargo) run rust tests and projects using cargo and vimux +* [vimux-bazel-test](https://github.com/pgr0ss/vimux-bazel-test) Run bazel tests in vimux ## Usage From 1b847e6d6a2b7773f5f31165c1c30c46b0929501 Mon Sep 17 00:00:00 2001 From: lingceng Date: Mon, 9 Jan 2017 18:54:03 +0800 Subject: [PATCH 047/138] Fix #57 Escape character "`" before send command --- plugin/vimux.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 9170668..bd3a2db 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -53,7 +53,7 @@ function! VimuxRunCommand(command, ...) endfunction function! VimuxSendText(text) - call VimuxSendKeys('"'.escape(a:text, '\"$').'"') + call VimuxSendKeys('"'.escape(a:text, '\"$`').'"') endfunction function! VimuxSendKeys(keys) From bbe6a597cdb31c601bbe3554bb2234cd49f86ae4 Mon Sep 17 00:00:00 2001 From: Filype Pereira Date: Tue, 4 Apr 2017 20:27:30 +1200 Subject: [PATCH 048/138] updated readme screenshot --- README.mkd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.mkd b/README.mkd index fd4f2a2..e5e2973 100644 --- a/README.mkd +++ b/README.mkd @@ -2,7 +2,7 @@ Easily interact with tmux from vim. -![vimux](https://www.braintreepayments.com/assets/images/blog/vimux3.png) +![vimux](https://www.braintreepayments.com/blog/content/images/blog/vimux3.png) What inspired me to write vimux was [tslime.vim](https://github.com/kikijump/tslime.vim), a plugin that lets you send input to tmux. While tslime.vim works well, I felt it wasn't optimized for my primary use case which was having a smaller tmux pane that I would use to run tests or play with a REPL. From 8cb041640108b8dd6da5d7ec6e96ef7ee5e9b6e1 Mon Sep 17 00:00:00 2001 From: Alberto De Lucca Date: Fri, 16 Jun 2017 00:09:53 -0400 Subject: [PATCH 049/138] Fix misspeling --- doc/vimux.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/vimux.txt b/doc/vimux.txt index 395b90b..03df1e5 100644 --- a/doc/vimux.txt +++ b/doc/vimux.txt @@ -306,7 +306,7 @@ Default: "v" *VimuxConfiguration_use_nearest* 2.3 g:VimuxUseNearest -Use exising pane or window (not used by vim) if found instead of running +Use existing pane or window (not used by vim) if found instead of running split-window. let VimuxUseNearest = 1 From 0a560ba41909a51345cf467aac58034211ddb2cb Mon Sep 17 00:00:00 2001 From: lyuts Date: Thu, 1 Dec 2016 22:38:19 -0800 Subject: [PATCH 050/138] Check tmux binary availability at startup. Updated the plugin to: - let override the location of tmux executable. - check tmux executable availability. --- plugin/vimux.vim | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index bd3a2db..37bd8ac 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -3,6 +3,15 @@ if exists("g:loaded_vimux") || &cp endif let g:loaded_vimux = 1 +if !exists("g:tmuxCmd") + let g:tmuxCmd = "tmux" +endif + +if !executable(g:tmuxCmd) + echohl ErrorMsg | echomsg "Failed to find executable ".g:tmuxCmd | echohl None + finish +endif + command -nargs=* VimuxRunCommand :call VimuxRunCommand() command VimuxRunLastCommand :call VimuxRunLastCommand() command VimuxCloseRunner :call VimuxCloseRunner() @@ -146,7 +155,7 @@ function! VimuxPromptCommand(...) endfunction function! _VimuxTmux(arguments) - let l:command = _VimuxOption("g:VimuxTmuxCommand", "tmux") + let l:command = _VimuxOption("g:VimuxTmuxCommand", g:tmuxCmd) return system(l:command." ".a:arguments) endfunction From 9f81329f60fa819ed0518e04bf0572488193e151 Mon Sep 17 00:00:00 2001 From: lyuts Date: Sun, 9 Jul 2017 23:12:41 -0700 Subject: [PATCH 051/138] Wrap tmux executable detection in a helper function. Function encapsulates executable detection which is needed at vim startup for checking tmux availability and during actual command running. --- plugin/vimux.vim | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 37bd8ac..5f5df76 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -3,12 +3,20 @@ if exists("g:loaded_vimux") || &cp endif let g:loaded_vimux = 1 -if !exists("g:tmuxCmd") - let g:tmuxCmd = "tmux" -endif +function! _VimuxOption(option, default) + if exists(a:option) + return eval(a:option) + else + return a:default + endif +endfunction + +function! _VimuxTmuxCmd() + return _VimuxOption("g:VimuxTmuxCommand", "tmux") +endfunction -if !executable(g:tmuxCmd) - echohl ErrorMsg | echomsg "Failed to find executable ".g:tmuxCmd | echohl None +if !executable(_VimuxTmuxCmd()) + echohl ErrorMsg | echomsg "Failed to find executable "._VimuxTmuxCmd() | echohl None finish endif @@ -155,8 +163,7 @@ function! VimuxPromptCommand(...) endfunction function! _VimuxTmux(arguments) - let l:command = _VimuxOption("g:VimuxTmuxCommand", g:tmuxCmd) - return system(l:command." ".a:arguments) + return system(_VimuxTmuxCmd()." ".a:arguments) endfunction function! _VimuxTmuxSession() @@ -195,14 +202,6 @@ function! _VimuxRunnerType() return _VimuxOption("g:VimuxRunnerType", "pane") endfunction -function! _VimuxOption(option, default) - if exists(a:option) - return eval(a:option) - else - return a:default - endif -endfunction - function! _VimuxTmuxProperty(property) return substitute(_VimuxTmux("display -p '".a:property."'"), '\n$', '', '') endfunction From 9c3195a0be7810c60166eaee4c9d1de660a8bedc Mon Sep 17 00:00:00 2001 From: Oskar Laska Date: Thu, 21 Sep 2017 10:52:04 +0200 Subject: [PATCH 052/138] Fix docs typos (missing 'g:') --- doc/vimux.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/vimux.txt b/doc/vimux.txt index 03df1e5..4b33722 100644 --- a/doc/vimux.txt +++ b/doc/vimux.txt @@ -309,7 +309,7 @@ Default: "v" Use existing pane or window (not used by vim) if found instead of running split-window. - let VimuxUseNearest = 1 + let g:VimuxUseNearest = 1 Default: 1 @@ -320,7 +320,7 @@ Default: 1 The keys sent to the runner pane before running a command. By default it sends `q` to make sure the pane is not in scroll-mode and `C-u` to clear the line. - let VimuxResetSequence = "" + let g:VimuxResetSequence = "" Default: "q C-u" From 198c8ea8ca3af312a1cb1fe474ff0b31d59f0197 Mon Sep 17 00:00:00 2001 From: Alphonse Mariyagnanaseelan Date: Tue, 26 Sep 2017 08:22:42 +0200 Subject: [PATCH 053/138] Fix docs: Update function name Updated the docs for `VimuxOpenRunner`, which was called `VimuxOpenPane` before. Relevant commit: 49a048e --- doc/vimux.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/vimux.txt b/doc/vimux.txt index 03df1e5..7f73473 100644 --- a/doc/vimux.txt +++ b/doc/vimux.txt @@ -64,7 +64,7 @@ Furthermore there are several handy commands all starting with 'Vimux': - |VimuxRunCommand| - |VimuxSendText| - |VimuxSendKeys| - - |VimuxOpenPane| + - |VimuxOpenRunner| - |VimuxRunLastCommand| - |VimuxCloseRunner| - |VimuxInspectRunner| @@ -93,7 +93,7 @@ vimux from automatically sending a return after the command. VimuxSendText~ Send raw text to the runner pane. This command will not open a new pane if one -does not already exist. You will need to use VimuxOpenPane to do this. This +does not already exist. You will need to use VimuxOpenRunner to do this. This command can be used to interact with REPLs or other interactive terminal programs that are not shells. @@ -103,12 +103,12 @@ programs that are not shells. VimuxSendKeys~ Send keys to the runner pane. This command will not open a new pane if one -does not already exist. You will need to use VimuxOpenPane to do this. You can -use this command to send keys such as "Enter" or "C-c" to the runner pane. +does not already exist. You will need to use VimuxOpenRunner to do this. You +can use this command to send keys such as "Enter" or "C-c" to the runner pane. ------------------------------------------------------------------------------ - *VimuxOpenPane* -VimuxOpenPane~ + *VimuxOpenRunner* +VimuxOpenRunner~ This will either open a new pane or use the nearest pane and set it as the vimux runner pane for the other vimux commands. You can control if this command From 020a5eed02aed742e2609a32fe9b490fee9be744 Mon Sep 17 00:00:00 2001 From: Tye Wang Date: Tue, 24 Oct 2017 16:33:48 -0400 Subject: [PATCH 054/138] Update plugins section of README.mkd with vimux-jest-test --- README.mkd | 1 + 1 file changed, 1 insertion(+) diff --git a/README.mkd b/README.mkd index e5e2973..b5a7caa 100644 --- a/README.mkd +++ b/README.mkd @@ -34,6 +34,7 @@ _Notes:_ * [vimix](https://github.com/spiegela/vimix) Run Elixir mix commands in vimux * [vimux-cargo](https://github.com/jtdowney/vimux-cargo) run rust tests and projects using cargo and vimux * [vimux-bazel-test](https://github.com/pgr0ss/vimux-bazel-test) Run bazel tests in vimux +* [vimux-jest-test](https://github.com/tyewang/vimux-jest-test) Run jest tests in vimux ## Usage From 3fdafcfd601a45442b987446e70a6859dfd396a4 Mon Sep 17 00:00:00 2001 From: Michael vanderKamp Date: Sun, 12 Jan 2020 14:13:17 -0600 Subject: [PATCH 055/138] Add VimuxOpenExtraArgs option --- plugin/vimux.vim | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index bd3a2db..7ab3746 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -70,12 +70,13 @@ function! VimuxOpenRunner() if _VimuxOption("g:VimuxUseNearest", 1) == 1 && nearestIndex != -1 let g:VimuxRunnerIndex = nearestIndex else + let extraArguments = _VimuxOption("g:VimuxOpenExtraArgs", " ") if _VimuxRunnerType() == "pane" let height = _VimuxOption("g:VimuxHeight", 20) let orientation = _VimuxOption("g:VimuxOrientation", "v") - call _VimuxTmux("split-window -p ".height." -".orientation) + call _VimuxTmux("split-window -p ".height." -".orientation." ".extraArguments) elseif _VimuxRunnerType() == "window" - call _VimuxTmux("new-window") + call _VimuxTmux("new-window ".extraArguments) endif let g:VimuxRunnerIndex = _VimuxTmuxIndex() From 556a2d692ba86b81a7b11b715504d41cb2b5c1db Mon Sep 17 00:00:00 2001 From: Michael vanderKamp Date: Sun, 12 Jan 2020 16:59:05 -0600 Subject: [PATCH 056/138] Add a VimuxOpenRunner command --- plugin/vimux.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 7ab3746..9259b9d 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -5,6 +5,7 @@ let g:loaded_vimux = 1 command -nargs=* VimuxRunCommand :call VimuxRunCommand() command VimuxRunLastCommand :call VimuxRunLastCommand() +command VimuxOpenRunner :call VimuxOpenRunner() command VimuxCloseRunner :call VimuxCloseRunner() command VimuxZoomRunner :call VimuxZoomRunner() command VimuxInspectRunner :call VimuxInspectRunner() From 67bd945586f7739bf99a77202cc8da12fb7eb8be Mon Sep 17 00:00:00 2001 From: Michael vanderKamp Date: Sun, 12 Jan 2020 17:37:18 -0600 Subject: [PATCH 057/138] Add detail about VimuxOpenExtraArgs option to docs --- doc/vimux.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/doc/vimux.txt b/doc/vimux.txt index a469d49..f58e2c0 100644 --- a/doc/vimux.txt +++ b/doc/vimux.txt @@ -362,5 +362,17 @@ redefine this if you're using something like tmate. Default: "tmux" +------------------------------------------------------------------------------ + *VimuxOpenExtraArgs* +2.8 g:VimuxOpenExtraArgs~ + +Allows addtional arguments to be passed to the tmux command that opens the +runner. Make sure that the arguments specified are valid depending on whether +you're using panes or windows, and your version of tmux. + + let g:VimuxOpenExtraArgs = "-c #{pane_current_path}" + +Default: "tmux" + ============================================================================== vim:tw=78:ts=2:sw=2:expandtab:ft=help:norl: From 02315b02c4a85d914d39e4f59a3cf4210b843e1e Mon Sep 17 00:00:00 2001 From: Jonathan Barratt Date: Sat, 13 Feb 2021 14:37:25 +0700 Subject: [PATCH 058/138] Fix typos in readme (#164) --- README.mkd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.mkd b/README.mkd index b5a7caa..6936da3 100644 --- a/README.mkd +++ b/README.mkd @@ -8,7 +8,7 @@ What inspired me to write vimux was [tslime.vim](https://github.com/kikijump/tsl My goal with vimux is to make interacting with tmux from vim effortless. By default when you call `VimuxRunCommand` vimux will create a 20% tall horizontal pane under your current tmux pane and execute a command in it without losing focus of vim. Once that pane exists whenever you call `VimuxRunCommand` again the command will be executed in that pane. As I was using vimux myself I wanted to rerun commands over and over. An example of this was running the current file through rspec. Rather than typing that over and over I wrote `VimuxRunLastCommand` that will execute the last command you called with `VimuxRunCommand`. -Other auxiliary functions and the ones I talked about above can be found bellow with a full description and example key binds for your vimrc. +Other auxiliary functions and the ones I talked about above can be found below with a full description and example key binds for your vimrc. ## Installation @@ -19,7 +19,7 @@ Otherwise download the latest [tarball](https://github.com/benmills/vimux/tarbal _Notes:_ -* Vimux assumes a tmux version >= 1.5. Some older versions might work but it is recommeded to use at least version 1.5. +* Vimux assumes a tmux version >= 1.5. Some older versions might work but it is recommended to use at least version 1.5. ## Platform-specific Plugins From f48360cea6df444d954abab00dc966bef4b57a1e Mon Sep 17 00:00:00 2001 From: Eugene Yunak Date: Sat, 13 Feb 2021 11:00:10 +0200 Subject: [PATCH 059/138] Fix docs, config variables should be global (#111) From fff2f1a6862e5fb4b950f3c141b6b95b9bfce191 Mon Sep 17 00:00:00 2001 From: saubhik Date: Sat, 13 Feb 2021 04:02:22 -0500 Subject: [PATCH 060/138] Fix Markdown formatting in readme (#170) --- README.mkd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.mkd b/README.mkd index 6936da3..fc1469d 100644 --- a/README.mkd +++ b/README.mkd @@ -13,7 +13,7 @@ Other auxiliary functions and the ones I talked about above can be found below w ## Installation With **[vim-bundle](https://github.com/benmills/vim-bundle)**: `vim-bundle install benmills/vimux` -With **[Vundle](https://github.com/gmarik/Vundle.vim)**: 'Plugin benmills/vimux' in your .vimrc +With **[Vundle](https://github.com/gmarik/Vundle.vim)**: `Plugin 'benmills/vimux'` in your .vimrc Otherwise download the latest [tarball](https://github.com/benmills/vimux/tarball/master), extract it and move `plugin/vimux.vim` inside `~/.vim/plugin`. If you're using [pathogen](https://github.com/tpope/vim-pathogen), then move the entire folder extracted from the tarball into `~/.vim/bundle`. From 1dec7164caa491bf7232969fdcd5368266547ba1 Mon Sep 17 00:00:00 2001 From: Eugene Yunak Date: Sat, 13 Feb 2021 11:13:02 +0200 Subject: [PATCH 061/138] Use IDs instead of indexes to identify windows and panes (#110) ...because indexes can change while IDs are constant and unique. --- plugin/vimux.vim | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index bd3a2db..5011120 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -96,7 +96,7 @@ function! VimuxTogglePane() call _VimuxTmux("join-pane -d -s ".g:VimuxRunnerIndex." -p "._VimuxOption("g:VimuxHeight", 20)) let g:VimuxRunnerType = "pane" elseif _VimuxRunnerType() == "pane" - let g:VimuxRunnerIndex=substitute(_VimuxTmux("break-pane -d -t ".g:VimuxRunnerIndex." -P -F '#{window_index}'"), "\n", "", "") + let g:VimuxRunnerIndex=substitute(_VimuxTmux("break-pane -d -t ".g:VimuxRunnerIndex." -P -F '#{window_id}'"), "\n", "", "") let g:VimuxRunnerType = "window" endif endif @@ -156,26 +156,27 @@ endfunction function! _VimuxTmuxIndex() if _VimuxRunnerType() == "pane" - return _VimuxTmuxPaneIndex() + return _VimuxTmuxPaneId() else - return _VimuxTmuxWindowIndex() + return _VimuxTmuxWindowId() end endfunction -function! _VimuxTmuxPaneIndex() - return _VimuxTmuxProperty("#I.#P") +function! _VimuxTmuxPaneId() + return _VimuxTmuxProperty("#{pane_id}") endfunction -function! _VimuxTmuxWindowIndex() - return _VimuxTmuxProperty("#I") +function! _VimuxTmuxWindowId() + return _VimuxTmuxProperty("#{window_id}") endfunction function! _VimuxNearestIndex() - let views = split(_VimuxTmux("list-"._VimuxRunnerType()."s"), "\n") + let t = _VimuxRunnerType() + let views = split(_VimuxTmux("list-".t."s -F '#{".t."_active}:#{".t."_id}'"), "\n") for view in views - if match(view, "(active)") == -1 - return split(view, ":")[0] + if match(view, "1:") == -1 + return split(view, ":")[1] endif endfor @@ -199,5 +200,6 @@ function! _VimuxTmuxProperty(property) endfunction function! _VimuxHasRunner(index) - return match(_VimuxTmux("list-"._VimuxRunnerType()."s -a"), a:index.":") + let t = _VimuxRunnerType() + return match(_VimuxTmux("list-".t."s -F '#{".t."_id}'"), a:index) endfunction From 8fa6ca92c0cf3f843c84299b0000b710c5148b14 Mon Sep 17 00:00:00 2001 From: Thomas Mayfield Date: Sat, 13 Feb 2021 04:20:02 -0500 Subject: [PATCH 062/138] Update VimuxSlime example to use VimuxRunCommand (#165) I was a little confused by the example in the VimuxTslimeReplacement section until I figured out that it was supposed to be calling VimuxRunCommand, rather than VimuxSendText -> VimuxSendKeys. The intended call is referenced in the follow paragraph, where it describes passing `0` as a second arg to that call to avoid an unwanted extra newline. --- doc/vimux.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/vimux.txt b/doc/vimux.txt index a469d49..fa3b3ce 100644 --- a/doc/vimux.txt +++ b/doc/vimux.txt @@ -251,8 +251,7 @@ First, add some helpful mappings. > function! VimuxSlime() - call VimuxSendText(@v) - call VimuxSendKeys("Enter") + call VimuxRunCommand(@v, 0) endfunction " If text is selected, save it in the v buffer and send that buffer it to tmux From 46377b8ab91553866c53d351b9e8277205e8b68a Mon Sep 17 00:00:00 2001 From: Giuseppe Rota Date: Thu, 4 Jul 2013 22:05:43 +0200 Subject: [PATCH 063/138] Escape the text sent to tmux Closes #76 --- plugin/vimux.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 5011120..c5e57cc 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -53,7 +53,7 @@ function! VimuxRunCommand(command, ...) endfunction function! VimuxSendText(text) - call VimuxSendKeys('"'.escape(a:text, '\"$`').'"') + call VimuxSendKeys(shellescape(substitute(a:text, "\n$", " ", ""))) endfunction function! VimuxSendKeys(keys) From 9c05307141e1907d0be3ebb9d4de5c1601b0bd8a Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 13 Feb 2021 18:40:22 +0300 Subject: [PATCH 064/138] Refactor PR code order to not move cheese With tons of outstanding PRs I don't want to introduce conflicts for no reason. We can refactor to make the source order more sensible later. --- plugin/vimux.vim | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 5f5df76..73f95c9 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -3,14 +3,6 @@ if exists("g:loaded_vimux") || &cp endif let g:loaded_vimux = 1 -function! _VimuxOption(option, default) - if exists(a:option) - return eval(a:option) - else - return a:default - endif -endfunction - function! _VimuxTmuxCmd() return _VimuxOption("g:VimuxTmuxCommand", "tmux") endfunction @@ -202,6 +194,14 @@ function! _VimuxRunnerType() return _VimuxOption("g:VimuxRunnerType", "pane") endfunction +function! _VimuxOption(option, default) + if exists(a:option) + return eval(a:option) + else + return a:default + endif +endfunction + function! _VimuxTmuxProperty(property) return substitute(_VimuxTmux("display -p '".a:property."'"), '\n$', '', '') endfunction From ef5622f225ad8fa592dc79799d5bc4bdf39d5dd5 Mon Sep 17 00:00:00 2001 From: Philipp Moers Date: Sat, 13 Feb 2021 17:17:10 +0100 Subject: [PATCH 065/138] Add VimuxClearTerminalScreen (#178) --- doc/vimux.txt | 20 +++++++++++++++++--- plugin/vimux.vim | 7 +++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/doc/vimux.txt b/doc/vimux.txt index fa3b3ce..77f860e 100644 --- a/doc/vimux.txt +++ b/doc/vimux.txt @@ -13,9 +13,10 @@ CONTENTS *vimux-contents* 2.3 .............................. |VimuxInspectRunner| 2.4 .............................. |VimuxCloseRunner| 2.5 .............................. |VimuxInterruptRunner| - 2.6 .............................. |VimuxClearRunnerHistory| - 2.7 .............................. |VimuxZoomRunner| - 2.8 .............................. |VimuxRunCommandInDir| + 2.6 .............................. |VimuxClearTerminalScreen| + 2.7 .............................. |VimuxClearRunnerHistory| + 2.8 .............................. |VimuxZoomRunner| + 2.9 .............................. |VimuxRunCommandInDir| 3. Misc ............................ |VimuxMisc| 3.1 Example Keybinding............ |VimuxExampleKeybinding| 3.2 Tslime Replacement............ |VimuxTslimeReplacement| @@ -70,6 +71,7 @@ Furthermore there are several handy commands all starting with 'Vimux': - |VimuxInspectRunner| - |VimuxInterruptRunner| - |VimuxPromptCommand| + - |VimuxClearTerminalScreen| - |VimuxClearRunnerHistory| - |VimuxZoomRunner| - |VimuxRunCommandInDir| @@ -170,6 +172,15 @@ runner pane. < +------------------------------------------------------------------------------ + *VimuxClearTerminalScreen* +VimuxClearTerminalScreen~ + +Clear the terminal screen of the runner pane. +> + " Clear the terminal screen of the runner pane. + map v :VimuxClearTerminalScreen +< ------------------------------------------------------------------------------ *VimuxClearRunnerHistory* @@ -240,6 +251,9 @@ Full Keybind Example~ " Zoom the runner pane (use z to restore runner pane) map vz :call VimuxZoomRunner() + + " Clear the terminal screen of the runner pane. + map v :VimuxClearTerminalScreen > ------------------------------------------------------------------------------ diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 18ac4fb..1a4dea8 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -21,6 +21,7 @@ command VimuxScrollUpInspect :call VimuxScrollUpInspect() command VimuxScrollDownInspect :call VimuxScrollDownInspect() command VimuxInterruptRunner :call VimuxInterruptRunner() command -nargs=? VimuxPromptCommand :call VimuxPromptCommand() +command VimuxClearTerminalScreen :call VimuxClearTerminalScreen() command VimuxClearRunnerHistory :call VimuxClearRunnerHistory() command VimuxTogglePane :call VimuxTogglePane() @@ -142,6 +143,12 @@ function! VimuxInterruptRunner() call VimuxSendKeys("^c") endfunction +function! VimuxClearTerminalScreen() + if exists("g:VimuxRunnerIndex") + call VimuxSendKeys("C-l") + endif +endfunction + function! VimuxClearRunnerHistory() if exists("g:VimuxRunnerIndex") call _VimuxTmux("clear-history -t ".g:VimuxRunnerIndex) From 48b541b1a426da6342f6272f8147ef9aaed8c95a Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 13 Feb 2021 19:22:44 +0300 Subject: [PATCH 066/138] Avoid useless space in default empty argument string --- plugin/vimux.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 9259b9d..b9f0337 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -71,7 +71,7 @@ function! VimuxOpenRunner() if _VimuxOption("g:VimuxUseNearest", 1) == 1 && nearestIndex != -1 let g:VimuxRunnerIndex = nearestIndex else - let extraArguments = _VimuxOption("g:VimuxOpenExtraArgs", " ") + let extraArguments = _VimuxOption("g:VimuxOpenExtraArgs", "") if _VimuxRunnerType() == "pane" let height = _VimuxOption("g:VimuxHeight", 20) let orientation = _VimuxOption("g:VimuxOrientation", "v") From cce84666132de216719baa7de38e837d2b60defb Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 13 Feb 2021 19:26:49 +0300 Subject: [PATCH 067/138] Move the cheese, because it has to move to run As anybody following this might have divined, my testing was flawed and I was running different code than I was viewing. --- plugin/vimux.vim | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index a1ec1a9..f41eb00 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -3,6 +3,14 @@ if exists("g:loaded_vimux") || &cp endif let g:loaded_vimux = 1 +function! _VimuxOption(option, default) + if exists(a:option) + return eval(a:option) + else + return a:default + endif +endfunction + function! _VimuxTmuxCmd() return _VimuxOption("g:VimuxTmuxCommand", "tmux") endfunction @@ -204,14 +212,6 @@ function! _VimuxRunnerType() return _VimuxOption("g:VimuxRunnerType", "pane") endfunction -function! _VimuxOption(option, default) - if exists(a:option) - return eval(a:option) - else - return a:default - endif -endfunction - function! _VimuxTmuxProperty(property) return substitute(_VimuxTmux("display -p '".a:property."'"), '\n$', '', '') endfunction From 57bbdc447877c1bebeff2479aeab9442658e451b Mon Sep 17 00:00:00 2001 From: Thales Mello <1127394+thalesmello@users.noreply.github.com> Date: Sat, 13 Feb 2021 10:09:55 -0800 Subject: [PATCH 068/138] Enable tab autocompletion on VimuxPromptOption (#142) --- plugin/vimux.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index f41eb00..6f9d722 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -167,7 +167,7 @@ endfunction function! VimuxPromptCommand(...) let command = a:0 == 1 ? a:1 : "" - let l:command = input(_VimuxOption("g:VimuxPromptString", "Command? "), command) + let l:command = input(_VimuxOption("g:VimuxPromptString", "Command? "), command, 'shellcmd') call VimuxRunCommand(l:command) endfunction From 0f5fd2ce498356c1ac47b2435e1304a32805be58 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sun, 14 Feb 2021 10:21:11 +0300 Subject: [PATCH 069/138] Fix typo and bump license date range, closes #154 --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 678e440..82308e2 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2103 Benjamin Mills +Copyright (c) 2012-2021 Benjamin Mills Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From af602e362d9ca791961f474afac68fb50743116c Mon Sep 17 00:00:00 2001 From: Matthias Bilger Date: Sun, 14 Feb 2021 10:10:24 +0100 Subject: [PATCH 070/138] Allow setting of VimuxRunner name to reuse session --- doc/vimux.txt | 30 +++++++++++++++++++++--------- plugin/vimux.vim | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 54 insertions(+), 10 deletions(-) diff --git a/doc/vimux.txt b/doc/vimux.txt index baf2144..0cfb413 100644 --- a/doc/vimux.txt +++ b/doc/vimux.txt @@ -291,7 +291,7 @@ You can configure Vimux like this: ------------------------------------------------------------------------------ *VimuxConfiguration_height* -2.1 g:VimuxHeight~ +4.1 g:VimuxHeight~ The percent of the screen the split pane Vimux will spawn should take up. @@ -301,7 +301,7 @@ Default: "20" ------------------------------------------------------------------------------ *VimuxConfiguration_orientation* -2.2 g:VimuxOrientation~ +4.2 g:VimuxOrientation~ The default orientation of the split tmux pane. This tells tmux to make the pane either vertically or horizontally, which is backward from how Vim handles @@ -317,7 +317,7 @@ Default: "v" ------------------------------------------------------------------------------ *VimuxConfiguration_use_nearest* -2.3 g:VimuxUseNearest +4.3 g:VimuxUseNearest Use existing pane or window (not used by vim) if found instead of running split-window. @@ -328,7 +328,7 @@ Default: 1 ------------------------------------------------------------------------------ *VimuxConfiguration_reset_sequence* -2.4 g:VimuxResetSequence~ +4.4 g:VimuxResetSequence~ The keys sent to the runner pane before running a command. By default it sends `q` to make sure the pane is not in scroll-mode and `C-u` to clear the line. @@ -339,7 +339,7 @@ Default: "q C-u" ------------------------------------------------------------------------------ *VimuxPromptString* -2.5 g:VimuxPromptString~ +4.5 g:VimuxPromptString~ The string presented in the vim command line when Vimux is invoked. Be sure to put a space at the end of the string to allow for distinction between @@ -351,7 +351,7 @@ Default: "Command? " ------------------------------------------------------------------------------ *VimuxRunnerType* -2.6 g:VimuxRunnerType~ +4.6 g:VimuxRunnerType~ The type of view object Vimux should use for the runner. For reference, a tmux session is a group of windows, and a window is a layout of panes. @@ -364,9 +364,21 @@ Options: Default: "pane" +------------------------------------------------------------------------------ + *VimuxRunnerName* +4.7 g:VimuxRunnerName + +Setting the name for the runner. Works for panes and windows. This makes the +VimuxRunner reusable between sessions. Caveat is, all your instances (in the +same session/window) use the same window. + + let g:VimuxRunnerName = "vimuxout" + +Default: "" + ------------------------------------------------------------------------------ *VimuxTmuxCommand* -2.7 g:VimuxTmuxCommand~ +4.8 g:VimuxTmuxCommand~ The command that Vimux runs when it calls out to tmux. It may be useful to redefine this if you're using something like tmate. @@ -376,8 +388,8 @@ redefine this if you're using something like tmate. Default: "tmux" ------------------------------------------------------------------------------ - *VimuxOpenExtraArgs* -2.8 g:VimuxOpenExtraArgs~ + *VimuxOpenExtraArgs* +4.9 g:VimuxOpenExtraArgs~ Allows addtional arguments to be passed to the tmux command that opens the runner. Make sure that the arguments specified are valid depending on whether diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 6f9d722..7b8d4ce 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -99,6 +99,7 @@ function! VimuxOpenRunner() endif let g:VimuxRunnerIndex = _VimuxTmuxIndex() + call _VimuxSetRunnerName() call _VimuxTmux("last-"._VimuxRunnerType()) endif endfunction @@ -172,6 +173,9 @@ function! VimuxPromptCommand(...) endfunction function! _VimuxTmux(arguments) + if _VimuxOption("g:VimuxDebug", 0) != 0 + echom _VimuxTmuxCmd()." ".a:arguments + endif return system(_VimuxTmuxCmd()." ".a:arguments) endfunction @@ -197,7 +201,8 @@ endfunction function! _VimuxNearestIndex() let t = _VimuxRunnerType() - let views = split(_VimuxTmux("list-".t."s -F '#{".t."_active}:#{".t."_id}'"), "\n") + let filter = _VimuxGetTargetFilter() + let views = split(_VimuxTmux("list-".t."s -F '#{".t."_active}:#{".t."_id}'".filter), "\n") for view in views if match(view, "1:") == -1 @@ -208,6 +213,33 @@ function! _VimuxNearestIndex() return -1 endfunction +function! _VimuxGetTargetFilter() + let targetName = _VimuxOption("g:VimuxRunnerName", "") + if targetName == "" + return "" + endif + let t = _VimuxRunnerType() + if t == "window" + return " -f '#{==:#{window_name},".targetName."}'" + elseif t == "pane" + return " -f '#{==:#{pane_title},".targetName."}'" + endif +endfunction + +function! _VimuxSetRunnerName() + let targetName = _VimuxOption("g:VimuxRunnerName", "") + if targetName == "" + return + endif + let t = _VimuxRunnerType() + if t == "window" + call _VimuxTmux("rename-window ".targetName) + elseif t == "pane" + call _VimuxTmux("select-pane -T ".targetName) + endif +endfunction + + function! _VimuxRunnerType() return _VimuxOption("g:VimuxRunnerType", "pane") endfunction From 925ae23b4297463ed1f8d44ed5e8cbb7efa60531 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 13 Feb 2021 10:49:58 +0300 Subject: [PATCH 071/138] Add Vint config file for vimscript linting --- .vintrc.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .vintrc.yaml diff --git a/.vintrc.yaml b/.vintrc.yaml new file mode 100644 index 0000000..c44b6ab --- /dev/null +++ b/.vintrc.yaml @@ -0,0 +1,5 @@ +cmdargs: + severity: style_problem + color: true + env: + neovim: false From e6fb662bf1645d0befe753b575b3c2bb2c1e86e2 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sun, 14 Feb 2021 16:50:14 +0300 Subject: [PATCH 072/138] Replace underscore convention with proper script-local scopes --- plugin/vimux.vim | 136 +++++++++++++++++++++++------------------------ 1 file changed, 68 insertions(+), 68 deletions(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 7b8d4ce..a68ccec 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -3,7 +3,7 @@ if exists("g:loaded_vimux") || &cp endif let g:loaded_vimux = 1 -function! _VimuxOption(option, default) +function! s:VimuxOption(option, default) if exists(a:option) return eval(a:option) else @@ -11,12 +11,12 @@ function! _VimuxOption(option, default) endif endfunction -function! _VimuxTmuxCmd() - return _VimuxOption("g:VimuxTmuxCommand", "tmux") +function! s:VimuxTmuxCmd() + return s:VimuxOption("g:VimuxTmuxCommand", "tmux") endfunction -if !executable(_VimuxTmuxCmd()) - echohl ErrorMsg | echomsg "Failed to find executable "._VimuxTmuxCmd() | echohl None +if !executable(s:VimuxTmuxCmd()) + echohl ErrorMsg | echomsg "Failed to find executable ".s:VimuxTmuxCmd() | echohl None finish endif @@ -51,7 +51,7 @@ function! VimuxRunLastCommand() endfunction function! VimuxRunCommand(command, ...) - if !exists("g:VimuxRunnerIndex") || _VimuxHasRunner(g:VimuxRunnerIndex) == -1 + if !exists("g:VimuxRunnerIndex") || s:VimuxHasRunner(g:VimuxRunnerIndex) == -1 call VimuxOpenRunner() endif @@ -60,7 +60,7 @@ function! VimuxRunCommand(command, ...) let l:autoreturn = a:1 endif - let resetSequence = _VimuxOption("g:VimuxResetSequence", "q C-u") + let resetSequence = s:VimuxOption("g:VimuxResetSequence", "q C-u") let g:VimuxLastCommand = a:command call VimuxSendKeys(resetSequence) @@ -77,47 +77,47 @@ endfunction function! VimuxSendKeys(keys) if exists("g:VimuxRunnerIndex") - call _VimuxTmux("send-keys -t ".g:VimuxRunnerIndex." ".a:keys) + call s:VimuxTmux("send-keys -t ".g:VimuxRunnerIndex." ".a:keys) else echo "No vimux runner pane/window. Create one with VimuxOpenRunner" endif endfunction function! VimuxOpenRunner() - let nearestIndex = _VimuxNearestIndex() + let nearestIndex = s:VimuxNearestIndex() - if _VimuxOption("g:VimuxUseNearest", 1) == 1 && nearestIndex != -1 + if s:VimuxOption("g:VimuxUseNearest", 1) == 1 && nearestIndex != -1 let g:VimuxRunnerIndex = nearestIndex else - let extraArguments = _VimuxOption("g:VimuxOpenExtraArgs", "") - if _VimuxRunnerType() == "pane" - let height = _VimuxOption("g:VimuxHeight", 20) - let orientation = _VimuxOption("g:VimuxOrientation", "v") - call _VimuxTmux("split-window -p ".height." -".orientation." ".extraArguments) - elseif _VimuxRunnerType() == "window" - call _VimuxTmux("new-window ".extraArguments) + let extraArguments = s:VimuxOption("g:VimuxOpenExtraArgs", "") + if s:VimuxRunnerType() == "pane" + let height = s:VimuxOption("g:VimuxHeight", 20) + let orientation = s:VimuxOption("g:VimuxOrientation", "v") + call s:VimuxTmux("split-window -p ".height." -".orientation." ".extraArguments) + elseif s:VimuxRunnerType() == "window" + call s:VimuxTmux("new-window ".extraArguments) endif - let g:VimuxRunnerIndex = _VimuxTmuxIndex() - call _VimuxSetRunnerName() - call _VimuxTmux("last-"._VimuxRunnerType()) + let g:VimuxRunnerIndex = s:VimuxTmuxIndex() + call s:VimuxSetRunnerName() + call s:VimuxTmux("last-".s:VimuxRunnerType()) endif endfunction function! VimuxCloseRunner() if exists("g:VimuxRunnerIndex") - call _VimuxTmux("kill-"._VimuxRunnerType()." -t ".g:VimuxRunnerIndex) + call s:VimuxTmux("kill-".s:VimuxRunnerType()." -t ".g:VimuxRunnerIndex) unlet g:VimuxRunnerIndex endif endfunction function! VimuxTogglePane() if exists("g:VimuxRunnerIndex") - if _VimuxRunnerType() == "window" - call _VimuxTmux("join-pane -d -s ".g:VimuxRunnerIndex." -p "._VimuxOption("g:VimuxHeight", 20)) + if s:VimuxRunnerType() == "window" + call s:VimuxTmux("join-pane -d -s ".g:VimuxRunnerIndex." -p ".s:VimuxOption("g:VimuxHeight", 20)) let g:VimuxRunnerType = "pane" - elseif _VimuxRunnerType() == "pane" - let g:VimuxRunnerIndex=substitute(_VimuxTmux("break-pane -d -t ".g:VimuxRunnerIndex." -P -F '#{window_id}'"), "\n", "", "") + elseif s:VimuxRunnerType() == "pane" + let g:VimuxRunnerIndex=substitute(s:VimuxTmux("break-pane -d -t ".g:VimuxRunnerIndex." -P -F '#{window_id}'"), "\n", "", "") let g:VimuxRunnerType = "window" endif endif @@ -125,28 +125,28 @@ endfunction function! VimuxZoomRunner() if exists("g:VimuxRunnerIndex") - if _VimuxRunnerType() == "pane" - call _VimuxTmux("resize-pane -Z -t ".g:VimuxRunnerIndex) - elseif _VimuxRunnerType() == "window" - call _VimuxTmux("select-window -t ".g:VimuxRunnerIndex) + if s:VimuxRunnerType() == "pane" + call s:VimuxTmux("resize-pane -Z -t ".g:VimuxRunnerIndex) + elseif s:VimuxRunnerType() == "window" + call s:VimuxTmux("select-window -t ".g:VimuxRunnerIndex) endif endif endfunction function! VimuxInspectRunner() - call _VimuxTmux("select-"._VimuxRunnerType()." -t ".g:VimuxRunnerIndex) - call _VimuxTmux("copy-mode") + call s:VimuxTmux("select-".s:VimuxRunnerType()." -t ".g:VimuxRunnerIndex) + call s:VimuxTmux("copy-mode") endfunction function! VimuxScrollUpInspect() call VimuxInspectRunner() - call _VimuxTmux("last-"._VimuxRunnerType()) + call s:VimuxTmux("last-".s:VimuxRunnerType()) call VimuxSendKeys("C-u") endfunction function! VimuxScrollDownInspect() call VimuxInspectRunner() - call _VimuxTmux("last-"._VimuxRunnerType()) + call s:VimuxTmux("last-".s:VimuxRunnerType()) call VimuxSendKeys("C-d") endfunction @@ -162,47 +162,47 @@ endfunction function! VimuxClearRunnerHistory() if exists("g:VimuxRunnerIndex") - call _VimuxTmux("clear-history -t ".g:VimuxRunnerIndex) + call s:VimuxTmux("clear-history -t ".g:VimuxRunnerIndex) endif endfunction function! VimuxPromptCommand(...) let command = a:0 == 1 ? a:1 : "" - let l:command = input(_VimuxOption("g:VimuxPromptString", "Command? "), command, 'shellcmd') + let l:command = input(s:VimuxOption("g:VimuxPromptString", "Command? "), command, 'shellcmd') call VimuxRunCommand(l:command) endfunction -function! _VimuxTmux(arguments) - if _VimuxOption("g:VimuxDebug", 0) != 0 - echom _VimuxTmuxCmd()." ".a:arguments +function! s:VimuxTmux(arguments) + if s:VimuxOption("g:VimuxDebug", 0) != 0 + echom s:VimuxTmuxCmd()." ".a:arguments endif - return system(_VimuxTmuxCmd()." ".a:arguments) + return system(s:VimuxTmuxCmd()." ".a:arguments) endfunction -function! _VimuxTmuxSession() - return _VimuxTmuxProperty("#S") +function! s:VimuxTmuxSession() + return s:VimuxTmuxProperty("#S") endfunction -function! _VimuxTmuxIndex() - if _VimuxRunnerType() == "pane" - return _VimuxTmuxPaneId() +function! s:VimuxTmuxIndex() + if s:VimuxRunnerType() == "pane" + return s:VimuxTmuxPaneId() else - return _VimuxTmuxWindowId() + return s:VimuxTmuxWindowId() end endfunction -function! _VimuxTmuxPaneId() - return _VimuxTmuxProperty("#{pane_id}") +function! s:VimuxTmuxPaneId() + return s:VimuxTmuxProperty("#{pane_id}") endfunction -function! _VimuxTmuxWindowId() - return _VimuxTmuxProperty("#{window_id}") +function! s:VimuxTmuxWindowId() + return s:VimuxTmuxProperty("#{window_id}") endfunction -function! _VimuxNearestIndex() - let t = _VimuxRunnerType() - let filter = _VimuxGetTargetFilter() - let views = split(_VimuxTmux("list-".t."s -F '#{".t."_active}:#{".t."_id}'".filter), "\n") +function! s:VimuxNearestIndex() + let t = s:VimuxRunnerType() + let filter = s:VimuxGetTargetFilter() + let views = split(s:VimuxTmux("list-".t."s -F '#{".t."_active}:#{".t."_id}'".filter), "\n") for view in views if match(view, "1:") == -1 @@ -213,12 +213,12 @@ function! _VimuxNearestIndex() return -1 endfunction -function! _VimuxGetTargetFilter() - let targetName = _VimuxOption("g:VimuxRunnerName", "") +function! s:VimuxGetTargetFilter() + let targetName = s:VimuxOption("g:VimuxRunnerName", "") if targetName == "" return "" endif - let t = _VimuxRunnerType() + let t = s:VimuxRunnerType() if t == "window" return " -f '#{==:#{window_name},".targetName."}'" elseif t == "pane" @@ -226,29 +226,29 @@ function! _VimuxGetTargetFilter() endif endfunction -function! _VimuxSetRunnerName() - let targetName = _VimuxOption("g:VimuxRunnerName", "") +function! s:VimuxSetRunnerName() + let targetName = s:VimuxOption("g:VimuxRunnerName", "") if targetName == "" return endif - let t = _VimuxRunnerType() + let t = s:VimuxRunnerType() if t == "window" - call _VimuxTmux("rename-window ".targetName) + call s:VimuxTmux("rename-window ".targetName) elseif t == "pane" - call _VimuxTmux("select-pane -T ".targetName) + call s:VimuxTmux("select-pane -T ".targetName) endif endfunction -function! _VimuxRunnerType() - return _VimuxOption("g:VimuxRunnerType", "pane") +function! s:VimuxRunnerType() + return s:VimuxOption("g:VimuxRunnerType", "pane") endfunction -function! _VimuxTmuxProperty(property) - return substitute(_VimuxTmux("display -p '".a:property."'"), '\n$', '', '') +function! s:VimuxTmuxProperty(property) + return substitute(s:VimuxTmux("display -p '".a:property."'"), '\n$', '', '') endfunction -function! _VimuxHasRunner(index) - let t = _VimuxRunnerType() - return match(_VimuxTmux("list-".t."s -F '#{".t."_id}'"), a:index) +function! s:VimuxHasRunner(index) + let t = s:VimuxRunnerType() + return match(s:VimuxTmux("list-".t."s -F '#{".t."_id}'"), a:index) endfunction From a5a17b8e328160f61703c1a5979fd4de7eee179e Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sun, 14 Feb 2021 17:31:30 +0300 Subject: [PATCH 073/138] Prefer single quoted strings --- plugin/vimux.vim | 148 +++++++++++++++++++++++------------------------ 1 file changed, 74 insertions(+), 74 deletions(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index a68ccec..87d0af1 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -1,4 +1,4 @@ -if exists("g:loaded_vimux") || &cp +if exists('g:loaded_vimux') || &cp finish endif let g:loaded_vimux = 1 @@ -12,11 +12,11 @@ function! s:VimuxOption(option, default) endfunction function! s:VimuxTmuxCmd() - return s:VimuxOption("g:VimuxTmuxCommand", "tmux") + return s:VimuxOption('g:VimuxTmuxCommand', 'tmux') endfunction if !executable(s:VimuxTmuxCmd()) - echohl ErrorMsg | echomsg "Failed to find executable ".s:VimuxTmuxCmd() | echohl None + echohl ErrorMsg | echomsg 'Failed to find executable '.s:VimuxTmuxCmd() | echohl None finish endif @@ -35,156 +35,156 @@ command VimuxClearRunnerHistory :call VimuxClearRunnerHistory() command VimuxTogglePane :call VimuxTogglePane() function! VimuxRunCommandInDir(command, useFile) - let l:file = "" + let l:file = '' if a:useFile ==# 1 let l:file = shellescape(expand('%:t'), 1) endif - call VimuxRunCommand("(cd ".shellescape(expand('%:p:h'), 1)." && ".a:command." ".l:file.")") + call VimuxRunCommand('(cd '.shellescape(expand('%:p:h'), 1).' && '.a:command.' '.l:file.')') endfunction function! VimuxRunLastCommand() - if exists("g:VimuxRunnerIndex") + if exists('g:VimuxRunnerIndex') call VimuxRunCommand(g:VimuxLastCommand) else - echo "No last vimux command." + echo 'No last vimux command.' endif endfunction function! VimuxRunCommand(command, ...) - if !exists("g:VimuxRunnerIndex") || s:VimuxHasRunner(g:VimuxRunnerIndex) == -1 + if !exists('g:VimuxRunnerIndex') || s:VimuxHasRunner(g:VimuxRunnerIndex) == -1 call VimuxOpenRunner() endif let l:autoreturn = 1 - if exists("a:1") + if exists('a:1') let l:autoreturn = a:1 endif - let resetSequence = s:VimuxOption("g:VimuxResetSequence", "q C-u") + let resetSequence = s:VimuxOption('g:VimuxResetSequence', 'q C-u') let g:VimuxLastCommand = a:command call VimuxSendKeys(resetSequence) call VimuxSendText(a:command) if l:autoreturn == 1 - call VimuxSendKeys("Enter") + call VimuxSendKeys('Enter') endif endfunction function! VimuxSendText(text) - call VimuxSendKeys(shellescape(substitute(a:text, "\n$", " ", ""))) + call VimuxSendKeys(shellescape(substitute(a:text, '\n$', ' ', ''))) endfunction function! VimuxSendKeys(keys) - if exists("g:VimuxRunnerIndex") - call s:VimuxTmux("send-keys -t ".g:VimuxRunnerIndex." ".a:keys) + if exists('g:VimuxRunnerIndex') + call s:VimuxTmux('send-keys -t '.g:VimuxRunnerIndex.' '.a:keys) else - echo "No vimux runner pane/window. Create one with VimuxOpenRunner" + echo 'No vimux runner pane/window. Create one with VimuxOpenRunner' endif endfunction function! VimuxOpenRunner() let nearestIndex = s:VimuxNearestIndex() - if s:VimuxOption("g:VimuxUseNearest", 1) == 1 && nearestIndex != -1 + if s:VimuxOption('g:VimuxUseNearest', 1) == 1 && nearestIndex != -1 let g:VimuxRunnerIndex = nearestIndex else - let extraArguments = s:VimuxOption("g:VimuxOpenExtraArgs", "") - if s:VimuxRunnerType() == "pane" - let height = s:VimuxOption("g:VimuxHeight", 20) - let orientation = s:VimuxOption("g:VimuxOrientation", "v") - call s:VimuxTmux("split-window -p ".height." -".orientation." ".extraArguments) - elseif s:VimuxRunnerType() == "window" - call s:VimuxTmux("new-window ".extraArguments) + let extraArguments = s:VimuxOption('g:VimuxOpenExtraArgs', '') + if s:VimuxRunnerType() == 'pane' + let height = s:VimuxOption('g:VimuxHeight', 20) + let orientation = s:VimuxOption('g:VimuxOrientation', 'v') + call s:VimuxTmux('split-window -p '.height.' -'.orientation.' '.extraArguments) + elseif s:VimuxRunnerType() == 'window' + call s:VimuxTmux('new-window '.extraArguments) endif let g:VimuxRunnerIndex = s:VimuxTmuxIndex() call s:VimuxSetRunnerName() - call s:VimuxTmux("last-".s:VimuxRunnerType()) + call s:VimuxTmux('last-'.s:VimuxRunnerType()) endif endfunction function! VimuxCloseRunner() - if exists("g:VimuxRunnerIndex") - call s:VimuxTmux("kill-".s:VimuxRunnerType()." -t ".g:VimuxRunnerIndex) + if exists('g:VimuxRunnerIndex') + call s:VimuxTmux('kill-'.s:VimuxRunnerType().' -t '.g:VimuxRunnerIndex) unlet g:VimuxRunnerIndex endif endfunction function! VimuxTogglePane() - if exists("g:VimuxRunnerIndex") - if s:VimuxRunnerType() == "window" - call s:VimuxTmux("join-pane -d -s ".g:VimuxRunnerIndex." -p ".s:VimuxOption("g:VimuxHeight", 20)) - let g:VimuxRunnerType = "pane" - elseif s:VimuxRunnerType() == "pane" - let g:VimuxRunnerIndex=substitute(s:VimuxTmux("break-pane -d -t ".g:VimuxRunnerIndex." -P -F '#{window_id}'"), "\n", "", "") - let g:VimuxRunnerType = "window" + if exists('g:VimuxRunnerIndex') + if s:VimuxRunnerType() == 'window' + call s:VimuxTmux('join-pane -d -s '.g:VimuxRunnerIndex.' -p '.s:VimuxOption('g:VimuxHeight', 20)) + let g:VimuxRunnerType = 'pane' + elseif s:VimuxRunnerType() == 'pane' + let g:VimuxRunnerIndex=substitute(s:VimuxTmux('break-pane -d -t '.g:VimuxRunnerIndex." -P -F '#{window_id}'"), '\n', '', '') + let g:VimuxRunnerType = 'window' endif endif endfunction function! VimuxZoomRunner() - if exists("g:VimuxRunnerIndex") - if s:VimuxRunnerType() == "pane" - call s:VimuxTmux("resize-pane -Z -t ".g:VimuxRunnerIndex) - elseif s:VimuxRunnerType() == "window" - call s:VimuxTmux("select-window -t ".g:VimuxRunnerIndex) + if exists('g:VimuxRunnerIndex') + if s:VimuxRunnerType() == 'pane' + call s:VimuxTmux('resize-pane -Z -t '.g:VimuxRunnerIndex) + elseif s:VimuxRunnerType() == 'window' + call s:VimuxTmux('select-window -t '.g:VimuxRunnerIndex) endif endif endfunction function! VimuxInspectRunner() - call s:VimuxTmux("select-".s:VimuxRunnerType()." -t ".g:VimuxRunnerIndex) - call s:VimuxTmux("copy-mode") + call s:VimuxTmux('select-'.s:VimuxRunnerType().' -t '.g:VimuxRunnerIndex) + call s:VimuxTmux('copy-mode') endfunction function! VimuxScrollUpInspect() call VimuxInspectRunner() - call s:VimuxTmux("last-".s:VimuxRunnerType()) - call VimuxSendKeys("C-u") + call s:VimuxTmux('last-'.s:VimuxRunnerType()) + call VimuxSendKeys('C-u') endfunction function! VimuxScrollDownInspect() call VimuxInspectRunner() - call s:VimuxTmux("last-".s:VimuxRunnerType()) - call VimuxSendKeys("C-d") + call s:VimuxTmux('last-'.s:VimuxRunnerType()) + call VimuxSendKeys('C-d') endfunction function! VimuxInterruptRunner() - call VimuxSendKeys("^c") + call VimuxSendKeys('^c') endfunction function! VimuxClearTerminalScreen() - if exists("g:VimuxRunnerIndex") - call VimuxSendKeys("C-l") + if exists('g:VimuxRunnerIndex') + call VimuxSendKeys('C-l') endif endfunction function! VimuxClearRunnerHistory() - if exists("g:VimuxRunnerIndex") - call s:VimuxTmux("clear-history -t ".g:VimuxRunnerIndex) + if exists('g:VimuxRunnerIndex') + call s:VimuxTmux('clear-history -t '.g:VimuxRunnerIndex) endif endfunction function! VimuxPromptCommand(...) - let command = a:0 == 1 ? a:1 : "" - let l:command = input(s:VimuxOption("g:VimuxPromptString", "Command? "), command, 'shellcmd') + let command = a:0 == 1 ? a:1 : '' + let l:command = input(s:VimuxOption('g:VimuxPromptString', 'Command? '), command, 'shellcmd') call VimuxRunCommand(l:command) endfunction function! s:VimuxTmux(arguments) - if s:VimuxOption("g:VimuxDebug", 0) != 0 - echom s:VimuxTmuxCmd()." ".a:arguments + if s:VimuxOption('g:VimuxDebug', 0) != 0 + echom s:VimuxTmuxCmd().' '.a:arguments endif - return system(s:VimuxTmuxCmd()." ".a:arguments) + return system(s:VimuxTmuxCmd().' '.a:arguments) endfunction function! s:VimuxTmuxSession() - return s:VimuxTmuxProperty("#S") + return s:VimuxTmuxProperty('#S') endfunction function! s:VimuxTmuxIndex() - if s:VimuxRunnerType() == "pane" + if s:VimuxRunnerType() == 'pane' return s:VimuxTmuxPaneId() else return s:VimuxTmuxWindowId() @@ -192,21 +192,21 @@ function! s:VimuxTmuxIndex() endfunction function! s:VimuxTmuxPaneId() - return s:VimuxTmuxProperty("#{pane_id}") + return s:VimuxTmuxProperty('#{pane_id}') endfunction function! s:VimuxTmuxWindowId() - return s:VimuxTmuxProperty("#{window_id}") + return s:VimuxTmuxProperty('#{window_id}') endfunction function! s:VimuxNearestIndex() let t = s:VimuxRunnerType() let filter = s:VimuxGetTargetFilter() - let views = split(s:VimuxTmux("list-".t."s -F '#{".t."_active}:#{".t."_id}'".filter), "\n") + let views = split(s:VimuxTmux('list-'.t."s -F '#{".t.'_active}:#{'.t."_id}'".filter), '\n') for view in views - if match(view, "1:") == -1 - return split(view, ":")[1] + if match(view, '1:') == -1 + return split(view, ':')[1] endif endfor @@ -214,34 +214,34 @@ function! s:VimuxNearestIndex() endfunction function! s:VimuxGetTargetFilter() - let targetName = s:VimuxOption("g:VimuxRunnerName", "") - if targetName == "" - return "" + let targetName = s:VimuxOption('g:VimuxRunnerName', '') + if targetName == '' + return '' endif let t = s:VimuxRunnerType() - if t == "window" + if t == 'window' return " -f '#{==:#{window_name},".targetName."}'" - elseif t == "pane" + elseif t == 'pane' return " -f '#{==:#{pane_title},".targetName."}'" endif endfunction function! s:VimuxSetRunnerName() - let targetName = s:VimuxOption("g:VimuxRunnerName", "") - if targetName == "" + let targetName = s:VimuxOption('g:VimuxRunnerName', '') + if targetName == '' return endif let t = s:VimuxRunnerType() - if t == "window" - call s:VimuxTmux("rename-window ".targetName) - elseif t == "pane" - call s:VimuxTmux("select-pane -T ".targetName) + if t == 'window' + call s:VimuxTmux('rename-window '.targetName) + elseif t == 'pane' + call s:VimuxTmux('select-pane -T '.targetName) endif endfunction function! s:VimuxRunnerType() - return s:VimuxOption("g:VimuxRunnerType", "pane") + return s:VimuxOption('g:VimuxRunnerType', 'pane') endfunction function! s:VimuxTmuxProperty(property) @@ -250,5 +250,5 @@ endfunction function! s:VimuxHasRunner(index) let t = s:VimuxRunnerType() - return match(s:VimuxTmux("list-".t."s -F '#{".t."_id}'"), a:index) + return match(s:VimuxTmux('list-'.t."s -F '#{".t."_id}'"), a:index) endfunction From f589e21472e6ae370b26af34005f35717d76fbc4 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sun, 14 Feb 2021 19:15:05 +0300 Subject: [PATCH 074/138] Use the full option name --- plugin/vimux.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 87d0af1..9de4f2f 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -1,4 +1,4 @@ -if exists('g:loaded_vimux') || &cp +if exists('g:loaded_vimux') || &compatible finish endif let g:loaded_vimux = 1 From c212352f931d5dc72b961495c2daa5d5fa165710 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sun, 14 Feb 2021 19:17:08 +0300 Subject: [PATCH 075/138] Use robust operators --- plugin/vimux.vim | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 9de4f2f..e58af19 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -51,7 +51,7 @@ function! VimuxRunLastCommand() endfunction function! VimuxRunCommand(command, ...) - if !exists('g:VimuxRunnerIndex') || s:VimuxHasRunner(g:VimuxRunnerIndex) == -1 + if !exists('g:VimuxRunnerIndex') || s:VimuxHasRunner(g:VimuxRunnerIndex) ==# -1 call VimuxOpenRunner() endif @@ -66,7 +66,7 @@ function! VimuxRunCommand(command, ...) call VimuxSendKeys(resetSequence) call VimuxSendText(a:command) - if l:autoreturn == 1 + if l:autoreturn ==# 1 call VimuxSendKeys('Enter') endif endfunction @@ -86,15 +86,15 @@ endfunction function! VimuxOpenRunner() let nearestIndex = s:VimuxNearestIndex() - if s:VimuxOption('g:VimuxUseNearest', 1) == 1 && nearestIndex != -1 + if s:VimuxOption('g:VimuxUseNearest', 1) ==# 1 && nearestIndex != -1 let g:VimuxRunnerIndex = nearestIndex else let extraArguments = s:VimuxOption('g:VimuxOpenExtraArgs', '') - if s:VimuxRunnerType() == 'pane' + if s:VimuxRunnerType() ==# 'pane' let height = s:VimuxOption('g:VimuxHeight', 20) let orientation = s:VimuxOption('g:VimuxOrientation', 'v') call s:VimuxTmux('split-window -p '.height.' -'.orientation.' '.extraArguments) - elseif s:VimuxRunnerType() == 'window' + elseif s:VimuxRunnerType() ==# 'window' call s:VimuxTmux('new-window '.extraArguments) endif @@ -113,10 +113,10 @@ endfunction function! VimuxTogglePane() if exists('g:VimuxRunnerIndex') - if s:VimuxRunnerType() == 'window' + if s:VimuxRunnerType() ==# 'window' call s:VimuxTmux('join-pane -d -s '.g:VimuxRunnerIndex.' -p '.s:VimuxOption('g:VimuxHeight', 20)) let g:VimuxRunnerType = 'pane' - elseif s:VimuxRunnerType() == 'pane' + elseif s:VimuxRunnerType() ==# 'pane' let g:VimuxRunnerIndex=substitute(s:VimuxTmux('break-pane -d -t '.g:VimuxRunnerIndex." -P -F '#{window_id}'"), '\n', '', '') let g:VimuxRunnerType = 'window' endif @@ -125,9 +125,9 @@ endfunction function! VimuxZoomRunner() if exists('g:VimuxRunnerIndex') - if s:VimuxRunnerType() == 'pane' + if s:VimuxRunnerType() ==# 'pane' call s:VimuxTmux('resize-pane -Z -t '.g:VimuxRunnerIndex) - elseif s:VimuxRunnerType() == 'window' + elseif s:VimuxRunnerType() ==# 'window' call s:VimuxTmux('select-window -t '.g:VimuxRunnerIndex) endif endif @@ -167,7 +167,7 @@ function! VimuxClearRunnerHistory() endfunction function! VimuxPromptCommand(...) - let command = a:0 == 1 ? a:1 : '' + let command = a:0 ==# 1 ? a:1 : '' let l:command = input(s:VimuxOption('g:VimuxPromptString', 'Command? '), command, 'shellcmd') call VimuxRunCommand(l:command) endfunction @@ -184,7 +184,7 @@ function! s:VimuxTmuxSession() endfunction function! s:VimuxTmuxIndex() - if s:VimuxRunnerType() == 'pane' + if s:VimuxRunnerType() ==# 'pane' return s:VimuxTmuxPaneId() else return s:VimuxTmuxWindowId() @@ -205,7 +205,7 @@ function! s:VimuxNearestIndex() let views = split(s:VimuxTmux('list-'.t."s -F '#{".t.'_active}:#{'.t."_id}'".filter), '\n') for view in views - if match(view, '1:') == -1 + if match(view, '1:') ==# -1 return split(view, ':')[1] endif endfor @@ -215,26 +215,26 @@ endfunction function! s:VimuxGetTargetFilter() let targetName = s:VimuxOption('g:VimuxRunnerName', '') - if targetName == '' + if targetName ==# '' return '' endif let t = s:VimuxRunnerType() - if t == 'window' + if t ==# 'window' return " -f '#{==:#{window_name},".targetName."}'" - elseif t == 'pane' + elseif t ==# 'pane' return " -f '#{==:#{pane_title},".targetName."}'" endif endfunction function! s:VimuxSetRunnerName() let targetName = s:VimuxOption('g:VimuxRunnerName', '') - if targetName == '' + if targetName ==# '' return endif let t = s:VimuxRunnerType() - if t == 'window' + if t ==# 'window' call s:VimuxTmux('rename-window '.targetName) - elseif t == 'pane' + elseif t ==# 'pane' call s:VimuxTmux('select-pane -T '.targetName) endif endfunction From 0e3ebca98b94002312653dc53e11d3ee7d8cba37 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sun, 14 Feb 2021 19:22:12 +0300 Subject: [PATCH 076/138] Add CI job to run vint linter --- .github/workflows/vint.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .github/workflows/vint.yml diff --git a/.github/workflows/vint.yml b/.github/workflows/vint.yml new file mode 100644 index 0000000..36d7258 --- /dev/null +++ b/.github/workflows/vint.yml @@ -0,0 +1,15 @@ +name: Vint +on: [push, pull_request] +jobs: + vint: + strategy: + fail-fast: false + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@master + - name: Run vint with reviewdog + uses: reviewdog/action-vint@v1.0.1 + with: + github_token: ${{ secrets.github_token }} + reporter: github-pr-review From 486ac1bd6e1a6402e6519bc95cb0fa5bc0a59300 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sun, 14 Feb 2021 19:25:56 +0300 Subject: [PATCH 077/138] Add lint badge to README --- README.mkd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.mkd b/README.mkd index fc1469d..9176f45 100644 --- a/README.mkd +++ b/README.mkd @@ -1,6 +1,6 @@ -# vimux +# Vimux: easily interact with tmux from vim -Easily interact with tmux from vim. +[![Vint](https://github.com/preservim/vimux/workflows/Vint/badge.svg)](https://github.com/preservim/vimux/actions?workflow=Vint) ![vimux](https://www.braintreepayments.com/blog/content/images/blog/vimux3.png) From efe04f05dcb0c3556a3edd595de6fdd4034ffce6 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sun, 14 Feb 2021 19:26:39 +0300 Subject: [PATCH 078/138] Use more standard suffix for Markdown file --- README.mkd => README.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename README.mkd => README.md (100%) diff --git a/README.mkd b/README.md similarity index 100% rename from README.mkd rename to README.md From ed12df373aebd115d9def19736262a1a9968347a Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sun, 14 Feb 2021 19:48:48 +0300 Subject: [PATCH 079/138] Update canonical URL in readme to new org namespace --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9176f45..636a2fa 100644 --- a/README.md +++ b/README.md @@ -12,10 +12,10 @@ Other auxiliary functions and the ones I talked about above can be found below w ## Installation -With **[vim-bundle](https://github.com/benmills/vim-bundle)**: `vim-bundle install benmills/vimux` -With **[Vundle](https://github.com/gmarik/Vundle.vim)**: `Plugin 'benmills/vimux'` in your .vimrc +With **[vim-bundle](https://github.com/preservim/vim-bundle)**: `vim-bundle install preservim/vimux` +With **[Vundle](https://github.com/gmarik/Vundle.vim)**: `Plugin 'preservim/vimux'` in your .vimrc -Otherwise download the latest [tarball](https://github.com/benmills/vimux/tarball/master), extract it and move `plugin/vimux.vim` inside `~/.vim/plugin`. If you're using [pathogen](https://github.com/tpope/vim-pathogen), then move the entire folder extracted from the tarball into `~/.vim/bundle`. +Otherwise download the latest [tarball](https://github.com/preservim/vimux/tarball/master), extract it and move `plugin/vimux.vim` inside `~/.vim/plugin`. If you're using [pathogen](https://github.com/tpope/vim-pathogen), then move the entire folder extracted from the tarball into `~/.vim/bundle`. _Notes:_ @@ -38,4 +38,4 @@ _Notes:_ ## Usage -The full documentation is available [online](https://raw.github.com/benmills/vimux/master/doc/vimux.txt) and accessible inside vim `:help vimux` +The full documentation is available [online](https://raw.github.com/preservim/vimux/master/doc/vimux.txt) and accessible inside vim `:help vimux` From a2ab8880a1eb1cae2c7216faa6ade3d83925e4cf Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sun, 14 Feb 2021 20:23:57 +0300 Subject: [PATCH 080/138] Allow all commands to be used in chains (#182) Allow all commands to be used in chains --- plugin/vimux.vim | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index e58af19..a49e596 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -20,19 +20,19 @@ if !executable(s:VimuxTmuxCmd()) finish endif -command -nargs=* VimuxRunCommand :call VimuxRunCommand() -command VimuxRunLastCommand :call VimuxRunLastCommand() -command VimuxOpenRunner :call VimuxOpenRunner() -command VimuxCloseRunner :call VimuxCloseRunner() -command VimuxZoomRunner :call VimuxZoomRunner() -command VimuxInspectRunner :call VimuxInspectRunner() -command VimuxScrollUpInspect :call VimuxScrollUpInspect() -command VimuxScrollDownInspect :call VimuxScrollDownInspect() -command VimuxInterruptRunner :call VimuxInterruptRunner() -command -nargs=? VimuxPromptCommand :call VimuxPromptCommand() -command VimuxClearTerminalScreen :call VimuxClearTerminalScreen() -command VimuxClearRunnerHistory :call VimuxClearRunnerHistory() -command VimuxTogglePane :call VimuxTogglePane() +command -bar -nargs=* VimuxRunCommand :call VimuxRunCommand() +command -bar VimuxRunLastCommand :call VimuxRunLastCommand() +command -bar VimuxOpenRunner :call VimuxOpenRunner() +command -bar VimuxCloseRunner :call VimuxCloseRunner() +command -bar VimuxZoomRunner :call VimuxZoomRunner() +command -bar VimuxInspectRunner :call VimuxInspectRunner() +command -bar VimuxScrollUpInspect :call VimuxScrollUpInspect() +command -bar VimuxScrollDownInspect :call VimuxScrollDownInspect() +command -bar VimuxInterruptRunner :call VimuxInterruptRunner() +command -bar -nargs=? VimuxPromptCommand :call VimuxPromptCommand() +command -bar VimuxClearTerminalScreen :call VimuxClearTerminalScreen() +command -bar VimuxClearRunnerHistory :call VimuxClearRunnerHistory() +command -bar VimuxTogglePane :call VimuxTogglePane() function! VimuxRunCommandInDir(command, useFile) let l:file = '' From 3a1aad87526c4dfdbabe281f815b2152571933f5 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 16 Feb 2021 10:08:56 +0300 Subject: [PATCH 081/138] style: Normalize indentation and other whitespace --- plugin/vimux.vim | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index a49e596..3b5562b 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -35,11 +35,11 @@ command -bar VimuxClearRunnerHistory :call VimuxClearRunnerHistory() command -bar VimuxTogglePane :call VimuxTogglePane() function! VimuxRunCommandInDir(command, useFile) - let l:file = '' - if a:useFile ==# 1 - let l:file = shellescape(expand('%:t'), 1) - endif - call VimuxRunCommand('(cd '.shellescape(expand('%:p:h'), 1).' && '.a:command.' '.l:file.')') + let l:file = '' + if a:useFile ==# 1 + let l:file = shellescape(expand('%:t'), 1) + endif + call VimuxRunCommand('(cd '.shellescape(expand('%:p:h'), 1).' && '.a:command.' '.l:file.')') endfunction function! VimuxRunLastCommand() @@ -114,11 +114,11 @@ endfunction function! VimuxTogglePane() if exists('g:VimuxRunnerIndex') if s:VimuxRunnerType() ==# 'window' - call s:VimuxTmux('join-pane -d -s '.g:VimuxRunnerIndex.' -p '.s:VimuxOption('g:VimuxHeight', 20)) - let g:VimuxRunnerType = 'pane' + call s:VimuxTmux('join-pane -d -s '.g:VimuxRunnerIndex.' -p '.s:VimuxOption('g:VimuxHeight', 20)) + let g:VimuxRunnerType = 'pane' elseif s:VimuxRunnerType() ==# 'pane' - let g:VimuxRunnerIndex=substitute(s:VimuxTmux('break-pane -d -t '.g:VimuxRunnerIndex." -P -F '#{window_id}'"), '\n', '', '') - let g:VimuxRunnerType = 'window' + let g:VimuxRunnerIndex=substitute(s:VimuxTmux('break-pane -d -t '.g:VimuxRunnerIndex." -P -F '#{window_id}'"), '\n', '', '') + let g:VimuxRunnerType = 'window' endif endif endfunction @@ -245,7 +245,7 @@ function! s:VimuxRunnerType() endfunction function! s:VimuxTmuxProperty(property) - return substitute(s:VimuxTmux("display -p '".a:property."'"), '\n$', '', '') + return substitute(s:VimuxTmux("display -p '".a:property."'"), '\n$', '', '') endfunction function! s:VimuxHasRunner(index) From 5f999f4dc4652bf0910a65b5c69c2da032d563e7 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 16 Feb 2021 10:05:58 +0300 Subject: [PATCH 082/138] Fix variable mismatch looking for previous command --- plugin/vimux.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 3b5562b..6be8be0 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -43,7 +43,7 @@ function! VimuxRunCommandInDir(command, useFile) endfunction function! VimuxRunLastCommand() - if exists('g:VimuxRunnerIndex') + if exists('g:VimuxLastCommand') call VimuxRunCommand(g:VimuxLastCommand) else echo 'No last vimux command.' From 748b54b885b1af93dcff8892a2d9ffa248fae60e Mon Sep 17 00:00:00 2001 From: Michael van der Kamp Date: Sun, 14 Feb 2021 13:09:52 -0600 Subject: [PATCH 083/138] Define options once at startup This also removes a couple of "getter" functions that were being used to look up options and fall back to their defaults --- plugin/vimux.vim | 89 +++++++++++++++++++++++------------------------- 1 file changed, 42 insertions(+), 47 deletions(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 6be8be0..681ac8f 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -3,20 +3,20 @@ if exists('g:loaded_vimux') || &compatible endif let g:loaded_vimux = 1 -function! s:VimuxOption(option, default) - if exists(a:option) - return eval(a:option) - else - return a:default - endif -endfunction - -function! s:VimuxTmuxCmd() - return s:VimuxOption('g:VimuxTmuxCommand', 'tmux') -endfunction - -if !executable(s:VimuxTmuxCmd()) - echohl ErrorMsg | echomsg 'Failed to find executable '.s:VimuxTmuxCmd() | echohl None +" Set up all global options with defaults right away, in one place +let g:VimuxDebug = get(g:, 'VimuxDebug', v:false) +let g:VimuxHeight = get(g:, 'VimuxHeight', 20) +let g:VimuxOpenExtraArgs = get(g:, 'VimuxOpenExtraArgs', '') +let g:VimuxOrientation = get(g:, 'VimuxOrientation', 'v') +let g:VimuxPromptString = get(g:, 'VimuxPromptString', 'Command? ') +let g:VimuxResetSequence = get(g:, 'VimuxResetSequence', 'q C-u') +let g:VimuxRunnerName = get(g:, 'VimuxRunnerName', '') +let g:VimuxRunnerType = get(g:, 'VimuxRunnerType', 'pane') +let g:VimuxTmuxCommand = get(g:, 'VimuxTmuxCommand', 'tmux') +let g:VimuxUseNearest = get(g:, 'VimuxUseNearest', v:true) + +if !executable(g:VimuxTmuxCommand) + echohl ErrorMsg | echomsg 'Failed to find executable '.g:VimuxTmuxCommand | echohl None finish endif @@ -60,7 +60,7 @@ function! VimuxRunCommand(command, ...) let l:autoreturn = a:1 endif - let resetSequence = s:VimuxOption('g:VimuxResetSequence', 'q C-u') + let resetSequence = g:VimuxResetSequence let g:VimuxLastCommand = a:command call VimuxSendKeys(resetSequence) @@ -86,37 +86,37 @@ endfunction function! VimuxOpenRunner() let nearestIndex = s:VimuxNearestIndex() - if s:VimuxOption('g:VimuxUseNearest', 1) ==# 1 && nearestIndex != -1 + if g:VimuxUseNearest ==# 1 && nearestIndex != -1 let g:VimuxRunnerIndex = nearestIndex else - let extraArguments = s:VimuxOption('g:VimuxOpenExtraArgs', '') - if s:VimuxRunnerType() ==# 'pane' - let height = s:VimuxOption('g:VimuxHeight', 20) - let orientation = s:VimuxOption('g:VimuxOrientation', 'v') + let extraArguments = g:VimuxOpenExtraArgs + if g:VimuxRunnerType ==# 'pane' + let height = g:VimuxHeight + let orientation = g:VimuxOrientation call s:VimuxTmux('split-window -p '.height.' -'.orientation.' '.extraArguments) - elseif s:VimuxRunnerType() ==# 'window' + elseif g:VimuxRunnerType ==# 'window' call s:VimuxTmux('new-window '.extraArguments) endif let g:VimuxRunnerIndex = s:VimuxTmuxIndex() call s:VimuxSetRunnerName() - call s:VimuxTmux('last-'.s:VimuxRunnerType()) + call s:VimuxTmux('last-'.g:VimuxRunnerType) endif endfunction function! VimuxCloseRunner() if exists('g:VimuxRunnerIndex') - call s:VimuxTmux('kill-'.s:VimuxRunnerType().' -t '.g:VimuxRunnerIndex) + call s:VimuxTmux('kill-'.g:VimuxRunnerType.' -t '.g:VimuxRunnerIndex) unlet g:VimuxRunnerIndex endif endfunction function! VimuxTogglePane() if exists('g:VimuxRunnerIndex') - if s:VimuxRunnerType() ==# 'window' - call s:VimuxTmux('join-pane -d -s '.g:VimuxRunnerIndex.' -p '.s:VimuxOption('g:VimuxHeight', 20)) + if g:VimuxRunnerType ==# 'window' + call s:VimuxTmux('join-pane -d -s '.g:VimuxRunnerIndex.' -p '.g:VimuxHeight) let g:VimuxRunnerType = 'pane' - elseif s:VimuxRunnerType() ==# 'pane' + elseif g:VimuxRunnerType ==# 'pane' let g:VimuxRunnerIndex=substitute(s:VimuxTmux('break-pane -d -t '.g:VimuxRunnerIndex." -P -F '#{window_id}'"), '\n', '', '') let g:VimuxRunnerType = 'window' endif @@ -125,28 +125,28 @@ endfunction function! VimuxZoomRunner() if exists('g:VimuxRunnerIndex') - if s:VimuxRunnerType() ==# 'pane' + if g:VimuxRunnerType ==# 'pane' call s:VimuxTmux('resize-pane -Z -t '.g:VimuxRunnerIndex) - elseif s:VimuxRunnerType() ==# 'window' + elseif g:VimuxRunnerType ==# 'window' call s:VimuxTmux('select-window -t '.g:VimuxRunnerIndex) endif endif endfunction function! VimuxInspectRunner() - call s:VimuxTmux('select-'.s:VimuxRunnerType().' -t '.g:VimuxRunnerIndex) + call s:VimuxTmux('select-'.g:VimuxRunnerType.' -t '.g:VimuxRunnerIndex) call s:VimuxTmux('copy-mode') endfunction function! VimuxScrollUpInspect() call VimuxInspectRunner() - call s:VimuxTmux('last-'.s:VimuxRunnerType()) + call s:VimuxTmux('last-'.g:VimuxRunnerType) call VimuxSendKeys('C-u') endfunction function! VimuxScrollDownInspect() call VimuxInspectRunner() - call s:VimuxTmux('last-'.s:VimuxRunnerType()) + call s:VimuxTmux('last-'.g:VimuxRunnerType) call VimuxSendKeys('C-d') endfunction @@ -168,15 +168,15 @@ endfunction function! VimuxPromptCommand(...) let command = a:0 ==# 1 ? a:1 : '' - let l:command = input(s:VimuxOption('g:VimuxPromptString', 'Command? '), command, 'shellcmd') + let l:command = input(g:VimuxPromptString, command, 'shellcmd') call VimuxRunCommand(l:command) endfunction function! s:VimuxTmux(arguments) - if s:VimuxOption('g:VimuxDebug', 0) != 0 - echom s:VimuxTmuxCmd().' '.a:arguments + if g:VimuxDebug + echom g:VimuxTmuxCommand.' '.a:arguments endif - return system(s:VimuxTmuxCmd().' '.a:arguments) + return system(g:VimuxTmuxCommand.' '.a:arguments) endfunction function! s:VimuxTmuxSession() @@ -184,7 +184,7 @@ function! s:VimuxTmuxSession() endfunction function! s:VimuxTmuxIndex() - if s:VimuxRunnerType() ==# 'pane' + if g:VimuxRunnerType ==# 'pane' return s:VimuxTmuxPaneId() else return s:VimuxTmuxWindowId() @@ -200,7 +200,7 @@ function! s:VimuxTmuxWindowId() endfunction function! s:VimuxNearestIndex() - let t = s:VimuxRunnerType() + let t = g:VimuxRunnerType let filter = s:VimuxGetTargetFilter() let views = split(s:VimuxTmux('list-'.t."s -F '#{".t.'_active}:#{'.t."_id}'".filter), '\n') @@ -214,11 +214,11 @@ function! s:VimuxNearestIndex() endfunction function! s:VimuxGetTargetFilter() - let targetName = s:VimuxOption('g:VimuxRunnerName', '') + let targetName = g:VimuxRunnerName if targetName ==# '' return '' endif - let t = s:VimuxRunnerType() + let t = g:VimuxRunnerType if t ==# 'window' return " -f '#{==:#{window_name},".targetName."}'" elseif t ==# 'pane' @@ -227,11 +227,11 @@ function! s:VimuxGetTargetFilter() endfunction function! s:VimuxSetRunnerName() - let targetName = s:VimuxOption('g:VimuxRunnerName', '') + let targetName = g:VimuxRunnerName if targetName ==# '' return endif - let t = s:VimuxRunnerType() + let t = g:VimuxRunnerType if t ==# 'window' call s:VimuxTmux('rename-window '.targetName) elseif t ==# 'pane' @@ -239,16 +239,11 @@ function! s:VimuxSetRunnerName() endif endfunction - -function! s:VimuxRunnerType() - return s:VimuxOption('g:VimuxRunnerType', 'pane') -endfunction - function! s:VimuxTmuxProperty(property) return substitute(s:VimuxTmux("display -p '".a:property."'"), '\n$', '', '') endfunction function! s:VimuxHasRunner(index) - let t = s:VimuxRunnerType() + let t = g:VimuxRunnerType return match(s:VimuxTmux('list-'.t."s -F '#{".t."_id}'"), a:index) endfunction From b13568ea1bfad50a1200a6e9004448620ee1f78f Mon Sep 17 00:00:00 2001 From: Michael van der Kamp Date: Mon, 15 Feb 2021 12:23:54 -0600 Subject: [PATCH 084/138] Support buffer-local variants of options --- plugin/vimux.vim | 68 +++++++++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 32 deletions(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 681ac8f..ca484b5 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -15,8 +15,12 @@ let g:VimuxRunnerType = get(g:, 'VimuxRunnerType', 'pane') let g:VimuxTmuxCommand = get(g:, 'VimuxTmuxCommand', 'tmux') let g:VimuxUseNearest = get(g:, 'VimuxUseNearest', v:true) -if !executable(g:VimuxTmuxCommand) - echohl ErrorMsg | echomsg 'Failed to find executable '.g:VimuxTmuxCommand | echohl None +function! s:VimuxOption(name) abort + return get(b:, a:name, get(g:, a:name)) +endfunction + +if !executable(s:VimuxOption('VimuxTmuxCommand')) + echohl ErrorMsg | echomsg 'Failed to find executable '.s:VimuxOption('VimuxTmuxCommand') | echohl None finish endif @@ -60,7 +64,7 @@ function! VimuxRunCommand(command, ...) let l:autoreturn = a:1 endif - let resetSequence = g:VimuxResetSequence + let resetSequence = s:VimuxOption('VimuxResetSequence') let g:VimuxLastCommand = a:command call VimuxSendKeys(resetSequence) @@ -86,67 +90,67 @@ endfunction function! VimuxOpenRunner() let nearestIndex = s:VimuxNearestIndex() - if g:VimuxUseNearest ==# 1 && nearestIndex != -1 + if s:VimuxOption('VimuxUseNearest') ==# 1 && nearestIndex != -1 let g:VimuxRunnerIndex = nearestIndex else - let extraArguments = g:VimuxOpenExtraArgs - if g:VimuxRunnerType ==# 'pane' - let height = g:VimuxHeight - let orientation = g:VimuxOrientation + let extraArguments = s:VimuxOption('VimuxOpenExtraArgs') + if s:VimuxOption('VimuxRunnerType') ==# 'pane' + let height = s:VimuxOption('VimuxHeight') + let orientation = s:VimuxOption('VimuxOrientation') call s:VimuxTmux('split-window -p '.height.' -'.orientation.' '.extraArguments) - elseif g:VimuxRunnerType ==# 'window' + elseif s:VimuxOption('VimuxRunnerType') ==# 'window' call s:VimuxTmux('new-window '.extraArguments) endif let g:VimuxRunnerIndex = s:VimuxTmuxIndex() call s:VimuxSetRunnerName() - call s:VimuxTmux('last-'.g:VimuxRunnerType) + call s:VimuxTmux('last-'.s:VimuxOption('VimuxRunnerType')) endif endfunction function! VimuxCloseRunner() if exists('g:VimuxRunnerIndex') - call s:VimuxTmux('kill-'.g:VimuxRunnerType.' -t '.g:VimuxRunnerIndex) + call s:VimuxTmux('kill-'.s:VimuxOption('VimuxRunnerType').' -t '.g:VimuxRunnerIndex) unlet g:VimuxRunnerIndex endif endfunction function! VimuxTogglePane() if exists('g:VimuxRunnerIndex') - if g:VimuxRunnerType ==# 'window' - call s:VimuxTmux('join-pane -d -s '.g:VimuxRunnerIndex.' -p '.g:VimuxHeight) - let g:VimuxRunnerType = 'pane' - elseif g:VimuxRunnerType ==# 'pane' + if s:VimuxOption('VimuxRunnerType') ==# 'window' + call s:VimuxTmux('join-pane -d -s '.g:VimuxRunnerIndex.' -p '.s:VimuxOption('VimuxHeight')) + let s:VimuxOption('VimuxRunnerType') = 'pane' + elseif s:VimuxOption('VimuxRunnerType') ==# 'pane' let g:VimuxRunnerIndex=substitute(s:VimuxTmux('break-pane -d -t '.g:VimuxRunnerIndex." -P -F '#{window_id}'"), '\n', '', '') - let g:VimuxRunnerType = 'window' + let s:VimuxOption('VimuxRunnerType') = 'window' endif endif endfunction function! VimuxZoomRunner() if exists('g:VimuxRunnerIndex') - if g:VimuxRunnerType ==# 'pane' + if s:VimuxOption('VimuxRunnerType') ==# 'pane' call s:VimuxTmux('resize-pane -Z -t '.g:VimuxRunnerIndex) - elseif g:VimuxRunnerType ==# 'window' + elseif s:VimuxOption('VimuxRunnerType') ==# 'window' call s:VimuxTmux('select-window -t '.g:VimuxRunnerIndex) endif endif endfunction function! VimuxInspectRunner() - call s:VimuxTmux('select-'.g:VimuxRunnerType.' -t '.g:VimuxRunnerIndex) + call s:VimuxTmux('select-'.s:VimuxOption('VimuxRunnerType').' -t '.g:VimuxRunnerIndex) call s:VimuxTmux('copy-mode') endfunction function! VimuxScrollUpInspect() call VimuxInspectRunner() - call s:VimuxTmux('last-'.g:VimuxRunnerType) + call s:VimuxTmux('last-'.s:VimuxOption('VimuxRunnerType')) call VimuxSendKeys('C-u') endfunction function! VimuxScrollDownInspect() call VimuxInspectRunner() - call s:VimuxTmux('last-'.g:VimuxRunnerType) + call s:VimuxTmux('last-'.s:VimuxOption('VimuxRunnerType')) call VimuxSendKeys('C-d') endfunction @@ -168,15 +172,15 @@ endfunction function! VimuxPromptCommand(...) let command = a:0 ==# 1 ? a:1 : '' - let l:command = input(g:VimuxPromptString, command, 'shellcmd') + let l:command = input(s:VimuxOption('VimuxPromptString'), command, 'shellcmd') call VimuxRunCommand(l:command) endfunction function! s:VimuxTmux(arguments) - if g:VimuxDebug - echom g:VimuxTmuxCommand.' '.a:arguments + if s:VimuxOption('VimuxDebug') + echom s:VimuxOption('VimuxTmuxCommand').' '.a:arguments endif - return system(g:VimuxTmuxCommand.' '.a:arguments) + return system(s:VimuxOption('VimuxTmuxCommand').' '.a:arguments) endfunction function! s:VimuxTmuxSession() @@ -184,7 +188,7 @@ function! s:VimuxTmuxSession() endfunction function! s:VimuxTmuxIndex() - if g:VimuxRunnerType ==# 'pane' + if s:VimuxOption('VimuxRunnerType') ==# 'pane' return s:VimuxTmuxPaneId() else return s:VimuxTmuxWindowId() @@ -200,7 +204,7 @@ function! s:VimuxTmuxWindowId() endfunction function! s:VimuxNearestIndex() - let t = g:VimuxRunnerType + let t = s:VimuxOption('VimuxRunnerType') let filter = s:VimuxGetTargetFilter() let views = split(s:VimuxTmux('list-'.t."s -F '#{".t.'_active}:#{'.t."_id}'".filter), '\n') @@ -214,11 +218,11 @@ function! s:VimuxNearestIndex() endfunction function! s:VimuxGetTargetFilter() - let targetName = g:VimuxRunnerName + let targetName = s:VimuxOption('VimuxRunnerName') if targetName ==# '' return '' endif - let t = g:VimuxRunnerType + let t = s:VimuxOption('VimuxRunnerType') if t ==# 'window' return " -f '#{==:#{window_name},".targetName."}'" elseif t ==# 'pane' @@ -227,11 +231,11 @@ function! s:VimuxGetTargetFilter() endfunction function! s:VimuxSetRunnerName() - let targetName = g:VimuxRunnerName + let targetName = s:VimuxOption('VimuxRunnerName') if targetName ==# '' return endif - let t = g:VimuxRunnerType + let t = s:VimuxOption('VimuxRunnerType') if t ==# 'window' call s:VimuxTmux('rename-window '.targetName) elseif t ==# 'pane' @@ -244,6 +248,6 @@ function! s:VimuxTmuxProperty(property) endfunction function! s:VimuxHasRunner(index) - let t = g:VimuxRunnerType + let t = s:VimuxOption('VimuxRunnerType') return match(s:VimuxTmux('list-'.t."s -F '#{".t."_id}'"), a:index) endfunction From 601749152e0a504e1d8edffc74d0f094017acce7 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 16 Feb 2021 12:28:47 +0300 Subject: [PATCH 085/138] feat: Make s:VimuxOption (was _VimuxOption) public VimuxOption --- plugin/vimux.vim | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 6be8be0..83e72c6 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -3,7 +3,7 @@ if exists('g:loaded_vimux') || &compatible endif let g:loaded_vimux = 1 -function! s:VimuxOption(option, default) +function! VimuxOption(option, default) if exists(a:option) return eval(a:option) else @@ -12,7 +12,7 @@ function! s:VimuxOption(option, default) endfunction function! s:VimuxTmuxCmd() - return s:VimuxOption('g:VimuxTmuxCommand', 'tmux') + return VimuxOption('g:VimuxTmuxCommand', 'tmux') endfunction if !executable(s:VimuxTmuxCmd()) @@ -60,7 +60,7 @@ function! VimuxRunCommand(command, ...) let l:autoreturn = a:1 endif - let resetSequence = s:VimuxOption('g:VimuxResetSequence', 'q C-u') + let resetSequence = VimuxOption('g:VimuxResetSequence', 'q C-u') let g:VimuxLastCommand = a:command call VimuxSendKeys(resetSequence) @@ -86,13 +86,13 @@ endfunction function! VimuxOpenRunner() let nearestIndex = s:VimuxNearestIndex() - if s:VimuxOption('g:VimuxUseNearest', 1) ==# 1 && nearestIndex != -1 + if VimuxOption('g:VimuxUseNearest', 1) ==# 1 && nearestIndex != -1 let g:VimuxRunnerIndex = nearestIndex else - let extraArguments = s:VimuxOption('g:VimuxOpenExtraArgs', '') + let extraArguments = VimuxOption('g:VimuxOpenExtraArgs', '') if s:VimuxRunnerType() ==# 'pane' - let height = s:VimuxOption('g:VimuxHeight', 20) - let orientation = s:VimuxOption('g:VimuxOrientation', 'v') + let height = VimuxOption('g:VimuxHeight', 20) + let orientation = VimuxOption('g:VimuxOrientation', 'v') call s:VimuxTmux('split-window -p '.height.' -'.orientation.' '.extraArguments) elseif s:VimuxRunnerType() ==# 'window' call s:VimuxTmux('new-window '.extraArguments) @@ -114,7 +114,7 @@ endfunction function! VimuxTogglePane() if exists('g:VimuxRunnerIndex') if s:VimuxRunnerType() ==# 'window' - call s:VimuxTmux('join-pane -d -s '.g:VimuxRunnerIndex.' -p '.s:VimuxOption('g:VimuxHeight', 20)) + call s:VimuxTmux('join-pane -d -s '.g:VimuxRunnerIndex.' -p '.VimuxOption('g:VimuxHeight', 20)) let g:VimuxRunnerType = 'pane' elseif s:VimuxRunnerType() ==# 'pane' let g:VimuxRunnerIndex=substitute(s:VimuxTmux('break-pane -d -t '.g:VimuxRunnerIndex." -P -F '#{window_id}'"), '\n', '', '') @@ -168,12 +168,12 @@ endfunction function! VimuxPromptCommand(...) let command = a:0 ==# 1 ? a:1 : '' - let l:command = input(s:VimuxOption('g:VimuxPromptString', 'Command? '), command, 'shellcmd') + let l:command = input(VimuxOption('g:VimuxPromptString', 'Command? '), command, 'shellcmd') call VimuxRunCommand(l:command) endfunction function! s:VimuxTmux(arguments) - if s:VimuxOption('g:VimuxDebug', 0) != 0 + if VimuxOption('g:VimuxDebug', 0) != 0 echom s:VimuxTmuxCmd().' '.a:arguments endif return system(s:VimuxTmuxCmd().' '.a:arguments) @@ -214,7 +214,7 @@ function! s:VimuxNearestIndex() endfunction function! s:VimuxGetTargetFilter() - let targetName = s:VimuxOption('g:VimuxRunnerName', '') + let targetName = VimuxOption('g:VimuxRunnerName', '') if targetName ==# '' return '' endif @@ -227,7 +227,7 @@ function! s:VimuxGetTargetFilter() endfunction function! s:VimuxSetRunnerName() - let targetName = s:VimuxOption('g:VimuxRunnerName', '') + let targetName = VimuxOption('g:VimuxRunnerName', '') if targetName ==# '' return endif @@ -241,7 +241,7 @@ endfunction function! s:VimuxRunnerType() - return s:VimuxOption('g:VimuxRunnerType', 'pane') + return VimuxOption('g:VimuxRunnerType', 'pane') endfunction function! s:VimuxTmuxProperty(property) From 43681e9f91293d48bf32a107a8df445d5aac6a60 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 16 Feb 2021 12:38:31 +0300 Subject: [PATCH 086/138] refactor: Simplify script-local private function names --- plugin/vimux.vim | 112 +++++++++++++++++++++++------------------------ 1 file changed, 56 insertions(+), 56 deletions(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 83e72c6..0e4cac4 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -11,12 +11,12 @@ function! VimuxOption(option, default) endif endfunction -function! s:VimuxTmuxCmd() +function! s:tmuxCmd() return VimuxOption('g:VimuxTmuxCommand', 'tmux') endfunction -if !executable(s:VimuxTmuxCmd()) - echohl ErrorMsg | echomsg 'Failed to find executable '.s:VimuxTmuxCmd() | echohl None +if !executable(s:tmuxCmd()) + echohl ErrorMsg | echomsg 'Failed to find executable '.s:tmuxCmd() | echohl None finish endif @@ -51,7 +51,7 @@ function! VimuxRunLastCommand() endfunction function! VimuxRunCommand(command, ...) - if !exists('g:VimuxRunnerIndex') || s:VimuxHasRunner(g:VimuxRunnerIndex) ==# -1 + if !exists('g:VimuxRunnerIndex') || s:hasRunner(g:VimuxRunnerIndex) ==# -1 call VimuxOpenRunner() endif @@ -77,47 +77,47 @@ endfunction function! VimuxSendKeys(keys) if exists('g:VimuxRunnerIndex') - call s:VimuxTmux('send-keys -t '.g:VimuxRunnerIndex.' '.a:keys) + call s:tmux('send-keys -t '.g:VimuxRunnerIndex.' '.a:keys) else echo 'No vimux runner pane/window. Create one with VimuxOpenRunner' endif endfunction function! VimuxOpenRunner() - let nearestIndex = s:VimuxNearestIndex() + let nearestIndex = s:nearestIndex() if VimuxOption('g:VimuxUseNearest', 1) ==# 1 && nearestIndex != -1 let g:VimuxRunnerIndex = nearestIndex else let extraArguments = VimuxOption('g:VimuxOpenExtraArgs', '') - if s:VimuxRunnerType() ==# 'pane' + if s:runnerType() ==# 'pane' let height = VimuxOption('g:VimuxHeight', 20) let orientation = VimuxOption('g:VimuxOrientation', 'v') - call s:VimuxTmux('split-window -p '.height.' -'.orientation.' '.extraArguments) - elseif s:VimuxRunnerType() ==# 'window' - call s:VimuxTmux('new-window '.extraArguments) + call s:tmux('split-window -p '.height.' -'.orientation.' '.extraArguments) + elseif s:runnerType() ==# 'window' + call s:tmux('new-window '.extraArguments) endif - let g:VimuxRunnerIndex = s:VimuxTmuxIndex() - call s:VimuxSetRunnerName() - call s:VimuxTmux('last-'.s:VimuxRunnerType()) + let g:VimuxRunnerIndex = s:tmuxIndex() + call s:setRunnerName() + call s:tmux('last-'.s:runnerType()) endif endfunction function! VimuxCloseRunner() if exists('g:VimuxRunnerIndex') - call s:VimuxTmux('kill-'.s:VimuxRunnerType().' -t '.g:VimuxRunnerIndex) + call s:tmux('kill-'.s:runnerType().' -t '.g:VimuxRunnerIndex) unlet g:VimuxRunnerIndex endif endfunction function! VimuxTogglePane() if exists('g:VimuxRunnerIndex') - if s:VimuxRunnerType() ==# 'window' - call s:VimuxTmux('join-pane -d -s '.g:VimuxRunnerIndex.' -p '.VimuxOption('g:VimuxHeight', 20)) + if s:runnerType() ==# 'window' + call s:tmux('join-pane -d -s '.g:VimuxRunnerIndex.' -p '.VimuxOption('g:VimuxHeight', 20)) let g:VimuxRunnerType = 'pane' - elseif s:VimuxRunnerType() ==# 'pane' - let g:VimuxRunnerIndex=substitute(s:VimuxTmux('break-pane -d -t '.g:VimuxRunnerIndex." -P -F '#{window_id}'"), '\n', '', '') + elseif s:runnerType() ==# 'pane' + let g:VimuxRunnerIndex=substitute(s:tmux('break-pane -d -t '.g:VimuxRunnerIndex." -P -F '#{window_id}'"), '\n', '', '') let g:VimuxRunnerType = 'window' endif endif @@ -125,28 +125,28 @@ endfunction function! VimuxZoomRunner() if exists('g:VimuxRunnerIndex') - if s:VimuxRunnerType() ==# 'pane' - call s:VimuxTmux('resize-pane -Z -t '.g:VimuxRunnerIndex) - elseif s:VimuxRunnerType() ==# 'window' - call s:VimuxTmux('select-window -t '.g:VimuxRunnerIndex) + if s:runnerType() ==# 'pane' + call s:tmux('resize-pane -Z -t '.g:VimuxRunnerIndex) + elseif s:runnerType() ==# 'window' + call s:tmux('select-window -t '.g:VimuxRunnerIndex) endif endif endfunction function! VimuxInspectRunner() - call s:VimuxTmux('select-'.s:VimuxRunnerType().' -t '.g:VimuxRunnerIndex) - call s:VimuxTmux('copy-mode') + call s:tmux('select-'.s:runnerType().' -t '.g:VimuxRunnerIndex) + call s:tmux('copy-mode') endfunction function! VimuxScrollUpInspect() call VimuxInspectRunner() - call s:VimuxTmux('last-'.s:VimuxRunnerType()) + call s:tmux('last-'.s:runnerType()) call VimuxSendKeys('C-u') endfunction function! VimuxScrollDownInspect() call VimuxInspectRunner() - call s:VimuxTmux('last-'.s:VimuxRunnerType()) + call s:tmux('last-'.s:runnerType()) call VimuxSendKeys('C-d') endfunction @@ -162,7 +162,7 @@ endfunction function! VimuxClearRunnerHistory() if exists('g:VimuxRunnerIndex') - call s:VimuxTmux('clear-history -t '.g:VimuxRunnerIndex) + call s:tmux('clear-history -t '.g:VimuxRunnerIndex) endif endfunction @@ -172,37 +172,37 @@ function! VimuxPromptCommand(...) call VimuxRunCommand(l:command) endfunction -function! s:VimuxTmux(arguments) +function! s:tmux(arguments) if VimuxOption('g:VimuxDebug', 0) != 0 - echom s:VimuxTmuxCmd().' '.a:arguments + echom s:tmuxCmd().' '.a:arguments endif - return system(s:VimuxTmuxCmd().' '.a:arguments) + return system(s:tmuxCmd().' '.a:arguments) endfunction -function! s:VimuxTmuxSession() - return s:VimuxTmuxProperty('#S') +function! s:tmuxSession() + return s:tmuxProperty('#S') endfunction -function! s:VimuxTmuxIndex() - if s:VimuxRunnerType() ==# 'pane' - return s:VimuxTmuxPaneId() +function! s:tmuxIndex() + if s:runnerType() ==# 'pane' + return s:tmuxPaneId() else - return s:VimuxTmuxWindowId() + return s:tmuxWindowId() end endfunction -function! s:VimuxTmuxPaneId() - return s:VimuxTmuxProperty('#{pane_id}') +function! s:tmuxPaneId() + return s:tmuxProperty('#{pane_id}') endfunction -function! s:VimuxTmuxWindowId() - return s:VimuxTmuxProperty('#{window_id}') +function! s:tmuxWindowId() + return s:tmuxProperty('#{window_id}') endfunction -function! s:VimuxNearestIndex() - let t = s:VimuxRunnerType() - let filter = s:VimuxGetTargetFilter() - let views = split(s:VimuxTmux('list-'.t."s -F '#{".t.'_active}:#{'.t."_id}'".filter), '\n') +function! s:nearestIndex() + let t = s:runnerType() + let filter = s:getTargetFilter() + let views = split(s:tmux('list-'.t."s -F '#{".t.'_active}:#{'.t."_id}'".filter), '\n') for view in views if match(view, '1:') ==# -1 @@ -213,12 +213,12 @@ function! s:VimuxNearestIndex() return -1 endfunction -function! s:VimuxGetTargetFilter() +function! s:getTargetFilter() let targetName = VimuxOption('g:VimuxRunnerName', '') if targetName ==# '' return '' endif - let t = s:VimuxRunnerType() + let t = s:runnerType() if t ==# 'window' return " -f '#{==:#{window_name},".targetName."}'" elseif t ==# 'pane' @@ -226,29 +226,29 @@ function! s:VimuxGetTargetFilter() endif endfunction -function! s:VimuxSetRunnerName() +function! s:setRunnerName() let targetName = VimuxOption('g:VimuxRunnerName', '') if targetName ==# '' return endif - let t = s:VimuxRunnerType() + let t = s:runnerType() if t ==# 'window' - call s:VimuxTmux('rename-window '.targetName) + call s:tmux('rename-window '.targetName) elseif t ==# 'pane' - call s:VimuxTmux('select-pane -T '.targetName) + call s:tmux('select-pane -T '.targetName) endif endfunction -function! s:VimuxRunnerType() +function! s:runnerType() return VimuxOption('g:VimuxRunnerType', 'pane') endfunction -function! s:VimuxTmuxProperty(property) - return substitute(s:VimuxTmux("display -p '".a:property."'"), '\n$', '', '') +function! s:tmuxProperty(property) + return substitute(s:tmux("display -p '".a:property."'"), '\n$', '', '') endfunction -function! s:VimuxHasRunner(index) - let t = s:VimuxRunnerType() - return match(s:VimuxTmux('list-'.t."s -F '#{".t."_id}'"), a:index) +function! s:hasRunner(index) + let t = s:runnerType() + return match(s:tmux('list-'.t."s -F '#{".t."_id}'"), a:index) endfunction From 566833e291784aaeba70f6dfcb32a9f192231420 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 16 Feb 2021 12:40:53 +0300 Subject: [PATCH 087/138] style: Format each function as a paragraph with no blanks --- plugin/vimux.vim | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 0e4cac4..c37cb0a 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -54,18 +54,14 @@ function! VimuxRunCommand(command, ...) if !exists('g:VimuxRunnerIndex') || s:hasRunner(g:VimuxRunnerIndex) ==# -1 call VimuxOpenRunner() endif - let l:autoreturn = 1 if exists('a:1') let l:autoreturn = a:1 endif - let resetSequence = VimuxOption('g:VimuxResetSequence', 'q C-u') let g:VimuxLastCommand = a:command - call VimuxSendKeys(resetSequence) call VimuxSendText(a:command) - if l:autoreturn ==# 1 call VimuxSendKeys('Enter') endif @@ -85,7 +81,6 @@ endfunction function! VimuxOpenRunner() let nearestIndex = s:nearestIndex() - if VimuxOption('g:VimuxUseNearest', 1) ==# 1 && nearestIndex != -1 let g:VimuxRunnerIndex = nearestIndex else @@ -97,7 +92,6 @@ function! VimuxOpenRunner() elseif s:runnerType() ==# 'window' call s:tmux('new-window '.extraArguments) endif - let g:VimuxRunnerIndex = s:tmuxIndex() call s:setRunnerName() call s:tmux('last-'.s:runnerType()) @@ -203,13 +197,11 @@ function! s:nearestIndex() let t = s:runnerType() let filter = s:getTargetFilter() let views = split(s:tmux('list-'.t."s -F '#{".t.'_active}:#{'.t."_id}'".filter), '\n') - for view in views if match(view, '1:') ==# -1 return split(view, ':')[1] endif endfor - return -1 endfunction @@ -229,7 +221,7 @@ endfunction function! s:setRunnerName() let targetName = VimuxOption('g:VimuxRunnerName', '') if targetName ==# '' - return + return endif let t = s:runnerType() if t ==# 'window' @@ -239,7 +231,6 @@ function! s:setRunnerName() endif endfunction - function! s:runnerType() return VimuxOption('g:VimuxRunnerType', 'pane') endfunction From 992d525ef9fa16ff4a40438b4210b0bf179edfc0 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 16 Feb 2021 13:43:24 +0300 Subject: [PATCH 088/138] feat: Make s:tmuxExec (was _VimuxTmux) public VimuxTmux --- plugin/vimux.vim | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index c37cb0a..704d301 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -73,7 +73,7 @@ endfunction function! VimuxSendKeys(keys) if exists('g:VimuxRunnerIndex') - call s:tmux('send-keys -t '.g:VimuxRunnerIndex.' '.a:keys) + call VimuxTmux('send-keys -t '.g:VimuxRunnerIndex.' '.a:keys) else echo 'No vimux runner pane/window. Create one with VimuxOpenRunner' endif @@ -88,19 +88,19 @@ function! VimuxOpenRunner() if s:runnerType() ==# 'pane' let height = VimuxOption('g:VimuxHeight', 20) let orientation = VimuxOption('g:VimuxOrientation', 'v') - call s:tmux('split-window -p '.height.' -'.orientation.' '.extraArguments) + call VimuxTmux('split-window -p '.height.' -'.orientation.' '.extraArguments) elseif s:runnerType() ==# 'window' - call s:tmux('new-window '.extraArguments) + call VimuxTmux('new-window '.extraArguments) endif let g:VimuxRunnerIndex = s:tmuxIndex() call s:setRunnerName() - call s:tmux('last-'.s:runnerType()) + call VimuxTmux('last-'.s:runnerType()) endif endfunction function! VimuxCloseRunner() if exists('g:VimuxRunnerIndex') - call s:tmux('kill-'.s:runnerType().' -t '.g:VimuxRunnerIndex) + call VimuxTmux('kill-'.s:runnerType().' -t '.g:VimuxRunnerIndex) unlet g:VimuxRunnerIndex endif endfunction @@ -108,10 +108,10 @@ endfunction function! VimuxTogglePane() if exists('g:VimuxRunnerIndex') if s:runnerType() ==# 'window' - call s:tmux('join-pane -d -s '.g:VimuxRunnerIndex.' -p '.VimuxOption('g:VimuxHeight', 20)) + call VimuxTmux('join-pane -d -s '.g:VimuxRunnerIndex.' -p '.VimuxOption('g:VimuxHeight', 20)) let g:VimuxRunnerType = 'pane' elseif s:runnerType() ==# 'pane' - let g:VimuxRunnerIndex=substitute(s:tmux('break-pane -d -t '.g:VimuxRunnerIndex." -P -F '#{window_id}'"), '\n', '', '') + let g:VimuxRunnerIndex=substitute(VimuxTmux('break-pane -d -t '.g:VimuxRunnerIndex." -P -F '#{window_id}'"), '\n', '', '') let g:VimuxRunnerType = 'window' endif endif @@ -120,27 +120,27 @@ endfunction function! VimuxZoomRunner() if exists('g:VimuxRunnerIndex') if s:runnerType() ==# 'pane' - call s:tmux('resize-pane -Z -t '.g:VimuxRunnerIndex) + call VimuxTmux('resize-pane -Z -t '.g:VimuxRunnerIndex) elseif s:runnerType() ==# 'window' - call s:tmux('select-window -t '.g:VimuxRunnerIndex) + call VimuxTmux('select-window -t '.g:VimuxRunnerIndex) endif endif endfunction function! VimuxInspectRunner() - call s:tmux('select-'.s:runnerType().' -t '.g:VimuxRunnerIndex) - call s:tmux('copy-mode') + call VimuxTmux('select-'.s:runnerType().' -t '.g:VimuxRunnerIndex) + call VimuxTmux('copy-mode') endfunction function! VimuxScrollUpInspect() call VimuxInspectRunner() - call s:tmux('last-'.s:runnerType()) + call VimuxTmux('last-'.s:runnerType()) call VimuxSendKeys('C-u') endfunction function! VimuxScrollDownInspect() call VimuxInspectRunner() - call s:tmux('last-'.s:runnerType()) + call VimuxTmux('last-'.s:runnerType()) call VimuxSendKeys('C-d') endfunction @@ -156,7 +156,7 @@ endfunction function! VimuxClearRunnerHistory() if exists('g:VimuxRunnerIndex') - call s:tmux('clear-history -t '.g:VimuxRunnerIndex) + call VimuxTmux('clear-history -t '.g:VimuxRunnerIndex) endif endfunction @@ -166,7 +166,7 @@ function! VimuxPromptCommand(...) call VimuxRunCommand(l:command) endfunction -function! s:tmux(arguments) +function! VimuxTmux(arguments) if VimuxOption('g:VimuxDebug', 0) != 0 echom s:tmuxCmd().' '.a:arguments endif @@ -196,7 +196,7 @@ endfunction function! s:nearestIndex() let t = s:runnerType() let filter = s:getTargetFilter() - let views = split(s:tmux('list-'.t."s -F '#{".t.'_active}:#{'.t."_id}'".filter), '\n') + let views = split(VimuxTmux('list-'.t."s -F '#{".t.'_active}:#{'.t."_id}'".filter), '\n') for view in views if match(view, '1:') ==# -1 return split(view, ':')[1] @@ -225,9 +225,9 @@ function! s:setRunnerName() endif let t = s:runnerType() if t ==# 'window' - call s:tmux('rename-window '.targetName) + call VimuxTmux('rename-window '.targetName) elseif t ==# 'pane' - call s:tmux('select-pane -T '.targetName) + call VimuxTmux('select-pane -T '.targetName) endif endfunction @@ -236,10 +236,10 @@ function! s:runnerType() endfunction function! s:tmuxProperty(property) - return substitute(s:tmux("display -p '".a:property."'"), '\n$', '', '') + return substitute(VimuxTmux("display -p '".a:property."'"), '\n$', '', '') endfunction function! s:hasRunner(index) let t = s:runnerType() - return match(s:tmux('list-'.t."s -F '#{".t."_id}'"), a:index) + return match(VimuxTmux('list-'.t."s -F '#{".t."_id}'"), a:index) endfunction From f4df4c9b5b5208ea0a78513cdf843b9d891a2ce0 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 16 Feb 2021 16:51:49 +0300 Subject: [PATCH 089/138] docs: Note settings may be buffer-local --- doc/vimux.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/vimux.txt b/doc/vimux.txt index 0cfb413..0770a33 100644 --- a/doc/vimux.txt +++ b/doc/vimux.txt @@ -287,7 +287,9 @@ extra return. Thanks to @trptcolin for discovering this issue. ============================================================================== CONFIGURATION (4) *VimuxConfiguration* -You can configure Vimux like this: +You can configure Vimux as follows. Note that all occurances of global +variables `g:Vimux...` may also be set using buffer variables `b:Vimux...` to +change the behavior of Vimux in just the current buffer. ------------------------------------------------------------------------------ *VimuxConfiguration_height* From cac9d11158088e455b4f720a4e60a276acd73aed Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Thu, 18 Feb 2021 07:40:56 +0300 Subject: [PATCH 090/138] docs: Update dead link and copy edit readme to avoid 1st person --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 636a2fa..bf5e45c 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,11 @@ ![vimux](https://www.braintreepayments.com/blog/content/images/blog/vimux3.png) -What inspired me to write vimux was [tslime.vim](https://github.com/kikijump/tslime.vim), a plugin that lets you send input to tmux. While tslime.vim works well, I felt it wasn't optimized for my primary use case which was having a smaller tmux pane that I would use to run tests or play with a REPL. +Vimux was originally inspired by [tslime.vim](https://github.com/jgdavey/tslime.vim/network), a plugin that lets you send input to tmux. While tslime.vim works well, it wasn't optimized for the use case of having a smaller tmux pane used to run tests or play with a REPL. The goal of Vimux is to make interacting with tmux from vim effortless. -My goal with vimux is to make interacting with tmux from vim effortless. By default when you call `VimuxRunCommand` vimux will create a 20% tall horizontal pane under your current tmux pane and execute a command in it without losing focus of vim. Once that pane exists whenever you call `VimuxRunCommand` again the command will be executed in that pane. As I was using vimux myself I wanted to rerun commands over and over. An example of this was running the current file through rspec. Rather than typing that over and over I wrote `VimuxRunLastCommand` that will execute the last command you called with `VimuxRunCommand`. +By default, when you call `VimuxRunCommand` vimux will create a 20% tall horizontal pane under your current tmux pane and execute a command in it without losing the focus on vim. Once that pane exists, whenever you call `VimuxRunCommand` again the command will be executed in that pane. A frequent use case is wanting to rerun commands over and over. An example of this is running the current file through rspec. Rather than typing that over and over `VimuxRunLastCommand` will execute the last command called with `VimuxRunCommand`. -Other auxiliary functions and the ones I talked about above can be found below with a full description and example key binds for your vimrc. +Other auxiliary functions and the ones talked about above can be found below with full descriptions and example key bindings for your vimrc. ## Installation From f1c27deeaab23ddf05ee71e78dbd7d31ff296697 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Thu, 18 Feb 2021 07:47:28 +0300 Subject: [PATCH 091/138] docs: Promote usage links in readme and remove help doc specific copy --- README.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index bf5e45c..fc4e516 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,6 @@ Vimux was originally inspired by [tslime.vim](https://github.com/jgdavey/tslime. By default, when you call `VimuxRunCommand` vimux will create a 20% tall horizontal pane under your current tmux pane and execute a command in it without losing the focus on vim. Once that pane exists, whenever you call `VimuxRunCommand` again the command will be executed in that pane. A frequent use case is wanting to rerun commands over and over. An example of this is running the current file through rspec. Rather than typing that over and over `VimuxRunLastCommand` will execute the last command called with `VimuxRunCommand`. -Other auxiliary functions and the ones talked about above can be found below with full descriptions and example key bindings for your vimrc. - ## Installation With **[vim-bundle](https://github.com/preservim/vim-bundle)**: `vim-bundle install preservim/vimux` @@ -19,7 +17,11 @@ Otherwise download the latest [tarball](https://github.com/preservim/vimux/tarba _Notes:_ -* Vimux assumes a tmux version >= 1.5. Some older versions might work but it is recommended to use at least version 1.5. +* Vimux assumes a reasonably new version of tmux. Some older versions might work but it is recommended to use the latest stable release. + +## Usage + +The full documentation is available [online](https://raw.github.com/preservim/vimux/master/doc/vimux.txt) and accessible inside vim via `:help vimux` ## Platform-specific Plugins @@ -35,7 +37,3 @@ _Notes:_ * [vimux-cargo](https://github.com/jtdowney/vimux-cargo) run rust tests and projects using cargo and vimux * [vimux-bazel-test](https://github.com/pgr0ss/vimux-bazel-test) Run bazel tests in vimux * [vimux-jest-test](https://github.com/tyewang/vimux-jest-test) Run jest tests in vimux - -## Usage - -The full documentation is available [online](https://raw.github.com/preservim/vimux/master/doc/vimux.txt) and accessible inside vim `:help vimux` From f293536dd5956e47776a8f6594f55e7206d5871b Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Thu, 18 Feb 2021 07:48:50 +0300 Subject: [PATCH 092/138] docus: Copy edit help docs with fresh link and to remove 1st person --- doc/vimux.txt | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/doc/vimux.txt b/doc/vimux.txt index 0770a33..dff0dcd 100644 --- a/doc/vimux.txt +++ b/doc/vimux.txt @@ -28,25 +28,24 @@ ABOUT (1) *VimuxAbout* Vimux -- Easily interact with tmux from vim. -What inspired me to write vimux was tslime.vim [1], a plugin that lets you -send input to tmux. While tslime.vim works well, I felt it wasn't optimized -for my primary use case which was having a smaller tmux pane that I would use -to run tests or play with a REPL. +Vimux was originally inspired by tslime.vim [1], a plugin that lets you send +input to tmux. While tslime.vim works well, it wasn't optimized for the use +case of having a smaller tmux pane used to run tests or play with a REPL. The +goal of Vimux is to make interacting with tmux from vim effortless. -My goal with vimux is to make interacting with tmux from vim effortless. By -default when you call `VimuxRunCommand` vimux will create a 20% tall +By default, when you call `VimuxRunCommand` vimux will create a 20% tall horizontal pane under your current tmux pane and execute a command in it -without losing focus of vim. Once that pane exists whenever you call -`VimuxRunCommand` again the command will be executed in that pane. As I was -using vimux myself I wanted to rerun commands over and over. An example of -this was running the current file through rspec. Rather than typing that over -and over I wrote `VimuxRunLastCommand` that will execute the last command -you called with `VimuxRunCommand`. +without losing the focus on vim. Once that pane exists, whenever you call +`VimuxRunCommand` again the command will be executed in that pane. A frequent +use case is wanting to rerun commands over and over. An example of this is +running the current file through rspec. Rather than typing that over and over +`VimuxRunLastCommand` will execute the last command called with +`VimuxRunCommand`. -Other auxiliary functions and the ones I talked about above can be found -bellow with a full description and example key binds for your vimrc. +Other auxiliary functions and the ones talked about above can be found bellow +with full descriptions and example key bindings for your vimrc. -[1] https://github.com/kikijump/tslime.vim +[1] https://github.com/jgdavey/tslime.vim/network ============================================================================== From 9214bf95784d330fe7e076e26aee9e3048f99253 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Thu, 18 Feb 2021 08:34:30 +0300 Subject: [PATCH 093/138] Split PR review from branch check workflows --- .github/workflows/reviewdog.yml | 13 +++++++++++++ .github/workflows/vint.yml | 20 ++++++++++---------- 2 files changed, 23 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/reviewdog.yml diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml new file mode 100644 index 0000000..421e438 --- /dev/null +++ b/.github/workflows/reviewdog.yml @@ -0,0 +1,13 @@ +name: Reviewdog +on: [pull_request] +jobs: + vint: + name: vint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: vint + uses: reviewdog/action-vint@v1 + with: + github_token: ${{ secrets.github_token }} + reporter: github-pr-review diff --git a/.github/workflows/vint.yml b/.github/workflows/vint.yml index 36d7258..909de43 100644 --- a/.github/workflows/vint.yml +++ b/.github/workflows/vint.yml @@ -1,15 +1,15 @@ name: Vint -on: [push, pull_request] +on: [push] jobs: vint: - strategy: - fail-fast: false + name: vint runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@master - - name: Run vint with reviewdog - uses: reviewdog/action-vint@v1.0.1 - with: - github_token: ${{ secrets.github_token }} - reporter: github-pr-review + - name: Checkout + uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + - name: Setup dependencies + run: pip install vim-vint + - name: Lint Vimscript + run: vint . From 1b38911c40d2111d4e9a2506f9f8d0f30aa6c8e6 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Thu, 18 Feb 2021 23:28:33 +0300 Subject: [PATCH 094/138] Disallow chaining VimuxRunCommand and VimuxPromptCommand Fixes #185 Vim does not allow escaping some characters in commands that can be chained. In particular bars are disallowed and double quotes begin code comments. Both of these things are regular features in shell command strings. I'm disallowing chaining for the two commands that take shell commands as arguments so they can be used sensibly again. One solution to allow this might be to have a ...Bar version of each. It might also be possible to work around this with `:call` and functions instead of commands. --- plugin/vimux.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 1cf6d3c..20da10c 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -24,7 +24,7 @@ if !executable(VimuxOption('VimuxTmuxCommand')) finish endif -command -bar -nargs=* VimuxRunCommand :call VimuxRunCommand() +command -nargs=* VimuxRunCommand :call VimuxRunCommand() command -bar VimuxRunLastCommand :call VimuxRunLastCommand() command -bar VimuxOpenRunner :call VimuxOpenRunner() command -bar VimuxCloseRunner :call VimuxCloseRunner() @@ -33,7 +33,7 @@ command -bar VimuxInspectRunner :call VimuxInspectRunner() command -bar VimuxScrollUpInspect :call VimuxScrollUpInspect() command -bar VimuxScrollDownInspect :call VimuxScrollDownInspect() command -bar VimuxInterruptRunner :call VimuxInterruptRunner() -command -bar -nargs=? VimuxPromptCommand :call VimuxPromptCommand() +command -nargs=? VimuxPromptCommand :call VimuxPromptCommand() command -bar VimuxClearTerminalScreen :call VimuxClearTerminalScreen() command -bar VimuxClearRunnerHistory :call VimuxClearRunnerHistory() command -bar VimuxTogglePane :call VimuxTogglePane() From fb43fcbc16ed97c9eafe29f78895e70d27cf636b Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Fri, 19 Feb 2021 00:18:11 +0300 Subject: [PATCH 095/138] Add CI workflow to actually test-drive Vimux --- .github/workflows/check.yml | 38 +++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/check.yml diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 0000000..fe586b6 --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,38 @@ +name: Check +on: [push, pull_request] +jobs: + check: + strategy: + fail-fast: false + matrix: + vimFlavor: ["vim", "nvim"] + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Enable Universe package repository + run: | + sudo add-apt-repository universe + sudo apt-get update + - name: Install tmux and ${{ matrix.tagsProvider }} + run: | + sudo apt-get install tmux ${{ matrix.vimFlavor == 'nvim' && 'neovim' || 'vim' }} + - name: Review versions + run: | + tmux -V + ${{ matrix.vimFlavor }} --version + # This tests looks for two thigs: + # * That VIM doesn't hang. If it succedes it will quit quickly. If 5 + # seconds later the tmux session is still running either the runner pane + # didn't get closed or (more likely) we threw some error and VIM is + # sitting there expecting us to acknowledge the message(s). + # * That VIM exited normally. This check isn't very useful since :qa + # never bubbles up an error, but if someday we use :cq for a test being + # ready to check the exit code seems like a good thing. + - name: "Try Vimux" + run: | + ec="$(mktemp)" + tmux new -s ci -d "${{ matrix.vimFlavor == 'nvim' && 'nvim -u /dev/null --headless' || 'vim' }} -i NONE \"+so plugin/vimux.vim\" \"+VimuxRunCommand('date')\" \"+VimuxCloseRunner | qa\"; echo \$? > '$ec'" + sleep 5 + tmux kill-session -t ci && exit 1 + exit "$(cat $ec)" From f02fa9c1615cd7ef6381177abb9925a794ac9845 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Fri, 19 Feb 2021 00:19:07 +0300 Subject: [PATCH 096/138] Add CI badge for tmux + vim/nvim + vimux check --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index fc4e516..e20e037 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # Vimux: easily interact with tmux from vim [![Vint](https://github.com/preservim/vimux/workflows/Vint/badge.svg)](https://github.com/preservim/vimux/actions?workflow=Vint) +[![Check](https://github.com/preservim/vimux/workflows/Check/badge.svg)](https://github.com/preservim/vimux/actions?workflow=Check) ![vimux](https://www.braintreepayments.com/blog/content/images/blog/vimux3.png) From 3bfe0ea285031f40f1a1e8e00f57a933eb8a8325 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Fri, 19 Feb 2021 12:51:20 +0300 Subject: [PATCH 097/138] Fix CI test step name --- .github/workflows/check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index fe586b6..5aa994c 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -14,7 +14,7 @@ jobs: run: | sudo add-apt-repository universe sudo apt-get update - - name: Install tmux and ${{ matrix.tagsProvider }} + - name: Install tmux and ${{ matrix.vimFlavor }} run: | sudo apt-get install tmux ${{ matrix.vimFlavor == 'nvim' && 'neovim' || 'vim' }} - name: Review versions From 5b1791673c1a089a78be16187f7532f95e50580b Mon Sep 17 00:00:00 2001 From: Gerhard Hellmann Date: Tue, 23 Feb 2021 13:35:38 +0100 Subject: [PATCH 098/138] Add option to expand VimuxPromptCommand arguments (#166) Co-authored-by: Gerhard Siegesmund --- doc/vimux.txt | 16 ++++++++++++++++ plugin/vimux.vim | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/doc/vimux.txt b/doc/vimux.txt index dff0dcd..509b123 100644 --- a/doc/vimux.txt +++ b/doc/vimux.txt @@ -400,5 +400,21 @@ you're using panes or windows, and your version of tmux. Default: "tmux" +------------------------------------------------------------------------------ + VimuxExpandCommand +4.10 g:VimuxExpandCommand~ + +Should the command given at the prompt via VimuxPromptCommand be expanded +using expand(). 1 to expand the string. + +Unfortunately expand() only expands % (etc.) if the string starts with that +character. So the command is split at spaces and then rejoined after +expansion. With this simple approach things like "%:h/test.xml" are not +possible. + + let g:VimuxExpandCommand = 1 + +Default: 0 + ============================================================================== vim:tw=78:ts=2:sw=2:expandtab:ft=help:norl: diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 20da10c..bd1f247 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -14,6 +14,7 @@ let g:VimuxRunnerName = get(g:, 'VimuxRunnerName', '') let g:VimuxRunnerType = get(g:, 'VimuxRunnerType', 'pane') let g:VimuxTmuxCommand = get(g:, 'VimuxTmuxCommand', 'tmux') let g:VimuxUseNearest = get(g:, 'VimuxUseNearest', v:true) +let g:VimuxExpandCommand = get(g:, 'VimuxExpandCommand', v:false) function! VimuxOption(name) abort return get(b:, a:name, get(g:, a:name)) @@ -167,6 +168,9 @@ endfunction function! VimuxPromptCommand(...) let command = a:0 ==# 1 ? a:1 : '' let l:command = input(VimuxOption('VimuxPromptString'), command, 'shellcmd') + if VimuxOption('VimuxExpandCommand') + let l:command = join(map(split(l:command, ' '), 'expand(v:val)'), ' ') + endif call VimuxRunCommand(l:command) endfunction From 54d24d169417b89672419dc925ec9e7e3e702028 Mon Sep 17 00:00:00 2001 From: Michael van der Kamp Date: Sun, 7 Mar 2021 17:44:17 -0600 Subject: [PATCH 099/138] Add an option to autoclose the runner --- plugin/vimux.vim | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index bd1f247..23c94f3 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -15,6 +15,7 @@ let g:VimuxRunnerType = get(g:, 'VimuxRunnerType', 'pane') let g:VimuxTmuxCommand = get(g:, 'VimuxTmuxCommand', 'tmux') let g:VimuxUseNearest = get(g:, 'VimuxUseNearest', v:true) let g:VimuxExpandCommand = get(g:, 'VimuxExpandCommand', v:false) +let g:VimuxCloseOnExit = get(g:, 'VimuxCloseOnExit', v:false) function! VimuxOption(name) abort return get(b:, a:name, get(g:, a:name)) @@ -39,6 +40,13 @@ command -bar VimuxClearTerminalScreen :call VimuxClearTerminalScreen() command -bar VimuxClearRunnerHistory :call VimuxClearRunnerHistory() command -bar VimuxTogglePane :call VimuxTogglePane() +if VimuxOption('VimuxCloseOnExit') + augroup VimuxAutocloseCommands + au! + autocmd VimLeave * call VimuxCloseRunner() + augroup END +endif + function! VimuxRunCommandInDir(command, useFile) let l:file = '' if a:useFile ==# 1 From c4adf57f6ec68b41e1d116655f676dea3dfd0700 Mon Sep 17 00:00:00 2001 From: Michael van der Kamp Date: Sun, 7 Mar 2021 17:58:20 -0600 Subject: [PATCH 100/138] Add documentation for g:VimuxCloseOnExit --- doc/vimux.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/doc/vimux.txt b/doc/vimux.txt index 509b123..fda9664 100644 --- a/doc/vimux.txt +++ b/doc/vimux.txt @@ -416,5 +416,16 @@ possible. Default: 0 +------------------------------------------------------------------------------ + *VimuxCloseOnExit* +4.11 g:VimuxCloseOnExit~ + +Set this option to 1 or v:true to tell vimux to close the runner when you quit +vim. + + let g:VimuxCloseOnExit = 1 + +Default: 0 + ============================================================================== vim:tw=78:ts=2:sw=2:expandtab:ft=help:norl: From 7d977a295412ea93fce693a6fa4f5af1e20e0a5e Mon Sep 17 00:00:00 2001 From: Michael van der Kamp Date: Sun, 7 Mar 2021 18:17:53 -0600 Subject: [PATCH 101/138] Documentation touchups --- doc/vimux.txt | 62 +++++++++++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/doc/vimux.txt b/doc/vimux.txt index fda9664..b137d67 100644 --- a/doc/vimux.txt +++ b/doc/vimux.txt @@ -94,7 +94,7 @@ vimux from automatically sending a return after the command. VimuxSendText~ Send raw text to the runner pane. This command will not open a new pane if one -does not already exist. You will need to use VimuxOpenRunner to do this. This +does not already exist. You will need to use |VimuxOpenRunner| to do this. This command can be used to interact with REPLs or other interactive terminal programs that are not shells. @@ -104,7 +104,7 @@ programs that are not shells. VimuxSendKeys~ Send keys to the runner pane. This command will not open a new pane if one -does not already exist. You will need to use VimuxOpenRunner to do this. You +does not already exist. You will need to use |VimuxOpenRunner| to do this. You can use this command to send keys such as "Enter" or "C-c" to the runner pane. ------------------------------------------------------------------------------ @@ -113,7 +113,7 @@ VimuxOpenRunner~ This will either open a new pane or use the nearest pane and set it as the vimux runner pane for the other vimux commands. You can control if this command -uses the nearest pane or always creates a new one with g:VimuxUseNearest +uses the nearest pane or always creates a new one with g:|VimuxUseNearest| ------------------------------------------------------------------------------ *VimuxPromptCommand* @@ -295,9 +295,9 @@ change the behavior of Vimux in just the current buffer. 4.1 g:VimuxHeight~ The percent of the screen the split pane Vimux will spawn should take up. - +> let g:VimuxHeight = "40" - +< Default: "20" ------------------------------------------------------------------------------ @@ -307,9 +307,9 @@ Default: "20" The default orientation of the split tmux pane. This tells tmux to make the pane either vertically or horizontally, which is backward from how Vim handles creating splits. - +> let g:VimuxOrientation = "h" - +< Options: "v": vertical "h": horizontal @@ -318,13 +318,13 @@ Default: "v" ------------------------------------------------------------------------------ *VimuxConfiguration_use_nearest* -4.3 g:VimuxUseNearest +4.3 g:VimuxUseNearest~ Use existing pane or window (not used by vim) if found instead of running split-window. - +> let g:VimuxUseNearest = 1 - +< Default: 1 ------------------------------------------------------------------------------ @@ -333,9 +333,9 @@ Default: 1 The keys sent to the runner pane before running a command. By default it sends `q` to make sure the pane is not in scroll-mode and `C-u` to clear the line. - +> let g:VimuxResetSequence = "" - +< Default: "q C-u" ------------------------------------------------------------------------------ @@ -345,9 +345,9 @@ Default: "q C-u" The string presented in the vim command line when Vimux is invoked. Be sure to put a space at the end of the string to allow for distinction between the prompt and your input. - +> let g:VimuxPromptString = "" - +< Default: "Command? " ------------------------------------------------------------------------------ @@ -356,9 +356,9 @@ Default: "Command? " The type of view object Vimux should use for the runner. For reference, a tmux session is a group of windows, and a window is a layout of panes. - +> let g:VimuxRunnerType = "window" - +< Options: "pane": for panes "window": for windows @@ -367,14 +367,16 @@ Default: "pane" ------------------------------------------------------------------------------ *VimuxRunnerName* -4.7 g:VimuxRunnerName +4.7 g:VimuxRunnerName~ Setting the name for the runner. Works for panes and windows. This makes the VimuxRunner reusable between sessions. Caveat is, all your instances (in the -same session/window) use the same window. +same session/window) use the same window. +Caution: It is probably best not to mix this with |VimuxCloseOnExit|. +> let g:VimuxRunnerName = "vimuxout" - +< Default: "" ------------------------------------------------------------------------------ @@ -383,9 +385,9 @@ Default: "" The command that Vimux runs when it calls out to tmux. It may be useful to redefine this if you're using something like tmate. - +> let g:VimuxTmuxCommand = "tmate" - +< Default: "tmux" ------------------------------------------------------------------------------ @@ -395,13 +397,13 @@ Default: "tmux" Allows addtional arguments to be passed to the tmux command that opens the runner. Make sure that the arguments specified are valid depending on whether you're using panes or windows, and your version of tmux. - +> let g:VimuxOpenExtraArgs = "-c #{pane_current_path}" - -Default: "tmux" +< +Default: "" ------------------------------------------------------------------------------ - VimuxExpandCommand + *VimuxExpandCommand* 4.10 g:VimuxExpandCommand~ Should the command given at the prompt via VimuxPromptCommand be expanded @@ -411,20 +413,22 @@ Unfortunately expand() only expands % (etc.) if the string starts with that character. So the command is split at spaces and then rejoined after expansion. With this simple approach things like "%:h/test.xml" are not possible. - +> let g:VimuxExpandCommand = 1 - +< Default: 0 ------------------------------------------------------------------------------ *VimuxCloseOnExit* 4.11 g:VimuxCloseOnExit~ -Set this option to 1 or v:true to tell vimux to close the runner when you quit +Set this option to `1` or `v:true` to tell vimux to close the runner when you quit vim. +Caution: It is probably best not to mix this with |VimuxRunnerName|. +> let g:VimuxCloseOnExit = 1 - +< Default: 0 ============================================================================== From 784b2834c70f2c8c5759a78db7b875cac39c2126 Mon Sep 17 00:00:00 2001 From: jaspertandy Date: Wed, 10 Mar 2021 14:11:59 +0000 Subject: [PATCH 102/138] Preference to allow up-arrow --- plugin/vimux.vim | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 23c94f3..c6cd9c9 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -16,6 +16,7 @@ let g:VimuxTmuxCommand = get(g:, 'VimuxTmuxCommand', 'tmux') let g:VimuxUseNearest = get(g:, 'VimuxUseNearest', v:true) let g:VimuxExpandCommand = get(g:, 'VimuxExpandCommand', v:false) let g:VimuxCloseOnExit = get(g:, 'VimuxCloseOnExit', v:false) +let g:VimuxCommandShell = get(g:, 'VimuxCommandShell', v:true) function! VimuxOption(name) abort return get(b:, a:name, get(g:, a:name)) @@ -175,7 +176,12 @@ endfunction function! VimuxPromptCommand(...) let command = a:0 ==# 1 ? a:1 : '' - let l:command = input(VimuxOption('VimuxPromptString'), command, 'shellcmd') + if VimuxOption('VimuxCommandShell') + let l:cancelreturn = 'shellcmd' + else + let l:cancelreturn = v:false + endif + let l:command = input(VimuxOption('VimuxPromptString'), command, l:cancelreturn) if VimuxOption('VimuxExpandCommand') let l:command = join(map(split(l:command, ' '), 'expand(v:val)'), ' ') endif From 59b1d28f80e7aa78efc08faad030db4d34befd83 Mon Sep 17 00:00:00 2001 From: jaspertandy Date: Wed, 10 Mar 2021 14:16:02 +0000 Subject: [PATCH 103/138] Needs no argument rather than a blank argument --- plugin/vimux.vim | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index c6cd9c9..a269e5c 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -177,11 +177,10 @@ endfunction function! VimuxPromptCommand(...) let command = a:0 ==# 1 ? a:1 : '' if VimuxOption('VimuxCommandShell') - let l:cancelreturn = 'shellcmd' + let l:command = input(VimuxOption('VimuxPromptString'), command, 'shellcmd') else - let l:cancelreturn = v:false + let l:command = input(VimuxOption('VimuxPromptString'), command) endif - let l:command = input(VimuxOption('VimuxPromptString'), command, l:cancelreturn) if VimuxOption('VimuxExpandCommand') let l:command = join(map(split(l:command, ' '), 'expand(v:val)'), ' ') endif From a70218b30ca9a75268698130bca8c4cfd119b20b Mon Sep 17 00:00:00 2001 From: jaspertandy Date: Thu, 18 Mar 2021 13:47:41 +0000 Subject: [PATCH 104/138] Update documentation for g:VimuxCommandShell --- doc/vimux.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/doc/vimux.txt b/doc/vimux.txt index b137d67..f0788ad 100644 --- a/doc/vimux.txt +++ b/doc/vimux.txt @@ -431,5 +431,21 @@ Caution: It is probably best not to mix this with |VimuxRunnerName|. < Default: 0 +------------------------------------------------------------------------------ + *VimuxCommandShell* +4.12 g:VimuxCommandShell~ + +Set this option to `1` or `v:true` to enable shell completion in +VimuxPromptCommand +Set this option to `0` or `v:false` to enable vim command editing in +VimuxPromptCommand + +Enabling shell completion blocks the ability to use up-arrow to cycle through +previously-run commands in VimuxPromptCommand. +> + let g:VimuxCommandShell = 0 +< +Default: 1 + ============================================================================== vim:tw=78:ts=2:sw=2:expandtab:ft=help:norl: From 96a47f789531580931799a5962f6b1d247eb40ee Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 10 Apr 2021 09:36:03 +0300 Subject: [PATCH 105/138] ci: Test on older Ubuntu flavor (has tmux 2.x) --- .github/workflows/check.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 5aa994c..4445370 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -5,8 +5,9 @@ jobs: strategy: fail-fast: false matrix: + ubuntuFlavor: ["18.04", "20.04"] vimFlavor: ["vim", "nvim"] - runs-on: ubuntu-20.04 + runs-on: ubuntu-${{ matrix.ubuntuFlavor }} steps: - name: Checkout uses: actions/checkout@v2 From ee3075ad30560ffba20c695124c60faef97ec4a4 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 10 Apr 2021 10:25:36 +0300 Subject: [PATCH 106/138] ci: Test on unreleased NeoVIM development builds (#193) --- .github/workflows/check.yml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 4445370..2ce79b3 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -5,23 +5,27 @@ jobs: strategy: fail-fast: false matrix: - ubuntuFlavor: ["18.04", "20.04"] - vimFlavor: ["vim", "nvim"] - runs-on: ubuntu-${{ matrix.ubuntuFlavor }} + osFlavor: [ubuntu-20.04, ubuntu-18.04] + vimFlavor: [neovim, vim] + vimVersion: [stable, unstable] + exclude: + - vimFlavor: vim + vimVersion: unstable + runs-on: ${{ matrix.osFlavor }} steps: - name: Checkout uses: actions/checkout@v2 - name: Enable Universe package repository run: | - sudo add-apt-repository universe + sudo add-apt-repository ${{ matrix.vimVersion == 'stable' && 'universe' || 'ppa:neovim-ppa/unstable' }} sudo apt-get update - name: Install tmux and ${{ matrix.vimFlavor }} run: | - sudo apt-get install tmux ${{ matrix.vimFlavor == 'nvim' && 'neovim' || 'vim' }} + sudo apt-get install tmux ${{ matrix.vimFlavor }} - name: Review versions run: | tmux -V - ${{ matrix.vimFlavor }} --version + ${{ matrix.vimFlavor == 'neovim' && 'nvim' || 'vim' }} --version # This tests looks for two thigs: # * That VIM doesn't hang. If it succedes it will quit quickly. If 5 # seconds later the tmux session is still running either the runner pane @@ -33,7 +37,7 @@ jobs: - name: "Try Vimux" run: | ec="$(mktemp)" - tmux new -s ci -d "${{ matrix.vimFlavor == 'nvim' && 'nvim -u /dev/null --headless' || 'vim' }} -i NONE \"+so plugin/vimux.vim\" \"+VimuxRunCommand('date')\" \"+VimuxCloseRunner | qa\"; echo \$? > '$ec'" + tmux new -s ci -d "${{ matrix.vimFlavor == 'neovim' && 'nvim -u /dev/null --headless' || 'vim' }} -i NONE \"+so plugin/vimux.vim\" \"+VimuxRunCommand('date')\" \"+VimuxCloseRunner | qa\"; echo \$? > '$ec'" sleep 5 tmux kill-session -t ci && exit 1 exit "$(cat $ec)" From ee0dfae33062419f2c9ef6a202b3ce415adf6e6a Mon Sep 17 00:00:00 2001 From: John Bredall <33331177+jbredall@users.noreply.github.com> Date: Thu, 29 Apr 2021 15:18:42 -0400 Subject: [PATCH 107/138] Fix VimuxTogglePane (#195) --- plugin/vimux.vim | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index a269e5c..4fcd4ed 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -122,11 +122,13 @@ endfunction function! VimuxTogglePane() if exists('g:VimuxRunnerIndex') if VimuxOption('VimuxRunnerType') ==# 'window' - call VimuxTmux('join-pane -d -s '.g:VimuxRunnerIndex.' -p '.VimuxOption('VimuxHeight')) - let VimuxOption('VimuxRunnerType') = 'pane' + call VimuxTmux('join-pane -s '.g:VimuxRunnerIndex.' -p '.VimuxOption('VimuxHeight')) + let g:VimuxRunnerType = 'pane' + let g:VimuxRunnerIndex = s:tmuxIndex() + call VimuxTmux('last-'.VimuxOption('VimuxRunnerType')) elseif VimuxOption('VimuxRunnerType') ==# 'pane' - let g:VimuxRunnerIndex=substitute(VimuxTmux('break-pane -d -t '.g:VimuxRunnerIndex." -P -F '#{window_id}'"), '\n', '', '') - let VimuxOption('VimuxRunnerType') = 'window' + let g:VimuxRunnerIndex=substitute(VimuxTmux('break-pane -d -s '.g:VimuxRunnerIndex." -P -F '#{window_id}'"), '\n', '', '') + let g:VimuxRunnerType = 'window' endif endif endfunction From a1650d5f9bc2d617bb546bb8014a206e41089dc8 Mon Sep 17 00:00:00 2001 From: Michael van der Kamp <40647401+mvanderkamp@users.noreply.github.com> Date: Tue, 25 May 2021 01:10:22 -0600 Subject: [PATCH 108/138] Use abort for all function declarations (#196) See: `:help func-abort` `:help except-compat` --- plugin/vimux.vim | 52 ++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 4fcd4ed..00cacf7 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -48,7 +48,7 @@ if VimuxOption('VimuxCloseOnExit') augroup END endif -function! VimuxRunCommandInDir(command, useFile) +function! VimuxRunCommandInDir(command, useFile) abort let l:file = '' if a:useFile ==# 1 let l:file = shellescape(expand('%:t'), 1) @@ -56,7 +56,7 @@ function! VimuxRunCommandInDir(command, useFile) call VimuxRunCommand('(cd '.shellescape(expand('%:p:h'), 1).' && '.a:command.' '.l:file.')') endfunction -function! VimuxRunLastCommand() +function! VimuxRunLastCommand() abort if exists('g:VimuxLastCommand') call VimuxRunCommand(g:VimuxLastCommand) else @@ -64,7 +64,7 @@ function! VimuxRunLastCommand() endif endfunction -function! VimuxRunCommand(command, ...) +function! VimuxRunCommand(command, ...) abort if !exists('g:VimuxRunnerIndex') || s:hasRunner(g:VimuxRunnerIndex) ==# -1 call VimuxOpenRunner() endif @@ -81,11 +81,11 @@ function! VimuxRunCommand(command, ...) endif endfunction -function! VimuxSendText(text) +function! VimuxSendText(text) abort call VimuxSendKeys(shellescape(substitute(a:text, '\n$', ' ', ''))) endfunction -function! VimuxSendKeys(keys) +function! VimuxSendKeys(keys) abort if exists('g:VimuxRunnerIndex') call VimuxTmux('send-keys -t '.g:VimuxRunnerIndex.' '.a:keys) else @@ -93,7 +93,7 @@ function! VimuxSendKeys(keys) endif endfunction -function! VimuxOpenRunner() +function! VimuxOpenRunner() abort let nearestIndex = s:nearestIndex() if VimuxOption('VimuxUseNearest') ==# 1 && nearestIndex != -1 let g:VimuxRunnerIndex = nearestIndex @@ -112,14 +112,14 @@ function! VimuxOpenRunner() endif endfunction -function! VimuxCloseRunner() +function! VimuxCloseRunner() abort if exists('g:VimuxRunnerIndex') call VimuxTmux('kill-'.VimuxOption('VimuxRunnerType').' -t '.g:VimuxRunnerIndex) unlet g:VimuxRunnerIndex endif endfunction -function! VimuxTogglePane() +function! VimuxTogglePane() abort if exists('g:VimuxRunnerIndex') if VimuxOption('VimuxRunnerType') ==# 'window' call VimuxTmux('join-pane -s '.g:VimuxRunnerIndex.' -p '.VimuxOption('VimuxHeight')) @@ -133,7 +133,7 @@ function! VimuxTogglePane() endif endfunction -function! VimuxZoomRunner() +function! VimuxZoomRunner() abort if exists('g:VimuxRunnerIndex') if VimuxOption('VimuxRunnerType') ==# 'pane' call VimuxTmux('resize-pane -Z -t '.g:VimuxRunnerIndex) @@ -143,40 +143,40 @@ function! VimuxZoomRunner() endif endfunction -function! VimuxInspectRunner() +function! VimuxInspectRunner() abort call VimuxTmux('select-'.VimuxOption('VimuxRunnerType').' -t '.g:VimuxRunnerIndex) call VimuxTmux('copy-mode') endfunction -function! VimuxScrollUpInspect() +function! VimuxScrollUpInspect() abort call VimuxInspectRunner() call VimuxTmux('last-'.VimuxOption('VimuxRunnerType')) call VimuxSendKeys('C-u') endfunction -function! VimuxScrollDownInspect() +function! VimuxScrollDownInspect() abort call VimuxInspectRunner() call VimuxTmux('last-'.VimuxOption('VimuxRunnerType')) call VimuxSendKeys('C-d') endfunction -function! VimuxInterruptRunner() +function! VimuxInterruptRunner() abort call VimuxSendKeys('^c') endfunction -function! VimuxClearTerminalScreen() +function! VimuxClearTerminalScreen() abort if exists('g:VimuxRunnerIndex') call VimuxSendKeys('C-l') endif endfunction -function! VimuxClearRunnerHistory() +function! VimuxClearRunnerHistory() abort if exists('g:VimuxRunnerIndex') call VimuxTmux('clear-history -t '.g:VimuxRunnerIndex) endif endfunction -function! VimuxPromptCommand(...) +function! VimuxPromptCommand(...) abort let command = a:0 ==# 1 ? a:1 : '' if VimuxOption('VimuxCommandShell') let l:command = input(VimuxOption('VimuxPromptString'), command, 'shellcmd') @@ -189,18 +189,18 @@ function! VimuxPromptCommand(...) call VimuxRunCommand(l:command) endfunction -function! VimuxTmux(arguments) +function! VimuxTmux(arguments) abort if VimuxOption('VimuxDebug') echom VimuxOption('VimuxTmuxCommand').' '.a:arguments endif return system(VimuxOption('VimuxTmuxCommand').' '.a:arguments) endfunction -function! s:tmuxSession() +function! s:tmuxSession() abort return s:tmuxProperty('#S') endfunction -function! s:tmuxIndex() +function! s:tmuxIndex() abort if VimuxOption('VimuxRunnerType') ==# 'pane' return s:tmuxPaneId() else @@ -208,15 +208,15 @@ function! s:tmuxIndex() end endfunction -function! s:tmuxPaneId() +function! s:tmuxPaneId() abort return s:tmuxProperty('#{pane_id}') endfunction -function! s:tmuxWindowId() +function! s:tmuxWindowId() abort return s:tmuxProperty('#{window_id}') endfunction -function! s:nearestIndex() +function! s:nearestIndex() abort let t = VimuxOption('VimuxRunnerType') let filter = s:getTargetFilter() let views = split(VimuxTmux('list-'.t."s -F '#{".t.'_active}:#{'.t."_id}'".filter), '\n') @@ -228,7 +228,7 @@ function! s:nearestIndex() return -1 endfunction -function! s:getTargetFilter() +function! s:getTargetFilter() abort let targetName = VimuxOption('VimuxRunnerName') if targetName ==# '' return '' @@ -241,7 +241,7 @@ function! s:getTargetFilter() endif endfunction -function! s:setRunnerName() +function! s:setRunnerName() abort let targetName = VimuxOption('VimuxRunnerName') if targetName ==# '' return @@ -254,11 +254,11 @@ function! s:setRunnerName() endif endfunction -function! s:tmuxProperty(property) +function! s:tmuxProperty(property) abort return substitute(VimuxTmux("display -p '".a:property."'"), '\n$', '', '') endfunction -function! s:hasRunner(index) +function! s:hasRunner(index) abort let t = VimuxOption('VimuxRunnerType') return match(VimuxTmux('list-'.t."s -F '#{".t."_id}'"), a:index) endfunction From 55a470dc0d3ab45e0b2659773f11a5083d2465d2 Mon Sep 17 00:00:00 2001 From: Michael van der Kamp Date: Sat, 24 Jul 2021 12:34:25 -0600 Subject: [PATCH 109/138] Use same height and orientation arguments for opening and toggling panes --- plugin/vimux.vim | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 00cacf7..f3a66c7 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -100,9 +100,7 @@ function! VimuxOpenRunner() abort else let extraArguments = VimuxOption('VimuxOpenExtraArgs') if VimuxOption('VimuxRunnerType') ==# 'pane' - let height = VimuxOption('VimuxHeight') - let orientation = VimuxOption('VimuxOrientation') - call VimuxTmux('split-window -p '.height.' -'.orientation.' '.extraArguments) + call VimuxTmux('split-window '.s:vimuxPaneOptions().' '.extraArguments) elseif VimuxOption('VimuxRunnerType') ==# 'window' call VimuxTmux('new-window '.extraArguments) endif @@ -122,7 +120,7 @@ endfunction function! VimuxTogglePane() abort if exists('g:VimuxRunnerIndex') if VimuxOption('VimuxRunnerType') ==# 'window' - call VimuxTmux('join-pane -s '.g:VimuxRunnerIndex.' -p '.VimuxOption('VimuxHeight')) + call VimuxTmux('join-pane -s '.g:VimuxRunnerIndex.' '.s:vimuxPaneOptions()) let g:VimuxRunnerType = 'pane' let g:VimuxRunnerIndex = s:tmuxIndex() call VimuxTmux('last-'.VimuxOption('VimuxRunnerType')) @@ -216,6 +214,12 @@ function! s:tmuxWindowId() abort return s:tmuxProperty('#{window_id}') endfunction +function! s:vimuxPaneOptions() abort + let height = VimuxOption('VimuxHeight') + let orientation = VimuxOption('VimuxOrientation') + return '-p '.height.' -'.orientation +endfunction + function! s:nearestIndex() abort let t = VimuxOption('VimuxRunnerType') let filter = s:getTargetFilter() From 853646aef3004954f4cad0b828aaa3d93cc56a3c Mon Sep 17 00:00:00 2001 From: Samuel Walladge Date: Tue, 10 Aug 2021 17:41:34 +0930 Subject: [PATCH 110/138] Abort with an error if run outside tmux session (#204) Otherwise, the command sent will run in a different and likely unexpected tmux session. --- plugin/vimux.vim | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 00cacf7..8b41754 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -193,7 +193,11 @@ function! VimuxTmux(arguments) abort if VimuxOption('VimuxDebug') echom VimuxOption('VimuxTmuxCommand').' '.a:arguments endif - return system(VimuxOption('VimuxTmuxCommand').' '.a:arguments) + if has_key(environ(), 'TMUX') + return system(VimuxOption('VimuxTmuxCommand').' '.a:arguments) + else + throw 'Aborting, because not inside tmux session.' + endif endfunction function! s:tmuxSession() abort From 028897b6fb4882ded8f1ec6b27774e2ff2f6ce56 Mon Sep 17 00:00:00 2001 From: Michael van der Kamp Date: Sat, 5 Jun 2021 17:45:04 -0600 Subject: [PATCH 111/138] Allow resetting the VimuxCloseOnExit option Instead of paying attention to the value when starting up, check the option's value at close. --- plugin/vimux.vim | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index e237a17..0737d74 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -41,12 +41,10 @@ command -bar VimuxClearTerminalScreen :call VimuxClearTerminalScreen() command -bar VimuxClearRunnerHistory :call VimuxClearRunnerHistory() command -bar VimuxTogglePane :call VimuxTogglePane() -if VimuxOption('VimuxCloseOnExit') - augroup VimuxAutocloseCommands - au! - autocmd VimLeave * call VimuxCloseRunner() - augroup END -endif +augroup VimuxAutocmds + au! + autocmd VimLeave * call s:autoclose() +augroup END function! VimuxRunCommandInDir(command, useFile) abort let l:file = '' @@ -270,3 +268,9 @@ function! s:hasRunner(index) abort let t = VimuxOption('VimuxRunnerType') return match(VimuxTmux('list-'.t."s -F '#{".t."_id}'"), a:index) endfunction + +function! s:autoclose() abort + if VimuxOption('VimuxCloseOnExit') + call VimuxCloseRunner() + endif +endfunction From 3daa0e91f018c53fcbcfe6554244c2845c41c649 Mon Sep 17 00:00:00 2001 From: Michael van der Kamp <40647401+mvanderkamp@users.noreply.github.com> Date: Sat, 3 Sep 2022 04:38:25 -0700 Subject: [PATCH 112/138] Support tmux's target-pane and target-window syntax for finding an existing runner (#210) --- doc/vimux.txt | 22 +++++++++++++++ plugin/vimux.vim | 70 +++++++++++++++++++++++++++++++++++++----------- 2 files changed, 76 insertions(+), 16 deletions(-) diff --git a/doc/vimux.txt b/doc/vimux.txt index f0788ad..8ab6ad3 100644 --- a/doc/vimux.txt +++ b/doc/vimux.txt @@ -447,5 +447,27 @@ previously-run commands in VimuxPromptCommand. < Default: 1 +------------------------------------------------------------------------------ + *VimuxRunnerQuery* +4.13 g:VimuxRunnerQuery~ + +Set this option to define a query to use for looking up an existing runner +pane or window when initiating Vimux. Uses the tmux syntax for the target-pane +and target-window command arguments. (See the man page for tmux). It must be a +dictionary containing up to two keys, "pane" and "window", defining the query +to use for the respective runner types. + +If no key exists for the current runner type, the search for an existing +runner falls back to the `VimuxUseNearest` option (and the related +`VimuxRunnerName`). If that option is false or either command fails, a new +runner is created instead, positioned according to `VimuxOrientation`. +> + let g:VimuxRunnerQuery = { + \ 'pane': '{down-of}', + \ 'window': 'vimux', + \} +< +Default: {} + ============================================================================== vim:tw=78:ts=2:sw=2:expandtab:ft=help:norl: diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 0737d74..982ec61 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -92,9 +92,9 @@ function! VimuxSendKeys(keys) abort endfunction function! VimuxOpenRunner() abort - let nearestIndex = s:nearestIndex() - if VimuxOption('VimuxUseNearest') ==# 1 && nearestIndex != -1 - let g:VimuxRunnerIndex = nearestIndex + let existingId = s:existingRunnerId() + if existingId !=# '' + let g:VimuxRunnerIndex = existingId else let extraArguments = VimuxOption('VimuxOpenExtraArgs') if VimuxOption('VimuxRunnerType') ==# 'pane' @@ -123,7 +123,12 @@ function! VimuxTogglePane() abort let g:VimuxRunnerIndex = s:tmuxIndex() call VimuxTmux('last-'.VimuxOption('VimuxRunnerType')) elseif VimuxOption('VimuxRunnerType') ==# 'pane' - let g:VimuxRunnerIndex=substitute(VimuxTmux('break-pane -d -s '.g:VimuxRunnerIndex." -P -F '#{window_id}'"), '\n', '', '') + let g:VimuxRunnerIndex=substitute( + \ VimuxTmux('break-pane -d -s '.g:VimuxRunnerIndex." -P -F '#{window_id}'"), + \ '\n', + \ '', + \ '' + \) let g:VimuxRunnerType = 'window' endif endif @@ -222,16 +227,49 @@ function! s:vimuxPaneOptions() abort return '-p '.height.' -'.orientation endfunction -function! s:nearestIndex() abort - let t = VimuxOption('VimuxRunnerType') +"" +" @return a string of the form '%4', the ID of the pane or window to use, +" or '' if no nearest pane or window is found. +function! s:existingRunnerId() abort + let runnerType = VimuxOption('VimuxRunnerType') + let query = get(VimuxOption('VimuxRunnerQuery'), runnerType, '') + if empty(query) + if !empty(VimuxOption('VimuxUseNearest')) + return s:nearestRunnerId() + endif + endif + " Try finding the runner using the provided query + let message = VimuxTmux('select-'.runnerType.' -t '.query.'') + if message ==# '' + " Success! + let runnerId = s:tmuxIndex() + call VimuxTmux('last-'.runnerType) + return runnerId + endif + return '' +endfunction + +function! s:nearestRunnerId() abort + " Try finding the runner in the current window/session, optionally using a + " name/title filter + let runnerType = VimuxOption('VimuxRunnerType') let filter = s:getTargetFilter() - let views = split(VimuxTmux('list-'.t."s -F '#{".t.'_active}:#{'.t."_id}'".filter), '\n') + " list-panes -F '#{pane_active}:#{pane_id}' -f '#{==:#{pane_title}, " foo}' + " select-pane -t:.'{last}' + let views = split( + \ VimuxTmux( + \ 'list-'.runnerType.'s' + \ ." -F '#{".runnerType.'_active}:#{'.runnerType."_id}'" + \ .filter), + \ '\n') + " '1:' is the current active pane (the one with vim). + " Find the first non-active pane. for view in views if match(view, '1:') ==# -1 return split(view, ':')[1] endif endfor - return -1 + return '' endfunction function! s:getTargetFilter() abort @@ -239,10 +277,10 @@ function! s:getTargetFilter() abort if targetName ==# '' return '' endif - let t = VimuxOption('VimuxRunnerType') - if t ==# 'window' + let runnerType = VimuxOption('VimuxRunnerType') + if runnerType ==# 'window' return " -f '#{==:#{window_name},".targetName."}'" - elseif t ==# 'pane' + elseif runnerType ==# 'pane' return " -f '#{==:#{pane_title},".targetName."}'" endif endfunction @@ -252,10 +290,10 @@ function! s:setRunnerName() abort if targetName ==# '' return endif - let t = VimuxOption('VimuxRunnerType') - if t ==# 'window' + let runnerType = VimuxOption('VimuxRunnerType') + if runnerType ==# 'window' call VimuxTmux('rename-window '.targetName) - elseif t ==# 'pane' + elseif runnerType ==# 'pane' call VimuxTmux('select-pane -T '.targetName) endif endfunction @@ -265,8 +303,8 @@ function! s:tmuxProperty(property) abort endfunction function! s:hasRunner(index) abort - let t = VimuxOption('VimuxRunnerType') - return match(VimuxTmux('list-'.t."s -F '#{".t."_id}'"), a:index) + let runnerType = VimuxOption('VimuxRunnerType') + return match(VimuxTmux('list-'.runnerType."s -F '#{".runnerType."_id}'"), a:index) endfunction function! s:autoclose() abort From 740320b798106c5de6758fb35bf39e79ee1ce0f0 Mon Sep 17 00:00:00 2001 From: Michael van der Kamp <40647401+mvanderkamp@users.noreply.github.com> Date: Sat, 3 Sep 2022 13:14:04 -0700 Subject: [PATCH 113/138] Address #212 (#213) --- plugin/vimux.vim | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 982ec61..04d1884 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -12,6 +12,7 @@ let g:VimuxPromptString = get(g:, 'VimuxPromptString', 'Command? ') let g:VimuxResetSequence = get(g:, 'VimuxResetSequence', 'q C-u') let g:VimuxRunnerName = get(g:, 'VimuxRunnerName', '') let g:VimuxRunnerType = get(g:, 'VimuxRunnerType', 'pane') +let g:VimuxRunnerQuery = get(g:, 'VimuxRunnerQuery', {}) let g:VimuxTmuxCommand = get(g:, 'VimuxTmuxCommand', 'tmux') let g:VimuxUseNearest = get(g:, 'VimuxUseNearest', v:true) let g:VimuxExpandCommand = get(g:, 'VimuxExpandCommand', v:false) @@ -254,8 +255,6 @@ function! s:nearestRunnerId() abort " name/title filter let runnerType = VimuxOption('VimuxRunnerType') let filter = s:getTargetFilter() - " list-panes -F '#{pane_active}:#{pane_id}' -f '#{==:#{pane_title}, " foo}' - " select-pane -t:.'{last}' let views = split( \ VimuxTmux( \ 'list-'.runnerType.'s' From 076e13b77cede04cf697a44cb5e91c816e87d409 Mon Sep 17 00:00:00 2001 From: Michael van der Kamp Date: Sat, 17 Sep 2022 10:21:05 -0700 Subject: [PATCH 114/138] Directly return empty string when not using existing runner - This should have been happening anyway due to a later conditional, but may not if tmux changed its behaviour. --- plugin/vimux.vim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 04d1884..324681a 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -235,7 +235,9 @@ function! s:existingRunnerId() abort let runnerType = VimuxOption('VimuxRunnerType') let query = get(VimuxOption('VimuxRunnerQuery'), runnerType, '') if empty(query) - if !empty(VimuxOption('VimuxUseNearest')) + if empty(VimuxOption('VimuxUseNearest')) + return '' + else return s:nearestRunnerId() endif endif From 2344b96fed6350832b7b2534cb28eb837fbfcaa0 Mon Sep 17 00:00:00 2001 From: Michael van der Kamp Date: Sat, 17 Sep 2022 10:23:56 -0700 Subject: [PATCH 115/138] Add a guard against queries matching current pane --- plugin/vimux.vim | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 324681a..9d0076e 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -242,12 +242,17 @@ function! s:existingRunnerId() abort endif endif " Try finding the runner using the provided query + let currentId = s:tmuxIndex() let message = VimuxTmux('select-'.runnerType.' -t '.query.'') if message ==# '' - " Success! + " A match was found. Make sure it isn't the current vim pane/window + " though! let runnerId = s:tmuxIndex() - call VimuxTmux('last-'.runnerType) - return runnerId + if runnerId !=# currentId + " Success! + call VimuxTmux('last-'.runnerType) + return runnerId + endif endif return '' endfunction From c08a2663d2a94e0cc911c91fa8f0e6b743f5b533 Mon Sep 17 00:00:00 2001 From: Michael van der Kamp Date: Sun, 19 Nov 2023 15:12:10 -0800 Subject: [PATCH 116/138] Construct the command only once --- plugin/vimux.vim | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 9d0076e..51fcbf5 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -192,11 +192,12 @@ function! VimuxPromptCommand(...) abort endfunction function! VimuxTmux(arguments) abort + let l:tmuxCommand = VimuxOption('VimuxTmuxCommand').' '.a:arguments if VimuxOption('VimuxDebug') - echom VimuxOption('VimuxTmuxCommand').' '.a:arguments + echom l:tmuxCommand endif if has_key(environ(), 'TMUX') - return system(VimuxOption('VimuxTmuxCommand').' '.a:arguments) + return system(l:tmuxCommand) else throw 'Aborting, because not inside tmux session.' endif From 5a7f37b43eaa5be7a5e90c56d48dbbae0a0f7337 Mon Sep 17 00:00:00 2001 From: Michael van der Kamp Date: Sun, 19 Nov 2023 15:16:52 -0800 Subject: [PATCH 117/138] Add docs about VimuxDebug --- doc/vimux.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/doc/vimux.txt b/doc/vimux.txt index 8ab6ad3..3936164 100644 --- a/doc/vimux.txt +++ b/doc/vimux.txt @@ -469,5 +469,16 @@ runner is created instead, positioned according to `VimuxOrientation`. < Default: {} +------------------------------------------------------------------------------ + *VimuxDebug* +4.13 g:VimuxDebug~ + +If you're having trouble with vimux, set this option to get vimux to pass each +tmux command to |echomsg| before running it. +> + let g:VimuxDebug = v:true +< +Default: v:false + ============================================================================== vim:tw=78:ts=2:sw=2:expandtab:ft=help:norl: From dac3388a4c344bddc080c0886a2ee13994307555 Mon Sep 17 00:00:00 2001 From: Michael van der Kamp Date: Sun, 19 Nov 2023 15:28:38 -0800 Subject: [PATCH 118/138] Throw error if system call fails --- plugin/vimux.vim | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 51fcbf5..3f72ac1 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -197,7 +197,11 @@ function! VimuxTmux(arguments) abort echom l:tmuxCommand endif if has_key(environ(), 'TMUX') - return system(l:tmuxCommand) + let l:output = system(l:tmuxCommand) + if v:shell_error + throw 'Tmux command failed with message:' . l:output + endif + return l:output else throw 'Aborting, because not inside tmux session.' endif From fbfca5a68b050ca79f8b3489b9824a7a4f60806b Mon Sep 17 00:00:00 2001 From: Michael van der Kamp Date: Sun, 19 Nov 2023 15:42:03 -0800 Subject: [PATCH 119/138] Use new checkout and setup-python versions --- .github/workflows/check.yml | 2 +- .github/workflows/reviewdog.yml | 2 +- .github/workflows/vint.yml | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 2ce79b3..6c3a521 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -14,7 +14,7 @@ jobs: runs-on: ${{ matrix.osFlavor }} steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Enable Universe package repository run: | sudo add-apt-repository ${{ matrix.vimVersion == 'stable' && 'universe' || 'ppa:neovim-ppa/unstable' }} diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml index 421e438..6427211 100644 --- a/.github/workflows/reviewdog.yml +++ b/.github/workflows/reviewdog.yml @@ -5,7 +5,7 @@ jobs: name: vint runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: vint uses: reviewdog/action-vint@v1 with: diff --git a/.github/workflows/vint.yml b/.github/workflows/vint.yml index 909de43..8529ed9 100644 --- a/.github/workflows/vint.yml +++ b/.github/workflows/vint.yml @@ -6,9 +6,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 - name: Setup dependencies run: pip install vim-vint - name: Lint Vimscript From ba80e544e2b4932f20378d76d6e04d014e85fe76 Mon Sep 17 00:00:00 2001 From: Michael van der Kamp Date: Sun, 19 Nov 2023 15:48:22 -0800 Subject: [PATCH 120/138] Just run on ubuntu-latest Trying to run on ubuntu 18 is failing to be picked up by any runners --- .github/workflows/check.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 6c3a521..42ef9ba 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -5,13 +5,12 @@ jobs: strategy: fail-fast: false matrix: - osFlavor: [ubuntu-20.04, ubuntu-18.04] vimFlavor: [neovim, vim] vimVersion: [stable, unstable] exclude: - vimFlavor: vim vimVersion: unstable - runs-on: ${{ matrix.osFlavor }} + runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 From f7c41607d9246ec4b6cc28587cce84d75d106e3e Mon Sep 17 00:00:00 2001 From: Chakib Benziane Date: Mon, 19 Feb 2024 08:27:35 +0100 Subject: [PATCH 121/138] fix: Use tmux 3.4 compatible pane height parameters (#217) Co-authored-by: spike --- plugin/vimux.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 9d0076e..4572a9b 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -225,7 +225,7 @@ endfunction function! s:vimuxPaneOptions() abort let height = VimuxOption('VimuxHeight') let orientation = VimuxOption('VimuxOrientation') - return '-p '.height.' -'.orientation + return '-l '.height.'% -'.orientation endfunction "" From 690d4aa067c82f8ec2d882cfe991802c7d9eb58a Mon Sep 17 00:00:00 2001 From: jmriego Date: Thu, 25 Jul 2024 22:38:56 +0200 Subject: [PATCH 122/138] Allow user to remove percentage sign in VimuxHeight --- plugin/vimux.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 76d0541..ca78fa5 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -5,7 +5,7 @@ let g:loaded_vimux = 1 " Set up all global options with defaults right away, in one place let g:VimuxDebug = get(g:, 'VimuxDebug', v:false) -let g:VimuxHeight = get(g:, 'VimuxHeight', 20) +let g:VimuxHeight = get(g:, 'VimuxHeight', '20%') let g:VimuxOpenExtraArgs = get(g:, 'VimuxOpenExtraArgs', '') let g:VimuxOrientation = get(g:, 'VimuxOrientation', 'v') let g:VimuxPromptString = get(g:, 'VimuxPromptString', 'Command? ') @@ -230,7 +230,7 @@ endfunction function! s:vimuxPaneOptions() abort let height = VimuxOption('VimuxHeight') let orientation = VimuxOption('VimuxOrientation') - return '-l '.height.'% -'.orientation + return '-l '.height.' -'.orientation endfunction "" From c4ffa0b992798f3362b27642088dccb251aaef1e Mon Sep 17 00:00:00 2001 From: jmriego Date: Thu, 25 Jul 2024 22:41:34 +0200 Subject: [PATCH 123/138] Update docs for VimuxHeight --- doc/vimux.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/vimux.txt b/doc/vimux.txt index 3936164..1d25ca1 100644 --- a/doc/vimux.txt +++ b/doc/vimux.txt @@ -294,11 +294,12 @@ change the behavior of Vimux in just the current buffer. *VimuxConfiguration_height* 4.1 g:VimuxHeight~ -The percent of the screen the split pane Vimux will spawn should take up. +The part of the screen the split pane Vimux will spawn should take up. This +option accepts both a number of lines/columns or a percentage. > let g:VimuxHeight = "40" < -Default: "20" +Default: "20%" ------------------------------------------------------------------------------ *VimuxConfiguration_orientation* From b110cd95062f5d83a4cb58b807783d783e1fbcd8 Mon Sep 17 00:00:00 2001 From: Tiago Scolari <38940+tscolari@users.noreply.github.com> Date: Wed, 21 Aug 2024 09:44:17 +0100 Subject: [PATCH 124/138] Only try to clear the pane if it exists (#231) --- plugin/vimux.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index ca78fa5..ac950c5 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -167,13 +167,13 @@ function! VimuxInterruptRunner() abort endfunction function! VimuxClearTerminalScreen() abort - if exists('g:VimuxRunnerIndex') + if exists('g:VimuxRunnerIndex') && s:hasRunner(g:VimuxRunnerIndex) !=# -1 call VimuxSendKeys('C-l') endif endfunction function! VimuxClearRunnerHistory() abort - if exists('g:VimuxRunnerIndex') + if exists('g:VimuxRunnerIndex') && s:hasRunner(g:VimuxRunnerIndex) !=# -1 call VimuxTmux('clear-history -t '.g:VimuxRunnerIndex) endif endfunction From 49eaa8d6601dcdf8281b6c80ae43bfc87888e3ea Mon Sep 17 00:00:00 2001 From: Michael van der Kamp Date: Mon, 26 Aug 2024 17:39:39 -0700 Subject: [PATCH 125/138] Use `copy-mode -q` to leave copy mode --- doc/vimux.txt | 11 ++++++++--- plugin/vimux.vim | 3 ++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/doc/vimux.txt b/doc/vimux.txt index 1d25ca1..efc3898 100644 --- a/doc/vimux.txt +++ b/doc/vimux.txt @@ -332,12 +332,17 @@ Default: 1 *VimuxConfiguration_reset_sequence* 4.4 g:VimuxResetSequence~ -The keys sent to the runner pane before running a command. By default it sends -`q` to make sure the pane is not in scroll-mode and `C-u` to clear the line. +The keys sent to the runner pane before running a command. + +When vimux runs a tmux command, it first makes sure that the runner is not in +copy mode by running `copy-mode -q` on the runner. This sequence is then sent +to make sure that the runner is ready to receive input. + +The default sends `C-u` to clear the line. > let g:VimuxResetSequence = "" < -Default: "q C-u" +Default: "C-u" ------------------------------------------------------------------------------ *VimuxPromptString* diff --git a/plugin/vimux.vim b/plugin/vimux.vim index ac950c5..a86790f 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -9,7 +9,7 @@ let g:VimuxHeight = get(g:, 'VimuxHeight', '20%') let g:VimuxOpenExtraArgs = get(g:, 'VimuxOpenExtraArgs', '') let g:VimuxOrientation = get(g:, 'VimuxOrientation', 'v') let g:VimuxPromptString = get(g:, 'VimuxPromptString', 'Command? ') -let g:VimuxResetSequence = get(g:, 'VimuxResetSequence', 'q C-u') +let g:VimuxResetSequence = get(g:, 'VimuxResetSequence', 'C-u') let g:VimuxRunnerName = get(g:, 'VimuxRunnerName', '') let g:VimuxRunnerType = get(g:, 'VimuxRunnerType', 'pane') let g:VimuxRunnerQuery = get(g:, 'VimuxRunnerQuery', {}) @@ -73,6 +73,7 @@ function! VimuxRunCommand(command, ...) abort endif let resetSequence = VimuxOption('VimuxResetSequence') let g:VimuxLastCommand = a:command + call VimuxTmux('copy-mode -q -t '.g:VimuxRunnerIndex) call VimuxSendKeys(resetSequence) call VimuxSendText(a:command) if l:autoreturn ==# 1 From b002925b506fa35439a8cfe335d6b4433f622150 Mon Sep 17 00:00:00 2001 From: Michael van der Kamp Date: Sun, 1 Sep 2024 22:47:43 -0700 Subject: [PATCH 126/138] Prefix 'q ' to reset sequence for older versions --- plugin/vimux.vim | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index a86790f..3d26239 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -71,10 +71,20 @@ function! VimuxRunCommand(command, ...) abort if exists('a:1') let l:autoreturn = a:1 endif - let resetSequence = VimuxOption('VimuxResetSequence') + let l:resetSequence = VimuxOption('VimuxResetSequence') let g:VimuxLastCommand = a:command - call VimuxTmux('copy-mode -q -t '.g:VimuxRunnerIndex) - call VimuxSendKeys(resetSequence) + + try + call VimuxTmux('copy-mode -q -t '.g:VimuxRunnerIndex) + catch + let l:versionString = s:tmuxProperty('#{version}') + if str2float(l:versionString) < 3.2 + let l:resetSequence = 'q '.l:resetSequence + else + endif + endtry + call VimuxSendKeys(l:resetSequence) + call VimuxSendText(a:command) if l:autoreturn ==# 1 call VimuxSendKeys('Enter') From 20ec061025711c87b786c5ad50c1a0b4c7a260f2 Mon Sep 17 00:00:00 2001 From: Michael van der Kamp Date: Wed, 18 Sep 2024 18:54:47 -0700 Subject: [PATCH 127/138] Remove unnecessary 'else' statement --- plugin/vimux.vim | 1 - 1 file changed, 1 deletion(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 3d26239..f345d30 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -80,7 +80,6 @@ function! VimuxRunCommand(command, ...) abort let l:versionString = s:tmuxProperty('#{version}') if str2float(l:versionString) < 3.2 let l:resetSequence = 'q '.l:resetSequence - else endif endtry call VimuxSendKeys(l:resetSequence) From 7db6b2f79d432ee3820668b1d4625311dbe1d0ad Mon Sep 17 00:00:00 2001 From: Travis Collins Date: Thu, 26 Sep 2024 15:50:49 -0600 Subject: [PATCH 128/138] Exit copy-mode when clearing terminal screen (#233) --- plugin/vimux.vim | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index f345d30..67072a9 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -74,16 +74,8 @@ function! VimuxRunCommand(command, ...) abort let l:resetSequence = VimuxOption('VimuxResetSequence') let g:VimuxLastCommand = a:command - try - call VimuxTmux('copy-mode -q -t '.g:VimuxRunnerIndex) - catch - let l:versionString = s:tmuxProperty('#{version}') - if str2float(l:versionString) < 3.2 - let l:resetSequence = 'q '.l:resetSequence - endif - endtry + call s:exitCopyMode() call VimuxSendKeys(l:resetSequence) - call VimuxSendText(a:command) if l:autoreturn ==# 1 call VimuxSendKeys('Enter') @@ -178,6 +170,7 @@ endfunction function! VimuxClearTerminalScreen() abort if exists('g:VimuxRunnerIndex') && s:hasRunner(g:VimuxRunnerIndex) !=# -1 + call s:exitCopyMode() call VimuxSendKeys('C-l') endif endfunction @@ -217,6 +210,17 @@ function! VimuxTmux(arguments) abort endif endfunction +function! s:exitCopyMode() abort + try + call VimuxTmux('copy-mode -q -t '.g:VimuxRunnerIndex) + catch + let l:versionString = s:tmuxProperty('#{version}') + if str2float(l:versionString) < 3.2 + call VimuxSendKeys('q') + endif + endtry +endfunction + function! s:tmuxSession() abort return s:tmuxProperty('#S') endfunction From 6e0bbd3d213e866f26ae7bf01e713b58c6ad3af7 Mon Sep 17 00:00:00 2001 From: Michael van der Kamp Date: Sat, 7 Dec 2024 12:46:45 -0800 Subject: [PATCH 129/138] Check for runner existence, not just variable --- plugin/vimux.vim | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 67072a9..add2bca 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -64,7 +64,7 @@ function! VimuxRunLastCommand() abort endfunction function! VimuxRunCommand(command, ...) abort - if !exists('g:VimuxRunnerIndex') || s:hasRunner(g:VimuxRunnerIndex) ==# -1 + if ! s:hasRunner() call VimuxOpenRunner() endif let l:autoreturn = 1 @@ -87,14 +87,13 @@ function! VimuxSendText(text) abort endfunction function! VimuxSendKeys(keys) abort - if exists('g:VimuxRunnerIndex') - call VimuxTmux('send-keys -t '.g:VimuxRunnerIndex.' '.a:keys) - else - echo 'No vimux runner pane/window. Create one with VimuxOpenRunner' - endif + call VimuxTmux('send-keys -t '.g:VimuxRunnerIndex.' '.a:keys) endfunction function! VimuxOpenRunner() abort + if s:hasRunner() + return + endif let existingId = s:existingRunnerId() if existingId !=# '' let g:VimuxRunnerIndex = existingId @@ -112,14 +111,14 @@ function! VimuxOpenRunner() abort endfunction function! VimuxCloseRunner() abort - if exists('g:VimuxRunnerIndex') + if s:hasRunner() call VimuxTmux('kill-'.VimuxOption('VimuxRunnerType').' -t '.g:VimuxRunnerIndex) - unlet g:VimuxRunnerIndex endif + unlet g:VimuxRunnerIndex endfunction function! VimuxTogglePane() abort - if exists('g:VimuxRunnerIndex') + if s:hasRunner() if VimuxOption('VimuxRunnerType') ==# 'window' call VimuxTmux('join-pane -s '.g:VimuxRunnerIndex.' '.s:vimuxPaneOptions()) let g:VimuxRunnerType = 'pane' @@ -138,7 +137,7 @@ function! VimuxTogglePane() abort endfunction function! VimuxZoomRunner() abort - if exists('g:VimuxRunnerIndex') + if s:hasRunner() if VimuxOption('VimuxRunnerType') ==# 'pane' call VimuxTmux('resize-pane -Z -t '.g:VimuxRunnerIndex) elseif VimuxOption('VimuxRunnerType') ==# 'window' @@ -169,14 +168,14 @@ function! VimuxInterruptRunner() abort endfunction function! VimuxClearTerminalScreen() abort - if exists('g:VimuxRunnerIndex') && s:hasRunner(g:VimuxRunnerIndex) !=# -1 + if s:hasRunner() call s:exitCopyMode() call VimuxSendKeys('C-l') endif endfunction function! VimuxClearRunnerHistory() abort - if exists('g:VimuxRunnerIndex') && s:hasRunner(g:VimuxRunnerIndex) !=# -1 + if s:hasRunner() call VimuxTmux('clear-history -t '.g:VimuxRunnerIndex) endif endfunction @@ -327,9 +326,14 @@ function! s:tmuxProperty(property) abort return substitute(VimuxTmux("display -p '".a:property."'"), '\n$', '', '') endfunction -function! s:hasRunner(index) abort - let runnerType = VimuxOption('VimuxRunnerType') - return match(VimuxTmux('list-'.runnerType."s -F '#{".runnerType."_id}'"), a:index) +function! s:hasRunner() abort + if ! exists('g:VimuxRunnerIndex') + return v:false + endif + let l:runnerType = VimuxOption('VimuxRunnerType') + let l:command = 'list-'.runnerType."s -F '#{".runnerType."_id}'" + let l:found = match(VimuxTmux(l:command), g:VimuxRunnerIndex) + return l:found != -1 endfunction function! s:autoclose() abort From a2591cf3701db33825b45f9008f3326d33c69c17 Mon Sep 17 00:00:00 2001 From: Michael van der Kamp Date: Sun, 25 May 2025 11:35:19 -0700 Subject: [PATCH 130/138] Remove redundant hasRunner() check --- plugin/vimux.vim | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index add2bca..7f2e423 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -64,9 +64,7 @@ function! VimuxRunLastCommand() abort endfunction function! VimuxRunCommand(command, ...) abort - if ! s:hasRunner() - call VimuxOpenRunner() - endif + call VimuxOpenRunner() let l:autoreturn = 1 if exists('a:1') let l:autoreturn = a:1 From 512db1aced0b73e6e4ee952aa7cc062dcbb4783a Mon Sep 17 00:00:00 2001 From: Michael van der Kamp Date: Sun, 25 May 2025 11:35:45 -0700 Subject: [PATCH 131/138] Fix indentation --- plugin/vimux.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 7f2e423..1779f6c 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -116,7 +116,7 @@ function! VimuxCloseRunner() abort endfunction function! VimuxTogglePane() abort - if s:hasRunner() + if s:hasRunner() if VimuxOption('VimuxRunnerType') ==# 'window' call VimuxTmux('join-pane -s '.g:VimuxRunnerIndex.' '.s:vimuxPaneOptions()) let g:VimuxRunnerType = 'pane' From eee9fee0d84ca89f370817f5a5c6315a1ef44e5a Mon Sep 17 00:00:00 2001 From: Michael van der Kamp Date: Sun, 25 May 2025 12:08:22 -0700 Subject: [PATCH 132/138] Extract internal versions of sendKeys and sendText --- plugin/vimux.vim | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 1779f6c..6c045b1 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -73,19 +73,27 @@ function! VimuxRunCommand(command, ...) abort let g:VimuxLastCommand = a:command call s:exitCopyMode() - call VimuxSendKeys(l:resetSequence) - call VimuxSendText(a:command) + call s:sendKeys(l:resetSequence) + call s:sendText(a:command) if l:autoreturn ==# 1 - call VimuxSendKeys('Enter') + call s:sendKeys('Enter') endif endfunction function! VimuxSendText(text) abort - call VimuxSendKeys(shellescape(substitute(a:text, '\n$', ' ', ''))) + if s:hasRunner() + call s:sendText(text) + else + echo 'No vimux runner pane/window. Create one with VimuxOpenRunner' + endif endfunction function! VimuxSendKeys(keys) abort - call VimuxTmux('send-keys -t '.g:VimuxRunnerIndex.' '.a:keys) + if s:hasRunner() + call s:sendKeys(keys) + else + echo 'No vimux runner pane/window. Create one with VimuxOpenRunner' + endif endfunction function! VimuxOpenRunner() abort @@ -152,23 +160,23 @@ endfunction function! VimuxScrollUpInspect() abort call VimuxInspectRunner() call VimuxTmux('last-'.VimuxOption('VimuxRunnerType')) - call VimuxSendKeys('C-u') + call s:sendKeys('C-u') endfunction function! VimuxScrollDownInspect() abort call VimuxInspectRunner() call VimuxTmux('last-'.VimuxOption('VimuxRunnerType')) - call VimuxSendKeys('C-d') + call s:sendKeys('C-d') endfunction function! VimuxInterruptRunner() abort - call VimuxSendKeys('^c') + call s:sendKeys('^c') endfunction function! VimuxClearTerminalScreen() abort if s:hasRunner() call s:exitCopyMode() - call VimuxSendKeys('C-l') + call s:sendKeys('C-l') endif endfunction @@ -213,7 +221,7 @@ function! s:exitCopyMode() abort catch let l:versionString = s:tmuxProperty('#{version}') if str2float(l:versionString) < 3.2 - call VimuxSendKeys('q') + call s:sendKeys('q') endif endtry endfunction @@ -339,3 +347,11 @@ function! s:autoclose() abort call VimuxCloseRunner() endif endfunction + +function! s:sendKeys(keys) abort + call VimuxTmux('send-keys -t '.g:VimuxRunnerIndex.' '.a:keys) +endfunction + +function! s:sendText(text) abort + call s:sendKeys(shellescape(substitute(a:text, '\n$', ' ', ''))) +endfunction From 5bcfb6a68b4ab2ff128bb6f056ea5c5a7dfbfe0e Mon Sep 17 00:00:00 2001 From: Michael van der Kamp Date: Sun, 25 May 2025 12:12:23 -0700 Subject: [PATCH 133/138] Always check hasRunner for all external functions --- plugin/vimux.vim | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 6c045b1..e02006b 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -153,24 +153,32 @@ function! VimuxZoomRunner() abort endfunction function! VimuxInspectRunner() abort - call VimuxTmux('select-'.VimuxOption('VimuxRunnerType').' -t '.g:VimuxRunnerIndex) - call VimuxTmux('copy-mode') + if s:hasRunner() + call VimuxTmux('select-'.VimuxOption('VimuxRunnerType').' -t '.g:VimuxRunnerIndex) + call VimuxTmux('copy-mode') + return v:true + endif + return v:false endfunction function! VimuxScrollUpInspect() abort - call VimuxInspectRunner() - call VimuxTmux('last-'.VimuxOption('VimuxRunnerType')) - call s:sendKeys('C-u') + if VimuxInspectRunner() + call VimuxTmux('last-'.VimuxOption('VimuxRunnerType')) + call s:sendKeys('C-u') + endif endfunction function! VimuxScrollDownInspect() abort - call VimuxInspectRunner() - call VimuxTmux('last-'.VimuxOption('VimuxRunnerType')) - call s:sendKeys('C-d') + if VimuxInspectRunner() + call VimuxTmux('last-'.VimuxOption('VimuxRunnerType')) + call s:sendKeys('C-d') + endif endfunction function! VimuxInterruptRunner() abort - call s:sendKeys('^c') + if s:hasRunner() + call s:sendKeys('^c') + endif endfunction function! VimuxClearTerminalScreen() abort From 7058d109f8b0e5d7081e0ab6341d4d8886beeb78 Mon Sep 17 00:00:00 2001 From: Michael van der Kamp Date: Sun, 25 May 2025 12:28:14 -0700 Subject: [PATCH 134/138] Echo a helpful message if missing required runner --- plugin/vimux.vim | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index e02006b..7b4033c 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -84,7 +84,7 @@ function! VimuxSendText(text) abort if s:hasRunner() call s:sendText(text) else - echo 'No vimux runner pane/window. Create one with VimuxOpenRunner' + call s:echoNoRunner() endif endfunction @@ -92,7 +92,7 @@ function! VimuxSendKeys(keys) abort if s:hasRunner() call s:sendKeys(keys) else - echo 'No vimux runner pane/window. Create one with VimuxOpenRunner' + call s:echoNoRunner() endif endfunction @@ -139,6 +139,8 @@ function! VimuxTogglePane() abort \) let g:VimuxRunnerType = 'window' endif + else + call s:echoNoRunner() endif endfunction @@ -149,6 +151,8 @@ function! VimuxZoomRunner() abort elseif VimuxOption('VimuxRunnerType') ==# 'window' call VimuxTmux('select-window -t '.g:VimuxRunnerIndex) endif + else + call s:echoNoRunner() endif endfunction @@ -158,6 +162,7 @@ function! VimuxInspectRunner() abort call VimuxTmux('copy-mode') return v:true endif + call s:echoNoRunner() return v:false endfunction @@ -178,6 +183,8 @@ endfunction function! VimuxInterruptRunner() abort if s:hasRunner() call s:sendKeys('^c') + else + call s:echoNoRunner() endif endfunction @@ -185,12 +192,16 @@ function! VimuxClearTerminalScreen() abort if s:hasRunner() call s:exitCopyMode() call s:sendKeys('C-l') + else + call s:echoNoRunner() endif endfunction function! VimuxClearRunnerHistory() abort if s:hasRunner() call VimuxTmux('clear-history -t '.g:VimuxRunnerIndex) + else + call s:echoNoRunner() endif endfunction @@ -363,3 +374,7 @@ endfunction function! s:sendText(text) abort call s:sendKeys(shellescape(substitute(a:text, '\n$', ' ', ''))) endfunction + +function! s:echoNoRunner() abort + echo 'No vimux runner pane/window. Create one with VimuxOpenRunner' +endfunction From 2d5b13dd6bb60f761d4ab44684f29064d907f779 Mon Sep 17 00:00:00 2001 From: Michael van der Kamp Date: Sun, 25 May 2025 12:35:59 -0700 Subject: [PATCH 135/138] Avoid error message if VimuxRunnerIndex undefined --- plugin/vimux.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 7b4033c..34f18cf 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -120,7 +120,7 @@ function! VimuxCloseRunner() abort if s:hasRunner() call VimuxTmux('kill-'.VimuxOption('VimuxRunnerType').' -t '.g:VimuxRunnerIndex) endif - unlet g:VimuxRunnerIndex + unlet! g:VimuxRunnerIndex endfunction function! VimuxTogglePane() abort From e8cc82397d877c4b0e3f51f730e062f704759f5e Mon Sep 17 00:00:00 2001 From: Michael van der Kamp Date: Sun, 25 May 2025 12:46:24 -0700 Subject: [PATCH 136/138] Fix indentation --- plugin/vimux.vim | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 34f18cf..e10ea66 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -98,7 +98,7 @@ endfunction function! VimuxOpenRunner() abort if s:hasRunner() - return + return endif let existingId = s:existingRunnerId() if existingId !=# '' @@ -132,11 +132,11 @@ function! VimuxTogglePane() abort call VimuxTmux('last-'.VimuxOption('VimuxRunnerType')) elseif VimuxOption('VimuxRunnerType') ==# 'pane' let g:VimuxRunnerIndex=substitute( - \ VimuxTmux('break-pane -d -s '.g:VimuxRunnerIndex." -P -F '#{window_id}'"), - \ '\n', - \ '', - \ '' - \) + \ VimuxTmux('break-pane -d -s '.g:VimuxRunnerIndex." -P -F '#{window_id}'"), + \ '\n', + \ '', + \ '' + \) let g:VimuxRunnerType = 'window' endif else @@ -240,7 +240,7 @@ function! s:exitCopyMode() abort catch let l:versionString = s:tmuxProperty('#{version}') if str2float(l:versionString) < 3.2 - call s:sendKeys('q') + call s:sendKeys('q') endif endtry endfunction @@ -266,9 +266,9 @@ function! s:tmuxWindowId() abort endfunction function! s:vimuxPaneOptions() abort - let height = VimuxOption('VimuxHeight') - let orientation = VimuxOption('VimuxOrientation') - return '-l '.height.' -'.orientation + let height = VimuxOption('VimuxHeight') + let orientation = VimuxOption('VimuxOrientation') + return '-l '.height.' -'.orientation endfunction "" @@ -288,13 +288,13 @@ function! s:existingRunnerId() abort let currentId = s:tmuxIndex() let message = VimuxTmux('select-'.runnerType.' -t '.query.'') if message ==# '' - " A match was found. Make sure it isn't the current vim pane/window - " though! + " A match was found. Make sure it isn't the current vim pane/window + " though! let runnerId = s:tmuxIndex() if runnerId !=# currentId - " Success! - call VimuxTmux('last-'.runnerType) - return runnerId + " Success! + call VimuxTmux('last-'.runnerType) + return runnerId endif endif return '' @@ -306,11 +306,11 @@ function! s:nearestRunnerId() abort let runnerType = VimuxOption('VimuxRunnerType') let filter = s:getTargetFilter() let views = split( - \ VimuxTmux( - \ 'list-'.runnerType.'s' - \ ." -F '#{".runnerType.'_active}:#{'.runnerType."_id}'" - \ .filter), - \ '\n') + \ VimuxTmux( + \ 'list-'.runnerType.'s' + \ ." -F '#{".runnerType.'_active}:#{'.runnerType."_id}'" + \ .filter), + \ '\n') " '1:' is the current active pane (the one with vim). " Find the first non-active pane. for view in views @@ -353,7 +353,7 @@ endfunction function! s:hasRunner() abort if ! exists('g:VimuxRunnerIndex') - return v:false + return v:false endif let l:runnerType = VimuxOption('VimuxRunnerType') let l:command = 'list-'.runnerType."s -F '#{".runnerType."_id}'" @@ -372,7 +372,7 @@ function! s:sendKeys(keys) abort endfunction function! s:sendText(text) abort - call s:sendKeys(shellescape(substitute(a:text, '\n$', ' ', ''))) + call s:sendKeys(shellescape(substitute(a:text, '\n$', ' ', ''))) endfunction function! s:echoNoRunner() abort From eeb2028461498b9a959ae696f5e9a0a505d4e019 Mon Sep 17 00:00:00 2001 From: Michael van der Kamp Date: Sun, 25 May 2025 12:49:23 -0700 Subject: [PATCH 137/138] Fix undefined variable --- plugin/vimux.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index e10ea66..d697629 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -82,7 +82,7 @@ endfunction function! VimuxSendText(text) abort if s:hasRunner() - call s:sendText(text) + call s:sendText(a:text) else call s:echoNoRunner() endif @@ -90,7 +90,7 @@ endfunction function! VimuxSendKeys(keys) abort if s:hasRunner() - call s:sendKeys(keys) + call s:sendKeys(a:keys) else call s:echoNoRunner() endif From 6c66a70727b17a474c1ae25976ba310fb194629b Mon Sep 17 00:00:00 2001 From: Michael van der Kamp Date: Sat, 12 Jul 2025 13:52:34 -0700 Subject: [PATCH 138/138] Handle case where runner index is the empty string --- plugin/vimux.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index d697629..4f571da 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -352,7 +352,7 @@ function! s:tmuxProperty(property) abort endfunction function! s:hasRunner() abort - if ! exists('g:VimuxRunnerIndex') + if get(g:, 'VimuxRunnerIndex', '') == '' return v:false endif let l:runnerType = VimuxOption('VimuxRunnerType')