Compare commits

..

237 Commits

Author SHA1 Message Date
spike
a62c16c8c3 add a mini sleep for slow to start shells (fish omf) 2022-10-13 16:24:14 +02:00
spike
3c0a1708dc fix pane height parameters 2022-10-13 14:45:30 +02:00
Michael van der Kamp
616fcb4799
Merge pull request #215 from mvanderkamp/issue-210-hotfix
Hotfix for issue from PR #210
2022-09-26 07:59:42 -07:00
Michael van der Kamp
2344b96fed Add a guard against queries matching current pane 2022-09-17 10:23:56 -07:00
Michael van der Kamp
076e13b77c 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.
2022-09-17 10:21:05 -07:00
Michael van der Kamp
740320b798
Address #212 (#213) 2022-09-03 23:14:04 +03:00
Michael van der Kamp
3daa0e91f0
Support tmux's target-pane and target-window syntax for finding an existing runner (#210) 2022-09-03 14:38:25 +03:00
Matthias Bilger
89604a4464
Merge pull request #198 from mvanderkamp/responsive_autoclose
Allow resetting the VimuxCloseOnExit option
2021-08-15 06:30:25 +02:00
Michael van der Kamp
028897b6fb Allow resetting the VimuxCloseOnExit option
Instead of paying attention to the value when starting up, check the
option's value at close.
2021-08-14 12:21:46 -06:00
Matthias Bilger
031cc6208e
Merge pull request #202 from mvanderkamp/issue_201
Use same height and orientation arguments for opening and toggling panes
2021-08-11 04:24:25 +02:00
Samuel Walladge
853646aef3
Abort with an error if run outside tmux session (#204)
Otherwise, the command sent will run in a different and likely unexpected tmux session.
2021-08-10 11:11:34 +03:00
Michael van der Kamp
55a470dc0d Use same height and orientation arguments for opening and toggling panes 2021-07-24 12:34:25 -06:00
Michael van der Kamp
a1650d5f9b
Use abort for all function declarations (#196)
See:
`:help func-abort`
`:help except-compat`
2021-05-25 10:10:22 +03:00
John Bredall
ee0dfae330
Fix VimuxTogglePane (#195) 2021-04-29 22:18:42 +03:00
Caleb Maclennan
ee3075ad30
ci: Test on unreleased NeoVIM development builds (#193) 2021-04-10 10:25:36 +03:00
Caleb Maclennan
96a47f7895
ci: Test on older Ubuntu flavor (has tmux 2.x) 2021-04-10 09:36:03 +03:00
Caleb Maclennan
708ce200d5
Merge pull request #190 from jaspertandy/master 2021-03-18 16:51:04 +03:00
jaspertandy
a70218b30c Update documentation for g:VimuxCommandShell 2021-03-18 13:47:41 +00:00
jaspertandy
59b1d28f80 Needs no argument rather than a blank argument 2021-03-10 14:16:02 +00:00
jaspertandy
784b2834c7 Preference to allow up-arrow 2021-03-10 14:11:59 +00:00
Caleb Maclennan
29d46f6bc1
Merge pull request #189 from mvanderkamp/autoclose_option 2021-03-09 13:43:04 +03:00
Michael van der Kamp
7d977a2954 Documentation touchups 2021-03-07 18:17:53 -06:00
Michael van der Kamp
c4adf57f6e Add documentation for g:VimuxCloseOnExit 2021-03-07 17:58:20 -06:00
Michael van der Kamp
54d24d1694 Add an option to autoclose the runner 2021-03-07 17:47:25 -06:00
Gerhard Hellmann
5b1791673c
Add option to expand VimuxPromptCommand arguments (#166)
Co-authored-by: Gerhard Siegesmund <gerhard.siegesmund@btd.de>
2021-02-23 15:35:38 +03:00
Caleb Maclennan
3bfe0ea285
Fix CI test step name 2021-02-19 12:52:25 +03:00
Caleb Maclennan
9dd1b68b59
Merge pull request #187 from preservim/test
Add CI workflow to actually test-drive Vimux

This is fairly primitive, but it's a start. At least we will know if a PR makes some egregious error that makes basic functionality die. In the future we should probably write some small test scripts and verify the contents of panes with some sort of content capture for true unit regression testing, but a pass/fail grade that we don't explode is better than no testing.
2021-02-19 12:49:12 +03:00
Caleb Maclennan
f02fa9c161
Add CI badge for tmux + vim/nvim + vimux check 2021-02-19 12:42:46 +03:00
Caleb Maclennan
fb43fcbc16
Add CI workflow to actually test-drive Vimux 2021-02-19 12:42:46 +03:00
Caleb Maclennan
1b38911c40 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.
2021-02-18 23:38:53 +03:00
Caleb Maclennan
9214bf9578
Split PR review from branch check workflows 2021-02-18 08:34:30 +03:00
Caleb Maclennan
f293536dd5
docus: Copy edit help docs with fresh link and to remove 1st person 2021-02-18 07:48:50 +03:00
Caleb Maclennan
f1c27deeaa
docs: Promote usage links in readme and remove help doc specific copy 2021-02-18 07:47:28 +03:00
Caleb Maclennan
cac9d11158
docs: Update dead link and copy edit readme to avoid 1st person 2021-02-18 07:40:56 +03:00
Caleb Maclennan
8cc4fe9678
Merge pull request #183 from mvanderkamp/initialize_settings 2021-02-18 06:41:25 +03:00
Caleb Maclennan
f4df4c9b5b
docs: Note settings may be buffer-local 2021-02-16 16:51:49 +03:00
Caleb Maclennan
29c5b39545
Merge branch 'master' into initialize_settings 2021-02-16 15:56:45 +03:00
Caleb Maclennan
576b24c7a0
Cleanup public/private API‌ split & coding style (#184)
* feat: Make s:VimuxOption (was _VimuxOption) public VimuxOption
* refactor: Simplify script-local private function names
* style: Format each function as a paragraph with no blanks
* feat: Make s:tmuxExec (was _VimuxTmux) public VimuxTmux
2021-02-16 15:50:49 +03:00
Caleb Maclennan
992d525ef9
feat: Make s:tmuxExec (was _VimuxTmux) public VimuxTmux 2021-02-16 15:47:18 +03:00
Caleb Maclennan
566833e291
style: Format each function as a paragraph with no blanks 2021-02-16 12:41:42 +03:00
Caleb Maclennan
43681e9f91
refactor: Simplify script-local private function names 2021-02-16 12:41:33 +03:00
Caleb Maclennan
601749152e
feat: Make s:VimuxOption (was _VimuxOption) public VimuxOption 2021-02-16 12:41:10 +03:00
Michael van der Kamp
b13568ea1b
Support buffer-local variants of options 2021-02-16 12:08:41 +03:00
Michael van der Kamp
748b54b885
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
2021-02-16 12:08:24 +03:00
Caleb Maclennan
5f999f4dc4
Fix variable mismatch looking for previous command 2021-02-16 10:09:07 +03:00
Caleb Maclennan
3a1aad8752
style: Normalize indentation and other whitespace 2021-02-16 10:08:56 +03:00
Caleb Maclennan
a2ab8880a1
Allow all commands to be used in chains (#182)
Allow all commands to be used in chains
2021-02-14 20:23:57 +03:00
Caleb Maclennan
ed12df373a
Update canonical URL in readme to new org namespace 2021-02-14 19:48:48 +03:00
Caleb Maclennan
efe04f05dc
Use more standard suffix for Markdown file 2021-02-14 19:27:00 +03:00
Caleb Maclennan
486ac1bd6e
Add lint badge to README 2021-02-14 19:27:00 +03:00
Caleb Maclennan
0e3ebca98b
Add CI job to run vint linter 2021-02-14 19:27:00 +03:00
Caleb Maclennan
bde8b4cb37
Fix vimscript lint errors and add CI linter (#181)
* Add Vint config file for vimscript linting
* Replace underscore convention with proper script-local scopes
* Prefer single quoted strings
* Use the full option name
* Use robust operators
2021-02-14 19:20:03 +03:00
Caleb Maclennan
c212352f93
Use robust operators 2021-02-14 19:17:08 +03:00
Caleb Maclennan
f589e21472
Use the full option name 2021-02-14 19:15:05 +03:00
Caleb Maclennan
a5a17b8e32
Prefer single quoted strings 2021-02-14 19:12:47 +03:00
Caleb Maclennan
e6fb662bf1
Replace underscore convention with proper script-local scopes 2021-02-14 17:12:03 +03:00
Caleb Maclennan
925ae23b42
Add Vint config file for vimscript linting 2021-02-14 16:39:31 +03:00
Matthias Bilger
3693ec6f12
Merge pull request #180 from m42e/preserve-choosesession
Allow setting of VimuxRunner name to reuse session
2021-02-14 13:47:05 +01:00
Matthias Bilger
af602e362d Allow setting of VimuxRunner name to reuse session 2021-02-14 10:10:24 +01:00
Caleb Maclennan
0f5fd2ce49
Fix typo and bump license date range, closes #154 2021-02-14 10:21:21 +03:00
Thales Mello
57bbdc4478
Enable tab autocompletion on VimuxPromptOption (#142) 2021-02-13 21:09:55 +03:00
Caleb Maclennan
cce8466613
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.
2021-02-13 19:29:25 +03:00
Caleb Maclennan
71f28c8296
Merge pull request #174 from mvanderkamp/split-extra-args 2021-02-13 19:23:36 +03:00
Caleb Maclennan
48b541b1a4
Avoid useless space in default empty argument string 2021-02-13 19:22:44 +03:00
Philipp Moers
ef5622f225
Add VimuxClearTerminalScreen (#178) 2021-02-13 19:17:10 +03:00
Caleb Maclennan
7f15726b07
Merge pull request #155 from lyuts/check_tmux_binary 2021-02-13 18:50:26 +03:00
Caleb Maclennan
9c05307141
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.
2021-02-13 18:41:57 +03:00
Giuseppe Rota
46377b8ab9
Escape the text sent to tmux
Closes #76
2021-02-13 12:38:46 +03:00
Thomas Mayfield
8fa6ca92c0
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.
2021-02-13 12:20:02 +03:00
Eugene Yunak
1dec7164ca
Use IDs instead of indexes to identify windows and panes (#110)
...because indexes can change while IDs are constant and unique.
2021-02-13 12:13:02 +03:00
saubhik
fff2f1a686
Fix Markdown formatting in readme (#170) 2021-02-13 12:02:22 +03:00
Eugene Yunak
f48360cea6
Fix docs, config variables should be global (#111) 2021-02-13 12:00:10 +03:00
Jonathan Barratt
02315b02c4
Fix typos in readme (#164) 2021-02-13 10:37:25 +03:00
Michael vanderKamp
67bd945586 Add detail about VimuxOpenExtraArgs option to docs 2020-01-12 17:37:18 -06:00
Michael vanderKamp
556a2d692b Add a VimuxOpenRunner command 2020-01-12 16:59:05 -06:00
Michael vanderKamp
3fdafcfd60 Add VimuxOpenExtraArgs option 2020-01-12 14:13:17 -06:00
Ben Mills
37f41195e6 Merge pull request #161 from tyewang/master
Add vimux-jest-test to README
2017-10-24 17:48:22 -05:00
Tye Wang
020a5eed02 Update plugins section of README.mkd with vimux-jest-test 2017-10-24 16:33:48 -04:00
Leandro Ostera
1adbef72d2 Merge pull request #157 from oskar1233/docs-missing-g
Fix docs typos (missing 'g:')
2017-10-07 11:32:54 +02:00
Leandro Ostera
212a34e5f9 Merge pull request #158 from alfunx/patch-1
Fix docs: Update function name
2017-10-07 11:31:45 +02:00
Alphonse Mariyagnanaseelan
198c8ea8ca Fix docs: Update function name
Updated the docs for `VimuxOpenRunner`, which was called `VimuxOpenPane` before. Relevant commit: 49a048e
2017-09-26 08:22:42 +02:00
Oskar Laska
9c3195a0be Fix docs typos (missing 'g:') 2017-09-21 10:52:04 +02:00
lyuts
9f81329f60 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.
2017-07-09 23:25:32 -07:00
lyuts
0a560ba419 Check tmux binary availability at startup.
Updated the plugin to:
- let override the location of tmux executable.
- check tmux executable availability.
2017-07-09 23:25:16 -07:00
Leandro Ostera
ca96cac46b Merge pull request #147 from lingceng/master
Escape character "`" before send command
2017-07-02 01:08:20 +02:00
Leandro Ostera
edc24ff4d3 Merge pull request #149 from fpereira1/patch-1
updated readme screenshot
2017-07-01 23:54:59 +02:00
Leandro Ostera
f3a919e86f Merge pull request #152 from adeluccar/patch-1
Fix misspeling
2017-07-01 23:54:44 +02:00
Alberto De Lucca
8cb0416401 Fix misspeling 2017-06-16 00:09:53 -04:00
Filype Pereira
bbe6a597cd updated readme screenshot 2017-04-04 20:27:30 +12:00
lingceng
1b847e6d6a Fix #57 Escape character "`" before send command 2017-01-09 18:58:14 +08:00
Ben Mills
2285cefee9 Merge pull request #135 from pgr0ss/patch-1
Add vimux-bazel-test to the list of plugins
2015-09-19 18:36:06 -05:00
Paul Gross
1b9db6392f Add vimux-bazel-test to the list of plugins. 2015-09-18 16:59:17 -07:00
Ben Mills
1d652fdc0c Merge pull request #134 from everbot/master
Fix #133: escape backslash
2015-08-31 09:20:40 -07:00
everbot
770ae77092 Fix #133: escape backslash 2015-08-31 20:43:17 +09:30
Ben Mills
bc11e401f1 Merge pull request #120 from bergman/master
VimuxRunCommandInDir: run in subshell
2015-08-25 10:27:55 -07:00
Ben Mills
5e760def05 Merge pull request #125 from bnadlerjr/patch-1
Fix typo in docs
2015-08-25 10:14:31 -07:00
Ben Mills
40d9f74db6 Merge pull request #130 from notahat/master
Allow configuring which tmux binary to use.
2015-08-25 10:14:23 -07:00
Joakim Bergman
8c332d9919 VimuxRunCommandInDir: run in subshell
Fixes a problem where the directory is not restored if the command exits
with a non-zero code.
2015-08-24 10:27:19 +02:00
Ben Mills
21d7a34172 Merge pull request #131 from jtdowney/add_cargo_plugin
Add vimux-cargo to README
2015-08-22 11:56:01 -07:00
John Downey
4153ba4987 Add vimux-cargo to README 2015-08-21 12:38:37 -05:00
Pete Yandell
863e813928 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.
2015-08-10 17:28:00 +10:00
Ben Mills
a1db73079f Merge pull request #126 from ppalucki/master
escape '$' before sending to tmux
2015-04-02 09:48:18 -07:00
Pawel Palucki
70e16b73f5 escape '$' before sending to tmux 2015-02-11 18:58:40 +01:00
Bob Nadler
24e9d354a4 Fix typo in docs 2015-01-31 12:26:27 -05:00
Ben Mills
a991ce8abd Merge pull request #116 from hpurmann/VimuxRunCommandInDir
Added VimuxRunCommandInDir + doc
2014-11-25 16:17:19 -08:00
Hendrik Purmann
7b655a7b5c Going back to formerly active directory after running command 2014-09-21 21:08:54 +02:00
Ben Mills
50254fad43 Merge pull request #112 from kavinderd/patch-1
Add Vundle installation instructions
2014-09-21 09:49:54 -07:00
Hendrik Purmann
01c0679223 Added VimuxRunCommandInDir + doc 2014-09-21 02:33:49 +02:00
Ben Mills
be6b83cfa4 Merge pull request #114 from mxie/mx-fix-optional-prompt-arg
Check for a predefined command for prompt before executing
2014-09-03 11:14:40 -07:00
Melissa Xie
d21337e01a 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.
2014-09-03 12:22:57 -04:00
Ben Mills
c56e3f79e1 Merge pull request #113 from m42e/master
Predefined command option for VimuxPromptCommand
2014-08-31 21:49:35 -07:00
Matthias Bilger
5a530ca8e4 Updated documentation for VimuxPromptCommand
Added description for VimuxPromptCommand optional parameter.
2014-08-20 07:47:21 +02:00
Matthias Bilger
a772fce3e2 Removed Debug Output
Removed debug output of command which was still in there
2014-08-19 10:02:25 +02:00
Matthias Bilger
d78cd0f8e1 Predefined command option for VimuxPromptCommand
Added the possibility to specify a predefined command which
can be edited or completed in the prompt line.
2014-08-19 08:55:31 +02:00
kavinderd
ab6941c2c5 Add Vundle installation instructions
I added the syntax for installing this plugin via Vundle. Tested it on my system and it works.
2014-07-28 09:44:38 -07:00
Ben Mills
1c3ca9e267 Merge pull request #109 from teoric/master
Run VimuxRunCommand as command
2014-07-14 10:48:31 -07:00
Teoric
e5a9eb74da :VimuxRunCommand nargs=*, not nargs=2 2014-07-13 12:37:17 +02:00
teoric
3135ab5e30 right number of arguments for :VimuxRunCommand
(read docs)
2014-07-13 12:18:28 +02:00
teoric
b437d32c1b remove exclamation mark 2014-07-13 12:10:39 +02:00
teoric
b60a52d36c Allow to use VimuxRunCommand as a command
use as

    :VimuxRunCommand "ls -la"
2014-07-13 12:08:15 +02:00
Ben Mills
fbb873a265 Merge pull request #107 from alexozer/master
Stop Vimux from spewing garbage text
2014-04-25 20:54:39 -05:00
Alex Ozer
54858144f9 Stop Vimux from spewing garbage text 2014-04-25 21:41:51 -04:00
Ben Mills
cf6b8c08db Merge pull request #96 from jdavis/patch-1
Add documentation for VimuxRunnerType config variable
2014-04-25 15:59:51 -05:00
Ben Mills
a04b07992d Merge pull request #105 from alexozer/master
Add VimuxTogglePane
2014-04-25 15:58:47 -05:00
Alex Ozer
6594afdcd0 Use runner window index when converting to window 2014-04-23 16:06:24 -04:00
Alex Ozer
905e002c81 Add VimuxTogglePane 2014-04-23 12:27:12 -04:00
Ben Mills
4cea1a1b84 Merge pull request #97 from ton/fix-closing-incorrect-pane
Identify a pane by its window and its pane index
2014-04-04 09:29:29 -07:00
Ben Mills
cae215041d Merge pull request #99 from justone/fix_zoom
update zoom to support pane or window
2014-04-04 09:28:28 -07:00
Ben Mills
602b2bc39c Merge pull request #101 from robturtle/patch-1
Fixed typo in doc/vimux.txt
2014-03-21 09:28:11 -07:00
LIU Yang
3f3ef11f40 Fixed typo in doc/vimux.txt
Add missing `map`
2014-03-21 15:42:48 +08:00
Nate Jones
d306d43a59 update zoom to support pane or window 2014-01-22 14:22:12 -08:00
Ton van den Heuvel
8ff22883bd 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.
2014-01-21 13:57:54 +01:00
Josh Davis
94b8b938b2 Match VimuxUseNearest documentation option w/ code 2014-01-11 19:28:56 -06:00
Josh Davis
17358e51ab Should return view name if one is active 2014-01-11 19:05:34 -06:00
Josh Davis
ba2b2050b0 Change pane(s) -> view(s) for clarity
Slightly pedantic but it reduces possible confusion.
2014-01-11 18:33:12 -06:00
Josh Davis
ff54646761 Document VimuxRunnerType option 2014-01-11 18:31:25 -06:00
Ben Mills
efa6a9aa4b Create LICENSE 2013-12-13 08:46:05 -08:00
Ben Mills
dfe4fa0b9e Merge pull request #94 from KevinSjoberg/fix-VimuxTmuxIndex-condition
Fix condition in _VimuxTmuxIndex()
2013-12-02 14:27:56 -08:00
Kevin Sjöberg
9855936bd1 Fix condition in _VimuxTmuxIndex()
This ensure that we call `_VimuxRunnerType()` instead of
`_VimuxRunnerType`.
2013-12-02 22:47:07 +01:00
Ben Mills
2e9b00b276 Merge pull request #93 from spiegela/patch-1
Update README to mention Vimix (Elixir Mix integration)
2013-12-02 07:29:56 -08:00
Aaron Spiegel
e7c2413f30 Update README to mention Vimix (Elixir Mix integration) 2013-12-01 20:02:35 -06:00
Ben Mills
f56788990d Update docs to reflect close functions. Fixes #89 2013-11-28 23:28:16 -08:00
Ben Mills
1e30ed8065 Merge pull request #83 from ersatzryan/master
Ability to change runner type
2013-11-28 23:23:02 -08:00
Ben Mills
6a7fcccb6b Merge pull request #80 from cmar/zoomrunner
add VimuxZoomRunner() to zoom the runner pane on Tmux 1.8
2013-11-28 23:20:55 -08:00
Ben Mills
40e93b511f Merge pull request #91 from larrylv/patch-1
Update vimux.txt
2013-11-28 23:20:13 -08:00
Ben Mills
53477b16c9 Correct docs to reflect the true default of VimuxUseNearestPane. Fixes 92 2013-11-07 11:30:24 -08:00
Larry Lv
a74b089c92 Update vimux.txt 2013-10-29 19:52:15 +08:00
Ben Mills
6fb5977ef7 Merge pull request #86 from daniely/patch-1
Update vimux.txt
2013-10-14 07:24:55 -07:00
daniely
3cada36538 Update vimux.txt
Fix typo "ths" to "the"
2013-10-14 20:58:38 +08:00
Ryan Glover
7212ae4ee8 Fix finding index to be based on runner type 2013-09-28 17:26:59 -04:00
Ryan Glover
aa8a444609 Add ability to change runner type between pane and window 2013-09-28 17:14:41 -04:00
Ryan Glover
49a048e94e Change variable and function names to be pane/window agnostic 2013-09-28 16:32:35 -04:00
cmar
635b800f22 add VimuxZoomRunner() to zoom the runner pane on Tmux 1.8 2013-09-13 11:01:45 -04:00
Ben Mills
be0a60ec70 Fix broken image in README. 2013-08-25 10:28:07 -07:00
Ben Mills
0228508f54 Merge pull request #75 from daviddavis/master
Fixing out of range error
2013-08-07 15:07:48 -07:00
Ben Mills
42772b79d3 Merge pull request #77 from jasonbellamy/master
Fixed a typo in the *VimuxOpenPane* section of the doc.
2013-07-05 09:35:39 -07:00
Jason Bellamy
71b2ac31de Fixed a typo in the *VimuxOpenPane* section of the doc. 2013-07-05 11:17:01 -04:00
David Davis
1a0a8abe71 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
2013-07-03 10:18:24 -04:00
Ben Mills
70433ed91b Remove ruby requirement in README. 2013-06-18 09:24:24 -06:00
benmills
7c54b7af6a Merge branch '1.0.0rc1'
Conflicts:
	plugin/vimux.vim
2013-06-15 21:01:21 -07:00
benmills
064ca8693a Only escale double quotes. Thanks @pgr0ss 2013-05-31 12:27:06 -07:00
Ben Mills
d99e30cc9b Merge pull request #68 from anyakichi/master
Escape a semicolon at the end of input
2013-05-23 08:58:58 -07:00
Ben Mills
6dd26fe7c3 Update README.mkd 2013-05-23 09:54:57 -06:00
Anyakichi
b409314c80 Escape a semicolon at the end of input.
Avoid tmux treating it as a separator.
2013-05-21 23:12:59 +09:00
Ben Mills
3f930159a2 Merge pull request #67 from fabiomcosta/patch-1
Updating README with new style Vimux prefixed commands
2013-05-15 20:39:41 -07:00
Fabio M. Costa
a6889b4bf4 Updating README with new style Vimux prefixed commands 2013-05-15 14:42:38 -06:00
benmills
6e909a2439 Fix typo in 1.0.0 docs. 2013-04-03 13:05:15 -05:00
benmills
173fcda85d Update help docs for 1.0.0. 2013-04-03 13:03:57 -05:00
benmills
e729607de6 Rewrite vimux using VimL.
This commit also drops the deprecated functions and removes some rarely used
functions such as VimuxClosePanes.
2013-04-03 13:03:03 -05:00
Ben Mills
35c54c0801 Merge pull request #64 from jingweno/master
Add vimux-zeus to README
2013-03-13 00:26:26 -07:00
Jingwen Owen Ou
e5602b90a5 Add vimux-zeus to README 2013-03-12 23:30:36 -07:00
Ben Mills
63ad5424d8 Merge pull request #62 from fishman/allow_backticks
Allow backticks
2013-03-04 11:23:44 -08:00
Reza Jelveh
8e091d6d5e allow backticks in commands, also fix potential exploit, of user running untrusted code hidden in some source 2013-03-03 21:07:25 -06:00
Reza Jelveh
51ee1a3c6d fix variable scopes 2013-03-03 12:42:17 -06:00
Ben Mills
9a410c5158 Merge pull request #59 from chip/master
Fixed typo in doc/vimux.txt
2013-02-18 20:11:07 -08:00
Chip Castle
46634b7bf7 Fixed typo in doc/vimux.txt 2013-02-18 21:56:40 -06:00
Ben Mills
eab15dc06e Add vimux-golang to README 2013-01-15 20:06:43 -06:00
Ben Mills
81426978b4 Merge pull request #56 from tonyskn/betterCloseRunnerPane
Improve close_runner_pane
2012-12-11 05:43:33 -08:00
tonyskn
06d75cb797 Improve close_runner_pane
Do not execute `tmux kill-pane` when a runner pane is not available

Avoids UI glitches when :VimuxCloseRunner is auto-called before exiting
Vim.
2012-12-11 14:37:55 +01:00
benmills
d6d88a4fce Focus runner pane when inspecting. 2012-10-23 16:29:08 -05:00
Ben Mills
56bcbb0a5f Merge pull request #50 from brianjriddle/master
Fixed for VimuxRunPrompt not working with default
2012-10-22 06:49:17 -07:00
Brian Riddle
8fb2563918 Moved default outside if statement. 2012-10-22 09:07:33 +02:00
Ben Mills
c4eccfcaff Merge pull request #49 from jtmkrueger/master
Allow for Customization of prompt string
2012-10-19 07:37:55 -07:00
John Krueger
dd1c213e4d updated from benmills remote master 2012-10-18 15:12:12 -06:00
John Krueger
201964f046 add VimuxPromptString 2012-10-18 14:57:59 -06:00
Ben Mills
d6eb9e5f04 Add vimux-nose-test link to README. 2012-10-10 09:53:30 -05:00
benmills
908358a09a Escape $ before sending commands to tmux. Fixes #39 2012-09-26 17:48:18 -05:00
Ben Mills
c5216bb345 Merge pull request #40 from alindeman/patch-1
Adds information about vim-vroom
2012-08-27 10:53:35 -07:00
Andy Lindeman
e0146a05fd Adds information about vim-vroom 2012-08-27 11:05:19 -03:00
Ben Mills
ea99609f56 Note ideal tmux version in README 2012-08-15 07:47:22 -05:00
benmills
4f13e27deb Allow multi-word session and window names. Fixes #34 2012-08-15 07:43:50 -05:00
Ben Mills
a221eb2f79 Merge pull request #37 from abstiles/patch-autoreturn
Remember autoreturn setting
2012-08-13 14:23:32 -07:00
Andrew Stiles
539580e5fe Remember autoreturn setting
Create a new variable "_VimTmuxCmdAutoreturn" which remembers the value
of the autoreturn parameter used by the last invocation of
VimuxRunCommand or RunVimTmuxCommand. Use this parameter in the
VimuxRunLastCommand function.
2012-08-05 16:06:10 -05:00
Ben Mills
dc4a45dcbf Merge pull request #35 from prognostikos/patch-1
Fix typo in section 2.4
2012-07-29 15:38:48 -07:00
Matt Rohrer
4a8e31f8b9 Fix typo in section 2.4 2012-07-29 15:54:45 +03:00
Ben Mills
6b8d484dfe Update master 2012-07-18 09:12:06 -05:00
Ben Mills
81b73a9639 Merge pull request #30 from elight/master
Adds terminal page up and down commands
2012-07-18 07:00:56 -07:00
Evan Light
9a0739b117 Merged with HEAD 2012-07-17 17:21:00 -04:00
Evan Light
e4da4bb5f8 Initial rev plus my scroll up and down commands 2012-07-17 17:18:58 -04:00
Ben Mills
ffc2185cb9 Update README. Fixes #24 2012-07-04 14:18:23 -05:00
benmills
f476177ad1 Add VimuxClearRunnerHistory to docs and example keybind changes 2012-06-15 11:06:38 -07:00
benmills
a91e177801 Add VimuxClearRunnerHistory command 2012-06-15 11:02:43 -07:00
benmills
0eefeff876 Remove deprecation warnings 2012-06-15 10:54:12 -07:00
Ben Mills
90129466fa Merge pull request #25 from sotte/rename_commands
Rename all commands to Vimux*
2012-06-15 10:51:47 -07:00
Stefan Otte
8402015a9e Enclose command in doc in >...< 2012-06-08 17:16:01 +02:00
Stefan Otte
ec898ca9b5 Use new commands in doc. 2012-06-08 17:13:57 +02:00
Stefan Otte
642ea420ba Rm new style command of an already deprecated function.
There is no reason also update the name of the command which
is already deprecated.
2012-06-08 17:02:39 +02:00
Stefan Otte
dbdee1c224 Rename all commands to have "Vimux" as prefix.
There are still alias functions.
2012-06-02 00:53:11 +02:00
Stefan Otte
1bc5f5ba85 Add aliases of all cmds that start with 'Vimux*'.
This way it's way easier to get all available vimux commands
in vims ex mode with tab completion.
2012-06-02 00:15:52 +02:00
benmills
8a20aec379 Update README and docs 2012-06-01 14:00:41 -05:00
Ben Mills
346f67906c Merge pull request #22 from sotte/rm_tags
rm tags file and .gitignore it.
2012-06-01 11:48:40 -07:00
Ben Mills
7f65c9c3aa Merge pull request #21 from sotte/docs
The documentation is now available as vim help.
2012-06-01 11:48:23 -07:00
Stefan Otte
c57660b8ad The documentation is now available as vim help.
Don't you hate it when you have to leave vim to do something
that you could easily do within vim? For example looking up the
help for an awesome vim plugin!
2012-05-31 18:45:27 +02:00
Stefan Otte
0cf661c5f4 rm tags file and .gitignore it. 2012-05-31 17:44:50 +02:00
Ben Mills
39678261e9 Merge pull request #18 from tonyskn/closeRunnerOnly
Add `CloseVimTmuxRunner` command
2012-05-07 10:53:18 -07:00
tonyskn
597581715c Add CloseVimTmuxRunner command
Closes runner pane only, leaving any other panes in current window intact.
2012-05-05 19:10:09 +02:00
benmills
c853343e6f Add an optional argument to RunVimTmuxCommand to stop sending a return after the command. Fixes #9 2012-04-20 17:47:54 -05:00
benmills
06ba414a32 Allow single quotes in commands. Fixes #6 2012-04-20 17:03:43 -05:00
benmills
b9684aa6d8 Add a VimuxResetSequence option so plugins can override 2012-04-20 16:24:41 -05:00
benmills
e925b0e127 Clear line and more accurately leave scroll-mode before runnign commands. Fixes #8 2012-04-20 15:34:40 -05:00
Ben Mills
252693ec57 Merge pull request #15 from antonishen/master
Fix: runner path issue, handle tmux not running. Fixes #13
2012-04-15 10:04:25 -07:00
Joshua Antonishen
de99c54046 don't explode if you aren't in a tmux session 2012-04-15 02:07:03 -04:00
Joshua Antonishen
62ded6f281 ensure new panes are in the correct directory 2012-04-15 02:06:21 -04:00
Ben Mills
f0bdd95be3 Merge pull request #11 from oscardelben/master
Use existing pane if one is found
2012-04-14 11:27:33 -07:00
Oscar Del Ben
4f90d43915 Rename ExistingPane to NearestPane 2012-04-14 20:20:45 +02:00
Ben Mills
d75780aa84 Update README.mkd 2012-04-14 12:42:24 -05:00
benmills
64a5ebe875 Use tmux display to find the current session name making vimux tmux1.3 compatible. Fixes #7 2012-04-12 14:54:28 -05:00
Oscar Del Ben
55f6c1f393 Add option to use existing pane if one is found 2012-04-12 12:29:48 +02:00
benmills
96df08933a Vim help docs 2012-04-11 10:05:08 -05:00
benmills
aeb965ce13 Change how current session is found. Fixes #7 2012-04-09 20:09:58 -05:00
benmills
359fb925b7 VimuxOrientation option to set the inital orientation of the runner pane. Fixes #5 2012-04-09 20:09:46 -05:00
benmills
c4a0836dfa Exit copy-mode before running a command in the runner pane. Fixes #3 2012-03-30 13:03:53 -05:00
Ben Mills
d189f2b99c Add Platform-specific Plugins section to the README. 2012-03-27 13:51:59 -05:00
Ben Mills
3628c358be Merge pull request #4 from pgr0ss/tslime_example
Tslime example
2012-03-24 12:32:00 -07:00
Paul Gross
c6e564aaa4 Minor wording update. 2012-03-23 17:12:29 -07:00
Paul Gross
0eba4c252b Show how to use vimux as a tslime replacement in the README. 2012-03-23 19:06:55 -05:00
Paul Gross
9029bcd870 Prevent file from loading more than once, which means we do not need function! anymore. 2012-03-23 18:58:21 -05:00
10 changed files with 907 additions and 247 deletions

43
.github/workflows/check.yml vendored Normal file
View File

@ -0,0 +1,43 @@
name: Check
on: [push, pull_request]
jobs:
check:
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 }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Enable Universe package repository
run: |
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 }}
- name: Review versions
run: |
tmux -V
${{ 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
# 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 == '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)"

13
.github/workflows/reviewdog.yml vendored Normal file
View File

@ -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

15
.github/workflows/vint.yml vendored Normal file
View File

@ -0,0 +1,15 @@
name: Vint
on: [push]
jobs:
vint:
name: vint
runs-on: ubuntu-latest
steps:
- 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 .

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
doc/tags

5
.vintrc.yaml Normal file
View File

@ -0,0 +1,5 @@
cmdargs:
severity: style_problem
color: true
env:
neovim: false

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
The MIT License (MIT)
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
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.

40
README.md Normal file
View File

@ -0,0 +1,40 @@
# 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)
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.
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`.
## Installation
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/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:_
* 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
* [vim-vroom](https://github.com/skalnik/vim-vroom) runner for rspec, cucumber and test/unit; vimux support via `g:vroom_use_vimux`
* [vimux-ruby-test](https://github.com/pgr0ss/vimux-ruby-test) a set of commands to easily run ruby tests
* [vimux-cucumber](https://github.com/cloud8421/vimux-cucumber) run Cucumber Features through Vimux
* [vim-turbux](https://github.com/jgdavey/vim-turbux) Turbo Ruby testing with tmux
* [vimux-pyutils](https://github.com/julienr/vimux-pyutils) A set of functions for vimux that allow to run code blocks in ipython
* [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
* [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

View File

@ -1,103 +0,0 @@
# vimux
Easily interact with tmux from vim. This project is still in development, so some features are still missing.
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`.
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.
## Installation
With **[vim-bundle](https://github.com/benmills/vim-bundle)**: `vim-bundle install benmills/vimux`
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`.
## Usage
### RunVimTmuxCommand
Run a system command in a small horizontal split bellow the current pane vim is in.
```viml
" Run the current file with rspec
map <Leader>rb :call RunVimTmuxCommand("clear; rspec " . bufname("%"))<CR>
```
### PromptVimTmuxCommand
Prompt for a command and run it in a small horizontal split bellow the current pane.
```viml
" Prompt for a command to run
map <Leader>rp :PromptVimTmuxCommand<CR>
```
### RunLastVimTmuxCommand
Run the last command executed by `RunVimTmuxCommand`
```viml
" Run last command executed by RunVimTmuxCommand
map <Leader>rl :RunLastVimTmuxCommand<CR>
```
### InspectVimTmuxRunner
Move into the tmux runner pane created by `RunVimTmuxCommand` and enter copy mode (scroll mode).
```viml
" Inspect runner pane
map <Leader>ri :InspectVimTmuxRunner<CR>
```
### CloseVimTmuxPanes
Close all other tmux panes in the current window.
```viml
" Close all other tmux panes in current window
map <Leader>rx :CloseVimTmuxPanes<CR>
```
### InterruptVimTmuxRunner
Interrupt any command that is running inside the runner pane.
```viml
" Interrupt any command running in the runner pane
map <Leader>rs :InterruptVimTmuxRunner<CR>
```
### Full Keybind Example
```viml
" Run the current file with rspec
map <Leader>rb :call RunVimTmuxCommand("clear; rspec " . bufname("%"))<CR>
" Prompt for a command to run
map <Leader>rp :PromptVimTmuxCommand<CR>
" Run last command executed by RunVimTmuxCommand
map <Leader>rl :RunLastVimTmuxCommand<CR>
" Inspect runner pane
map <Leader>ri :InspectVimTmuxRunner<CR>
" Close all other tmux panes in current window
map <Leader>rx :CloseVimTmuxPanes<CR>
" Interrupt any command running in the runner pane
map <Leader>rs :InterruptVimTmuxRunner<CR>
```
## Options
### VimuxHeight
Set the percent height of the runner pane opened by `RunVimTmuxCommand`.
**Default: `"20"`**
```viml
let VimuxHeight = "50"
```
## Todo
The features I would like to add in the near future.
* Add the ability to target any tmux session, window and pane

473
doc/vimux.txt Normal file
View File

@ -0,0 +1,473 @@
*vimux.txt* easily interact with tmux
Vimux
effortless vim and tmux interaction
==============================================================================
CONTENTS *vimux-contents*
1. About............................ |VimuxAbout|
2. Usage ........................... |VimuxUsage|
2.1 .............................. |VimuxPromptCommand|
2.2 .............................. |VimuxRunLastCommand|
2.3 .............................. |VimuxInspectRunner|
2.4 .............................. |VimuxCloseRunner|
2.5 .............................. |VimuxInterruptRunner|
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|
4. Configuration ................... |VimuxConfiguration|
==============================================================================
ABOUT (1) *VimuxAbout*
Vimux -- Easily interact with tmux from vim.
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.
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 bellow
with full descriptions and example key bindings for your vimrc.
[1] https://github.com/jgdavey/tslime.vim/network
==============================================================================
USAGE (2) *VimuxUsage*
The function VimuxRunCommand(command) is the core of Vimux. It will
create a split pane in the current window and run the passed command in it.
>
:call VimuxRunCommand("ls")
<
This will run the command in a split pane without losing focus of vim. If the
command takes a long time to return you can continue to use vim while the
process finishes and will see the output in the pane when it's finished.
Furthermore there are several handy commands all starting with 'Vimux':
- |VimuxRunCommand|
- |VimuxSendText|
- |VimuxSendKeys|
- |VimuxOpenRunner|
- |VimuxRunLastCommand|
- |VimuxCloseRunner|
- |VimuxInspectRunner|
- |VimuxInterruptRunner|
- |VimuxPromptCommand|
- |VimuxClearTerminalScreen|
- |VimuxClearRunnerHistory|
- |VimuxZoomRunner|
- |VimuxRunCommandInDir|
------------------------------------------------------------------------------
*VimuxRunCommand*
VimuxRunCommand~
Run a system command in a small horizontal split bellow
the current pane vim is in. You can optionally pass a second argument to stop
vimux from automatically sending a return after the command.
>
" Run the current file with rspec
map <Leader>rb :call VimuxRunCommand("clear; rspec " . bufname("%"))<CR>
" Run command without sending a return
map <Leader>rq :call VimuxRunCommand("clear; rspec " . bufname("%"), 0)<CR>
<
------------------------------------------------------------------------------
*VimuxSendText*
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
command can be used to interact with REPLs or other interactive terminal
programs that are not shells.
------------------------------------------------------------------------------
*VimuxSendKeys*
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
can use this command to send keys such as "Enter" or "C-c" to the runner pane.
------------------------------------------------------------------------------
*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
uses the nearest pane or always creates a new one with g:|VimuxUseNearest|
------------------------------------------------------------------------------
*VimuxPromptCommand*
VimuxPromptCommand~
Prompt for a command and run it in a small horizontal split bellow the current
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 <Leader>vp :VimuxPromptCommand<CR>
map <Leader>vm :VimuxPromptCommand("make ")<CR>
<
------------------------------------------------------------------------------
*VimuxRunLastCommand*
VimuxRunLastCommand~
Run the last command executed by `VimuxRunCommand`
>
" Run last command executed by VimuxRunCommand
map <Leader>vl :VimuxRunLastCommand<CR>
<
------------------------------------------------------------------------------
*VimuxInspectRunner*
VimuxInspectRunner~
Move into the tmux runner pane created by `VimuxRunCommand` and enter copy
pmode (scroll mode).
>
" Inspect runner pane map
map <Leader>vi :VimuxInspectRunner<CR>
<
------------------------------------------------------------------------------
*VimuxCloseRunner*
VimuxCloseRunner~
Close the tmux runner created by `VimuxRunCommand`
>
" Close vim tmux runner opened by VimuxRunCommand
map <Leader>vq :VimuxCloseRunner<CR>
<
------------------------------------------------------------------------------
*VimuxInterruptRunner*
VimuxInterruptRunner~
Interrupt any command that is running inside the
runner pane.
>
" Interrupt any command running in the runner pane map
map <Leader>vs :VimuxInterruptRunner<CR>
<
------------------------------------------------------------------------------
*VimuxClearTerminalScreen*
VimuxClearTerminalScreen~
Clear the terminal screen of the runner pane.
>
" Clear the terminal screen of the runner pane.
map <Leader>v<C-l> :VimuxClearTerminalScreen<CR>
<
------------------------------------------------------------------------------
*VimuxClearRunnerHistory*
VimuxClearRunnerHistory~
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
map <Leader>vc :VimuxClearRunnerHistory<CR>
<
------------------------------------------------------------------------------
*VimuxZoomRunner*
VimuxZoomRunner~
Zoom the runner pane. Once its zoomed, you will need
to use tmux "<bind-key> z" to restore the runner pane.
Zoom requires tmux version >= 1.8
>
" Zoom the tmux runner page
map <Leader>vz :VimuxZoomRunner<CR>
<
------------------------------------------------------------------------------
*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 <buffer> <Leader>rr :update<Bar>:call VimuxRunCommandInDir('latexmk -pdf', 1)<CR>
" Push the repository of the currently opened file
nnoremap <leader>gp :call VimuxRunCommandInDir("git push", 0)<CR>
<
==============================================================================
MISC (3) *VimuxMisc*
------------------------------------------------------------------------------
*VimuxExampleKeybinding*
Full Keybind Example~
>
" Run the current file with rspec
map <Leader>rb :call VimuxRunCommand("clear; rspec " . bufname("%"))<CR>
" Prompt for a command to run
map <Leader>vp :VimuxPromptCommand<CR>
" Run last command executed by VimuxRunCommand
map <Leader>vl :VimuxRunLastCommand<CR>
" Inspect runner pane
map <Leader>vi :VimuxInspectRunner<CR>
" Close vim tmux runner opened by VimuxRunCommand
map <Leader>vq :VimuxCloseRunner<CR>
" Interrupt any command running in the runner pane
map <Leader>vx :VimuxInterruptRunner<CR>
" Zoom the runner pane (use <bind-key> z to restore runner pane)
map <Leader>vz :call VimuxZoomRunner()<CR>
" Clear the terminal screen of the runner pane.
map <Leader>v<C-l> :VimuxClearTerminalScreen<CR>
>
------------------------------------------------------------------------------
*VimuxTslimeReplacement*
Vimux as tslime replacement~
Here is how to use vimux to send code to a REPL. This is similar to tslime.
First, add some helpful mappings.
>
function! VimuxSlime()
call VimuxRunCommand(@v, 0)
endfunction
" If text is selected, save it in the v buffer and send that buffer it to tmux
vmap <LocalLeader>vs "vy :call VimuxSlime()<CR>
" Select current paragraph and send it to tmux
nmap <LocalLeader>vs vip<LocalLeader>vs<CR>
<
Now, open a clojure file. Let's say your leader is backslash (\). Type \vp,
and then type lein repl at the prompt. This opens a tmux split running a REPL.
Then, select text or put the cursor on a function and type \vs. This will send
it to the REPL and evaluate it. The reason we pass `0` to `VimuxRunCommand`
is to stop the normal return that is sent to the runner pane and use our own
new line so the clojure REPL will evaluate the selected text without adding an
extra return. Thanks to @trptcolin for discovering this issue.
==============================================================================
CONFIGURATION (4) *VimuxConfiguration*
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*
4.1 g:VimuxHeight~
The percent of the screen the split pane Vimux will spawn should take up.
>
let g:VimuxHeight = "40"
<
Default: "20"
------------------------------------------------------------------------------
*VimuxConfiguration_orientation*
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
creating splits.
>
let g:VimuxOrientation = "h"
<
Options:
"v": vertical
"h": horizontal
Default: "v"
------------------------------------------------------------------------------
*VimuxConfiguration_use_nearest*
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
------------------------------------------------------------------------------
*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.
>
let g:VimuxResetSequence = ""
<
Default: "q C-u"
------------------------------------------------------------------------------
*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
the prompt and your input.
>
let g:VimuxPromptString = ""
<
Default: "Command? "
------------------------------------------------------------------------------
*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.
>
let g:VimuxRunnerType = "window"
<
Options:
"pane": for panes
"window": for windows
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.
Caution: It is probably best not to mix this with |VimuxCloseOnExit|.
>
let g:VimuxRunnerName = "vimuxout"
<
Default: ""
------------------------------------------------------------------------------
*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.
>
let g:VimuxTmuxCommand = "tmate"
<
Default: "tmux"
------------------------------------------------------------------------------
*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
you're using panes or windows, and your version of tmux.
>
let g:VimuxOpenExtraArgs = "-c #{pane_current_path}"
<
Default: ""
------------------------------------------------------------------------------
*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
------------------------------------------------------------------------------
*VimuxCloseOnExit*
4.11 g:VimuxCloseOnExit~
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
------------------------------------------------------------------------------
*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
------------------------------------------------------------------------------
*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:

View File

@ -1,169 +1,321 @@
if !has("ruby") if exists('g:loaded_vimux') || &compatible
finish finish
end endif
let g:loaded_vimux = 1
command RunLastVimTmuxCommand :call RunLastVimTmuxCommand() " Set up all global options with defaults right away, in one place
command CloseVimTmuxPanes :call CloseVimTmuxPanes() let g:VimuxDebug = get(g:, 'VimuxDebug', v:false)
command CloseVimTmuxWindows :call CloseVimTmuxWindows() let g:VimuxHeight = get(g:, 'VimuxHeight', 20)
command InspectVimTmuxRunner :call InspectVimTmuxRunner() let g:VimuxOpenExtraArgs = get(g:, 'VimuxOpenExtraArgs', '')
command InterruptVimTmuxRunner :call InterruptVimTmuxRunner() let g:VimuxOrientation = get(g:, 'VimuxOrientation', 'v')
command PromptVimTmuxCommand :call PromptVimTmuxCommand() 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)
let g:VimuxCloseOnExit = get(g:, 'VimuxCloseOnExit', v:false)
let g:VimuxCommandShell = get(g:, 'VimuxCommandShell', v:true)
function! RunVimTmuxCommand(command) function! VimuxOption(name) abort
let g:_VimTmuxCmd = a:command return get(b:, a:name, get(g:, a:name))
ruby CurrentTmuxSession.new.run_shell_command(Vim.evaluate("g:_VimTmuxCmd"))
endfunction endfunction
function! RunLastVimTmuxCommand() if !executable(VimuxOption('VimuxTmuxCommand'))
if exists("g:_VimTmuxCmd") echohl ErrorMsg | echomsg 'Failed to find executable '.VimuxOption('VimuxTmuxCommand') | echohl None
ruby CurrentTmuxSession.new.run_shell_command(Vim.evaluate("g:_VimTmuxCmd")) finish
endif
command -nargs=* VimuxRunCommand :call VimuxRunCommand(<args>)
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 -nargs=? VimuxPromptCommand :call VimuxPromptCommand(<args>)
command -bar VimuxClearTerminalScreen :call VimuxClearTerminalScreen()
command -bar VimuxClearRunnerHistory :call VimuxClearRunnerHistory()
command -bar VimuxTogglePane :call VimuxTogglePane()
augroup VimuxAutocmds
au!
autocmd VimLeave * call s:autoclose()
augroup END
function! VimuxRunCommandInDir(command, useFile) abort
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() abort
if exists('g:VimuxLastCommand')
call VimuxRunCommand(g:VimuxLastCommand)
else else
echo "No last command" echo 'No last vimux command.'
endif endif
endfunction endfunction
function! ClearVimTmuxWindow() function! VimuxRunCommand(command, ...) abort
if exists("g:_VimTmuxRunnerPane") if !exists('g:VimuxRunnerIndex') || s:hasRunner(g:VimuxRunnerIndex) ==# -1
unlet g:_VimTmuxRunnerPane call VimuxOpenRunner()
end endif
let l:autoreturn = 1
if exists('a:1')
let l:autoreturn = a:1
endif
let resetSequence = VimuxOption('VimuxResetSequence')
let g:VimuxLastCommand = a:command
call VimuxSendKeys(resetSequence)
call VimuxSendText(a:command)
if l:autoreturn ==# 1
call VimuxSendKeys('Enter')
endif
endfunction endfunction
function! CloseVimTmuxWindows() function! VimuxSendText(text) abort
ruby CurrentTmuxSession.new.close_other_panes call VimuxSendKeys(shellescape(substitute(a:text, '\n$', ' ', '')))
call ClearVimTmuxWindow()
echoerr "CloseVimTmuxWindows is deprecated, use CloseVimTmuxPanes"
endfunction endfunction
function! CloseVimTmuxPanes() function! VimuxSendKeys(keys) abort
ruby CurrentTmuxSession.new.close_other_panes if exists('g:VimuxRunnerIndex')
call ClearVimTmuxWindow() call VimuxTmux('send-keys -t '.g:VimuxRunnerIndex.' '.a:keys)
endfunction
function! InterruptVimTmuxRunner()
ruby CurrentTmuxSession.new.interrupt_runner
endfunction
function! InspectVimTmuxRunner()
ruby CurrentTmuxSession.new.inspect_runner
endfunction
function! PromptVimTmuxCommand()
let l:command = input("Command? ")
call RunVimTmuxCommand(l:command)
endfunction
ruby << EOF
class TmuxSession
def initialize(session, window, pane)
@session = session
@window = window
@pane = pane
@runner_pane = vim_cached_runner_pane
end
def vim_cached_runner_pane
if Vim.evaluate('exists("g:_VimTmuxRunnerPane")') != 0
Vim.evaluate('g:_VimTmuxRunnerPane')
else else
nil echo 'No vimux runner pane/window. Create one with VimuxOpenRunner'
end endif
end endfunction
def vim_cached_runner_pane=(runner_pane) function! VimuxOpenRunner() abort
Vim.command("let g:_VimTmuxRunnerPane = '#{runner_pane}'") let existingId = s:existingRunnerId()
end if existingId !=# ''
let g:VimuxRunnerIndex = existingId
def clear_vim_cached_runner_pane
Vim.command("unlet g:_VimTmuxRunnerPane")
end
def height
if Vim.evaluate('exists("g:VimuxHeight")') != 0
Vim.evaluate('g:VimuxHeight')
else else
20 let extraArguments = VimuxOption('VimuxOpenExtraArgs')
end if VimuxOption('VimuxRunnerType') ==# 'pane'
end call VimuxTmux('split-window '.s:vimuxPaneOptions().' '.extraArguments)
elseif VimuxOption('VimuxRunnerType') ==# 'window'
call VimuxTmux('new-window '.extraArguments)
endif
let g:VimuxRunnerIndex = s:tmuxIndex()
call s:setRunnerName()
call VimuxTmux('last-'.VimuxOption('VimuxRunnerType'))
sleep 100m
endif
endfunction
def inspect_runner function! VimuxCloseRunner() abort
run("select-pane -t #{target(:pane => runner_pane)}") if exists('g:VimuxRunnerIndex')
run("copy-mode") call VimuxTmux('kill-'.VimuxOption('VimuxRunnerType').' -t '.g:VimuxRunnerIndex)
end unlet g:VimuxRunnerIndex
endif
endfunction
def current_panes function! VimuxTogglePane() abort
run('list-panes').split("\n").map do |line| if exists('g:VimuxRunnerIndex')
line.split(':').first if VimuxOption('VimuxRunnerType') ==# 'window'
end call VimuxTmux('join-pane -s '.g:VimuxRunnerIndex.' '.s:vimuxPaneOptions())
end 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 -s '.g:VimuxRunnerIndex." -P -F '#{window_id}'"),
\ '\n',
\ '',
\ ''
\)
let g:VimuxRunnerType = 'window'
endif
endif
endfunction
def active_pane_id function! VimuxZoomRunner() abort
run('list-panes').split("\n").map do |line| if exists('g:VimuxRunnerIndex')
return line.split[-2] if line =~ /\(active\)/ if VimuxOption('VimuxRunnerType') ==# 'pane'
end call VimuxTmux('resize-pane -Z -t '.g:VimuxRunnerIndex)
end elseif VimuxOption('VimuxRunnerType') ==# 'window'
call VimuxTmux('select-window -t '.g:VimuxRunnerIndex)
endif
endif
endfunction
def target(args={}) function! VimuxInspectRunner() abort
"#{args.fetch(:session, @session)}:#{args.fetch(:window, @window)}.#{args.fetch(:pane, @pane)}" call VimuxTmux('select-'.VimuxOption('VimuxRunnerType').' -t '.g:VimuxRunnerIndex)
end call VimuxTmux('copy-mode')
endfunction
def runner_pane function! VimuxScrollUpInspect() abort
if @runner_pane.nil? call VimuxInspectRunner()
run("split-window -p #{height}") call VimuxTmux('last-'.VimuxOption('VimuxRunnerType'))
@runner_pane = active_pane_id call VimuxSendKeys('C-u')
Vim.command("let g:_VimTmuxRunnerPane = '#{@runner_pane}'") endfunction
end
run('list-panes').split("\n").map do |line| function! VimuxScrollDownInspect() abort
return line.split(':').first if line =~ /#{@runner_pane}/ call VimuxInspectRunner()
end call VimuxTmux('last-'.VimuxOption('VimuxRunnerType'))
call VimuxSendKeys('C-d')
endfunction
@runner_pane = nil function! VimuxInterruptRunner() abort
clear_vim_cached_runner_pane call VimuxSendKeys('^c')
runner_pane endfunction
end
def interrupt_runner function! VimuxClearTerminalScreen() abort
run("send-keys -t #{target(:pane => runner_pane)} ^c") if exists('g:VimuxRunnerIndex')
end call VimuxSendKeys('C-l')
endif
endfunction
def run_shell_command(command) function! VimuxClearRunnerHistory() abort
send_command(command, target(:pane => runner_pane)) if exists('g:VimuxRunnerIndex')
move_up_pane call VimuxTmux('clear-history -t '.g:VimuxRunnerIndex)
end endif
endfunction
def close_other_panes function! VimuxPromptCommand(...) abort
# if run("list-panes").split("\n").length > 1 let command = a:0 ==# 1 ? a:1 : ''
run("kill-pane -a") if VimuxOption('VimuxCommandShell')
# end let l:command = input(VimuxOption('VimuxPromptString'), command, 'shellcmd')
end else
let l:command = input(VimuxOption('VimuxPromptString'), command)
endif
if VimuxOption('VimuxExpandCommand')
let l:command = join(map(split(l:command, ' '), 'expand(v:val)'), ' ')
endif
call VimuxRunCommand(l:command)
endfunction
def move_up_pane function! VimuxTmux(arguments) abort
run("select-pane -t #{target}") if VimuxOption('VimuxDebug')
end echom VimuxOption('VimuxTmuxCommand').' '.a:arguments
endif
if has_key(environ(), 'TMUX')
return system(VimuxOption('VimuxTmuxCommand').' '.a:arguments)
else
throw 'Aborting, because not inside tmux session.'
endif
endfunction
def send_command(command, target) function! s:tmuxSession() abort
run("send-keys -t #{target} '#{command.gsub("'", "\'")}'") return s:tmuxProperty('#S')
run("send-keys -t #{target} Enter") endfunction
end
def run(command) function! s:tmuxIndex() abort
`tmux #{command}` if VimuxOption('VimuxRunnerType') ==# 'pane'
end return s:tmuxPaneId()
else
return s:tmuxWindowId()
end end
endfunction
class CurrentTmuxSession < TmuxSession function! s:tmuxPaneId() abort
def initialize return s:tmuxProperty('#{pane_id}')
session = self.get_property(:attached, :session) endfunction
window = self.get_property(:active, :window)
pane = self.get_property(:active, :pane)
super(session, window, pane) function! s:tmuxWindowId() abort
end return s:tmuxProperty('#{window_id}')
endfunction
def get_property(match, type) function! s:vimuxPaneOptions() abort
run("list-#{type.to_s}").split("\n").each do |line| let height = VimuxOption('VimuxHeight')
return line.split(':').first if line =~ /\(#{match.to_s}\)/ let orientation = VimuxOption('VimuxOrientation')
end return '-l '.height.'% -'.orientation
end endfunction
end
EOF ""
" @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 ''
else
return s:nearestRunnerId()
endif
endif
" Try finding the runner using the provided query
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!
let runnerId = s:tmuxIndex()
if runnerId !=# currentId
" Success!
call VimuxTmux('last-'.runnerType)
return runnerId
endif
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-'.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 ''
endfunction
function! s:getTargetFilter() abort
let targetName = VimuxOption('VimuxRunnerName')
if targetName ==# ''
return ''
endif
let runnerType = VimuxOption('VimuxRunnerType')
if runnerType ==# 'window'
return " -f '#{==:#{window_name},".targetName."}'"
elseif runnerType ==# 'pane'
return " -f '#{==:#{pane_title},".targetName."}'"
endif
endfunction
function! s:setRunnerName() abort
let targetName = VimuxOption('VimuxRunnerName')
if targetName ==# ''
return
endif
let runnerType = VimuxOption('VimuxRunnerType')
if runnerType ==# 'window'
call VimuxTmux('rename-window '.targetName)
elseif runnerType ==# 'pane'
call VimuxTmux('select-pane -T '.targetName)
endif
endfunction
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)
endfunction
function! s:autoclose() abort
if VimuxOption('VimuxCloseOnExit')
call VimuxCloseRunner()
endif
endfunction