forked from Archives/vimux
Compare commits
237 Commits
Author | SHA1 | Date |
---|---|---|
spike | a62c16c8c3 | 2 years ago |
spike | 3c0a1708dc | 2 years ago |
Michael van der Kamp | 616fcb4799 | 2 years ago |
Michael van der Kamp | 2344b96fed | 2 years ago |
Michael van der Kamp | 076e13b77c | 2 years ago |
Michael van der Kamp | 740320b798 | 2 years ago |
Michael van der Kamp | 3daa0e91f0 | 2 years ago |
Matthias Bilger | 89604a4464 | 3 years ago |
Michael van der Kamp | 028897b6fb | 3 years ago |
Matthias Bilger | 031cc6208e | 3 years ago |
Samuel Walladge | 853646aef3 | 3 years ago |
Michael van der Kamp | 55a470dc0d | 3 years ago |
Michael van der Kamp | a1650d5f9b | 3 years ago |
John Bredall | ee0dfae330 | 3 years ago |
Caleb Maclennan | ee3075ad30 | 4 years ago |
Caleb Maclennan | 96a47f7895 | 4 years ago |
Caleb Maclennan | 708ce200d5 | 4 years ago |
jaspertandy | a70218b30c | 4 years ago |
jaspertandy | 59b1d28f80 | 4 years ago |
jaspertandy | 784b2834c7 | 4 years ago |
Caleb Maclennan | 29d46f6bc1 | 4 years ago |
Michael van der Kamp | 7d977a2954 | 4 years ago |
Michael van der Kamp | c4adf57f6e | 4 years ago |
Michael van der Kamp | 54d24d1694 | 4 years ago |
Gerhard Hellmann | 5b1791673c | 4 years ago |
Caleb Maclennan | 3bfe0ea285 | 4 years ago |
Caleb Maclennan | 9dd1b68b59 | 4 years ago |
Caleb Maclennan | f02fa9c161 | 4 years ago |
Caleb Maclennan | fb43fcbc16 | 4 years ago |
Caleb Maclennan | 1b38911c40 | 4 years ago |
Caleb Maclennan | 9214bf9578 | 4 years ago |
Caleb Maclennan | f293536dd5 | 4 years ago |
Caleb Maclennan | f1c27deeaa | 4 years ago |
Caleb Maclennan | cac9d11158 | 4 years ago |
Caleb Maclennan | 8cc4fe9678 | 4 years ago |
Caleb Maclennan | f4df4c9b5b | 4 years ago |
Caleb Maclennan | 29c5b39545 | 4 years ago |
Caleb Maclennan | 576b24c7a0 | 4 years ago |
Caleb Maclennan | 992d525ef9 | 4 years ago |
Caleb Maclennan | 566833e291 | 4 years ago |
Caleb Maclennan | 43681e9f91 | 4 years ago |
Caleb Maclennan | 601749152e | 4 years ago |
Michael van der Kamp | b13568ea1b | 4 years ago |
Michael van der Kamp | 748b54b885 | 4 years ago |
Caleb Maclennan | 5f999f4dc4 | 4 years ago |
Caleb Maclennan | 3a1aad8752 | 4 years ago |
Caleb Maclennan | a2ab8880a1 | 4 years ago |
Caleb Maclennan | ed12df373a | 4 years ago |
Caleb Maclennan | efe04f05dc | 4 years ago |
Caleb Maclennan | 486ac1bd6e | 4 years ago |
Caleb Maclennan | 0e3ebca98b | 4 years ago |
Caleb Maclennan | bde8b4cb37 | 4 years ago |
Caleb Maclennan | c212352f93 | 4 years ago |
Caleb Maclennan | f589e21472 | 4 years ago |
Caleb Maclennan | a5a17b8e32 | 4 years ago |
Caleb Maclennan | e6fb662bf1 | 4 years ago |
Caleb Maclennan | 925ae23b42 | 4 years ago |
Matthias Bilger | 3693ec6f12 | 4 years ago |
Matthias Bilger | af602e362d | 4 years ago |
Caleb Maclennan | 0f5fd2ce49 | 4 years ago |
Thales Mello | 57bbdc4478 | 4 years ago |
Caleb Maclennan | cce8466613 | 4 years ago |
Caleb Maclennan | 71f28c8296 | 4 years ago |
Caleb Maclennan | 48b541b1a4 | 4 years ago |
Philipp Moers | ef5622f225 | 4 years ago |
Caleb Maclennan | 7f15726b07 | 4 years ago |
Caleb Maclennan | 9c05307141 | 4 years ago |
Giuseppe Rota | 46377b8ab9 | 4 years ago |
Thomas Mayfield | 8fa6ca92c0 | 4 years ago |
Eugene Yunak | 1dec7164ca | 4 years ago |
saubhik | fff2f1a686 | 4 years ago |
Eugene Yunak | f48360cea6 | 4 years ago |
Jonathan Barratt | 02315b02c4 | 4 years ago |
Michael vanderKamp | 67bd945586 | 5 years ago |
Michael vanderKamp | 556a2d692b | 5 years ago |
Michael vanderKamp | 3fdafcfd60 | 5 years ago |
Ben Mills | 37f41195e6 | 7 years ago |
Tye Wang | 020a5eed02 | 7 years ago |
Leandro Ostera | 1adbef72d2 | 7 years ago |
Leandro Ostera | 212a34e5f9 | 7 years ago |
Alphonse Mariyagnanaseelan | 198c8ea8ca | 7 years ago |
Oskar Laska | 9c3195a0be | 7 years ago |
lyuts | 9f81329f60 | 7 years ago |
lyuts | 0a560ba419 | 7 years ago |
Leandro Ostera | ca96cac46b | 7 years ago |
Leandro Ostera | edc24ff4d3 | 7 years ago |
Leandro Ostera | f3a919e86f | 7 years ago |
Alberto De Lucca | 8cb0416401 | 7 years ago |
Filype Pereira | bbe6a597cd | 8 years ago |
lingceng | 1b847e6d6a | 8 years ago |
Ben Mills | 2285cefee9 | 9 years ago |
Paul Gross | 1b9db6392f | 9 years ago |
Ben Mills | 1d652fdc0c | 9 years ago |
everbot | 770ae77092 | 9 years ago |
Ben Mills | bc11e401f1 | 9 years ago |
Ben Mills | 5e760def05 | 9 years ago |
Ben Mills | 40d9f74db6 | 9 years ago |
Joakim Bergman | 8c332d9919 | 9 years ago |
Ben Mills | 21d7a34172 | 9 years ago |
John Downey | 4153ba4987 | 9 years ago |
Pete Yandell | 863e813928 | 9 years ago |
Ben Mills | a1db73079f | 10 years ago |
Pawel Palucki | 70e16b73f5 | 10 years ago |
Bob Nadler | 24e9d354a4 | 10 years ago |
Ben Mills | a991ce8abd | 10 years ago |
Hendrik Purmann | 7b655a7b5c | 10 years ago |
Ben Mills | 50254fad43 | 10 years ago |
Hendrik Purmann | 01c0679223 | 10 years ago |
Ben Mills | be6b83cfa4 | 10 years ago |
Melissa Xie | d21337e01a | 10 years ago |
Ben Mills | c56e3f79e1 | 10 years ago |
Matthias Bilger | 5a530ca8e4 | 10 years ago |
Matthias Bilger | a772fce3e2 | 10 years ago |
Matthias Bilger | d78cd0f8e1 | 10 years ago |
kavinderd | ab6941c2c5 | 10 years ago |
Ben Mills | 1c3ca9e267 | 10 years ago |
Teoric | e5a9eb74da | 10 years ago |
teoric | 3135ab5e30 | 10 years ago |
teoric | b437d32c1b | 10 years ago |
teoric | b60a52d36c | 10 years ago |
Ben Mills | fbb873a265 | 11 years ago |
Alex Ozer | 54858144f9 | 11 years ago |
Ben Mills | cf6b8c08db | 11 years ago |
Ben Mills | a04b07992d | 11 years ago |
Alex Ozer | 6594afdcd0 | 11 years ago |
Alex Ozer | 905e002c81 | 11 years ago |
Ben Mills | 4cea1a1b84 | 11 years ago |
Ben Mills | cae215041d | 11 years ago |
Ben Mills | 602b2bc39c | 11 years ago |
LIU Yang | 3f3ef11f40 | 11 years ago |
Nate Jones | d306d43a59 | 11 years ago |
Ton van den Heuvel | 8ff22883bd | 11 years ago |
Josh Davis | 94b8b938b2 | 11 years ago |
Josh Davis | 17358e51ab | 11 years ago |
Josh Davis | ba2b2050b0 | 11 years ago |
Josh Davis | ff54646761 | 11 years ago |
Ben Mills | efa6a9aa4b | 11 years ago |
Ben Mills | dfe4fa0b9e | 11 years ago |
Kevin Sjöberg | 9855936bd1 | 11 years ago |
Ben Mills | 2e9b00b276 | 11 years ago |
Aaron Spiegel | e7c2413f30 | 11 years ago |
Ben Mills | f56788990d | 11 years ago |
Ben Mills | 1e30ed8065 | 11 years ago |
Ben Mills | 6a7fcccb6b | 11 years ago |
Ben Mills | 40e93b511f | 11 years ago |
Ben Mills | 53477b16c9 | 11 years ago |
Larry Lv | a74b089c92 | 11 years ago |
Ben Mills | 6fb5977ef7 | 11 years ago |
daniely | 3cada36538 | 11 years ago |
Ryan Glover | 7212ae4ee8 | 11 years ago |
Ryan Glover | aa8a444609 | 11 years ago |
Ryan Glover | 49a048e94e | 11 years ago |
cmar | 635b800f22 | 11 years ago |
Ben Mills | be0a60ec70 | 11 years ago |
Ben Mills | 0228508f54 | 11 years ago |
Ben Mills | 42772b79d3 | 11 years ago |
Jason Bellamy | 71b2ac31de | 11 years ago |
David Davis | 1a0a8abe71 | 11 years ago |
Ben Mills | 70433ed91b | 11 years ago |
benmills | 7c54b7af6a | 11 years ago |
benmills | 064ca8693a | 11 years ago |
Ben Mills | d99e30cc9b | 12 years ago |
Ben Mills | 6dd26fe7c3 | 12 years ago |
Anyakichi | b409314c80 | 12 years ago |
Ben Mills | 3f930159a2 | 12 years ago |
Fabio M. Costa | a6889b4bf4 | 12 years ago |
benmills | 6e909a2439 | 12 years ago |
benmills | 173fcda85d | 12 years ago |
benmills | e729607de6 | 12 years ago |
Ben Mills | 35c54c0801 | 12 years ago |
Jingwen Owen Ou | e5602b90a5 | 12 years ago |
Ben Mills | 63ad5424d8 | 12 years ago |
Reza Jelveh | 8e091d6d5e | 12 years ago |
Reza Jelveh | 51ee1a3c6d | 12 years ago |
Ben Mills | 9a410c5158 | 12 years ago |
Chip Castle | 46634b7bf7 | 12 years ago |
Ben Mills | eab15dc06e | 12 years ago |
Ben Mills | 81426978b4 | 12 years ago |
tonyskn | 06d75cb797 | 12 years ago |
benmills | d6d88a4fce | 12 years ago |
Ben Mills | 56bcbb0a5f | 12 years ago |
Brian Riddle | 8fb2563918 | 12 years ago |
Ben Mills | c4eccfcaff | 12 years ago |
John Krueger | dd1c213e4d | 12 years ago |
John Krueger | 201964f046 | 12 years ago |
Ben Mills | d6eb9e5f04 | 12 years ago |
benmills | 908358a09a | 12 years ago |
Ben Mills | c5216bb345 | 12 years ago |
Andy Lindeman | e0146a05fd | 12 years ago |
Ben Mills | ea99609f56 | 12 years ago |
benmills | 4f13e27deb | 12 years ago |
Ben Mills | a221eb2f79 | 12 years ago |
Andrew Stiles | 539580e5fe | 12 years ago |
Ben Mills | dc4a45dcbf | 12 years ago |
Matt Rohrer | 4a8e31f8b9 | 12 years ago |
Ben Mills | 6b8d484dfe | 12 years ago |
Ben Mills | 81b73a9639 | 12 years ago |
Evan Light | 9a0739b117 | 12 years ago |
Evan Light | e4da4bb5f8 | 12 years ago |
Ben Mills | ffc2185cb9 | 12 years ago |
benmills | f476177ad1 | 12 years ago |
benmills | a91e177801 | 12 years ago |
benmills | 0eefeff876 | 12 years ago |
Ben Mills | 90129466fa | 12 years ago |
Stefan Otte | 8402015a9e | 12 years ago |
Stefan Otte | ec898ca9b5 | 12 years ago |
Stefan Otte | 642ea420ba | 12 years ago |
Stefan Otte | dbdee1c224 | 13 years ago |
Stefan Otte | 1bc5f5ba85 | 13 years ago |
benmills | 8a20aec379 | 13 years ago |
Ben Mills | 346f67906c | 13 years ago |
Ben Mills | 7f65c9c3aa | 13 years ago |
Stefan Otte | c57660b8ad | 13 years ago |
Stefan Otte | 0cf661c5f4 | 13 years ago |
Ben Mills | 39678261e9 | 13 years ago |
tonyskn | 597581715c | 13 years ago |
benmills | c853343e6f | 13 years ago |
benmills | 06ba414a32 | 13 years ago |
benmills | b9684aa6d8 | 13 years ago |
benmills | e925b0e127 | 13 years ago |
Ben Mills | 252693ec57 | 13 years ago |
Joshua Antonishen | de99c54046 | 13 years ago |
Joshua Antonishen | 62ded6f281 | 13 years ago |
Ben Mills | f0bdd95be3 | 13 years ago |
Oscar Del Ben | 4f90d43915 | 13 years ago |
Ben Mills | d75780aa84 | 13 years ago |
benmills | 64a5ebe875 | 13 years ago |
Oscar Del Ben | 55f6c1f393 | 13 years ago |
benmills | 96df08933a | 13 years ago |
benmills | aeb965ce13 | 13 years ago |
benmills | 359fb925b7 | 13 years ago |
benmills | c4a0836dfa | 13 years ago |
Ben Mills | d189f2b99c | 13 years ago |
Ben Mills | 3628c358be | 13 years ago |
Paul Gross | c6e564aaa4 | 13 years ago |
Paul Gross | 0eba4c252b | 13 years ago |
Paul Gross | 9029bcd870 | 13 years ago |
@ -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)"
|
@ -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
|
@ -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 .
|
@ -0,0 +1 @@
|
||||
doc/tags
|
@ -0,0 +1,5 @@
|
||||
cmdargs:
|
||||
severity: style_problem
|
||||
color: true
|
||||
env:
|
||||
neovim: false
|
@ -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.
|
@ -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
|
@ -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
|
@ -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:
|
@ -1,169 +1,321 @@
|
||||
if !has("ruby")
|
||||
if exists('g:loaded_vimux') || &compatible
|
||||
finish
|
||||
end
|
||||
endif
|
||||
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: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: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! VimuxOption(name) abort
|
||||
return get(b:, a:name, get(g:, a:name))
|
||||
endfunction
|
||||
|
||||
if !executable(VimuxOption('VimuxTmuxCommand'))
|
||||
echohl ErrorMsg | echomsg 'Failed to find executable '.VimuxOption('VimuxTmuxCommand') | echohl None
|
||||
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()
|
||||
|
||||
command RunLastVimTmuxCommand :call RunLastVimTmuxCommand()
|
||||
command CloseVimTmuxPanes :call CloseVimTmuxPanes()
|
||||
command CloseVimTmuxWindows :call CloseVimTmuxWindows()
|
||||
command InspectVimTmuxRunner :call InspectVimTmuxRunner()
|
||||
command InterruptVimTmuxRunner :call InterruptVimTmuxRunner()
|
||||
command PromptVimTmuxCommand :call PromptVimTmuxCommand()
|
||||
augroup VimuxAutocmds
|
||||
au!
|
||||
autocmd VimLeave * call s:autoclose()
|
||||
augroup END
|
||||
|
||||
function! RunVimTmuxCommand(command)
|
||||
let g:_VimTmuxCmd = a:command
|
||||
ruby CurrentTmuxSession.new.run_shell_command(Vim.evaluate("g:_VimTmuxCmd"))
|
||||
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! RunLastVimTmuxCommand()
|
||||
if exists("g:_VimTmuxCmd")
|
||||
ruby CurrentTmuxSession.new.run_shell_command(Vim.evaluate("g:_VimTmuxCmd"))
|
||||
function! VimuxRunLastCommand() abort
|
||||
if exists('g:VimuxLastCommand')
|
||||
call VimuxRunCommand(g:VimuxLastCommand)
|
||||
else
|
||||
echo "No last command"
|
||||
echo 'No last vimux command.'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! ClearVimTmuxWindow()
|
||||
if exists("g:_VimTmuxRunnerPane")
|
||||
unlet g:_VimTmuxRunnerPane
|
||||
end
|
||||
function! VimuxRunCommand(command, ...) abort
|
||||
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('VimuxResetSequence')
|
||||
let g:VimuxLastCommand = a:command
|
||||
call VimuxSendKeys(resetSequence)
|
||||
call VimuxSendText(a:command)
|
||||
if l:autoreturn ==# 1
|
||||
call VimuxSendKeys('Enter')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! CloseVimTmuxWindows()
|
||||
ruby CurrentTmuxSession.new.close_other_panes
|
||||
call ClearVimTmuxWindow()
|
||||
echoerr "CloseVimTmuxWindows is deprecated, use CloseVimTmuxPanes"
|
||||
function! VimuxSendText(text) abort
|
||||
call VimuxSendKeys(shellescape(substitute(a:text, '\n$', ' ', '')))
|
||||
endfunction
|
||||
|
||||
function! CloseVimTmuxPanes()
|
||||
ruby CurrentTmuxSession.new.close_other_panes
|
||||
call ClearVimTmuxWindow()
|
||||
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
|
||||
endfunction
|
||||
|
||||
function! InterruptVimTmuxRunner()
|
||||
ruby CurrentTmuxSession.new.interrupt_runner
|
||||
function! VimuxOpenRunner() abort
|
||||
let existingId = s:existingRunnerId()
|
||||
if existingId !=# ''
|
||||
let g:VimuxRunnerIndex = existingId
|
||||
else
|
||||
let extraArguments = VimuxOption('VimuxOpenExtraArgs')
|
||||
if VimuxOption('VimuxRunnerType') ==# 'pane'
|
||||
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
|
||||
|
||||
function! InspectVimTmuxRunner()
|
||||
ruby CurrentTmuxSession.new.inspect_runner
|
||||
function! VimuxCloseRunner() abort
|
||||
if exists('g:VimuxRunnerIndex')
|
||||
call VimuxTmux('kill-'.VimuxOption('VimuxRunnerType').' -t '.g:VimuxRunnerIndex)
|
||||
unlet g:VimuxRunnerIndex
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! PromptVimTmuxCommand()
|
||||
let l:command = input("Command? ")
|
||||
call RunVimTmuxCommand(l:command)
|
||||
function! VimuxTogglePane() abort
|
||||
if exists('g:VimuxRunnerIndex')
|
||||
if VimuxOption('VimuxRunnerType') ==# 'window'
|
||||
call VimuxTmux('join-pane -s '.g:VimuxRunnerIndex.' '.s:vimuxPaneOptions())
|
||||
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
|
||||
|
||||
ruby << EOF
|
||||
class TmuxSession
|
||||
def initialize(session, window, pane)
|
||||
@session = session
|
||||
@window = window
|
||||
@pane = pane
|
||||
@runner_pane = vim_cached_runner_pane
|
||||
end
|
||||
function! VimuxZoomRunner() abort
|
||||
if exists('g:VimuxRunnerIndex')
|
||||
if VimuxOption('VimuxRunnerType') ==# 'pane'
|
||||
call VimuxTmux('resize-pane -Z -t '.g:VimuxRunnerIndex)
|
||||
elseif VimuxOption('VimuxRunnerType') ==# 'window'
|
||||
call VimuxTmux('select-window -t '.g:VimuxRunnerIndex)
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
def vim_cached_runner_pane
|
||||
if Vim.evaluate('exists("g:_VimTmuxRunnerPane")') != 0
|
||||
Vim.evaluate('g:_VimTmuxRunnerPane')
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
function! VimuxInspectRunner() abort
|
||||
call VimuxTmux('select-'.VimuxOption('VimuxRunnerType').' -t '.g:VimuxRunnerIndex)
|
||||
call VimuxTmux('copy-mode')
|
||||
endfunction
|
||||
|
||||
def vim_cached_runner_pane=(runner_pane)
|
||||
Vim.command("let g:_VimTmuxRunnerPane = '#{runner_pane}'")
|
||||
end
|
||||
function! VimuxScrollUpInspect() abort
|
||||
call VimuxInspectRunner()
|
||||
call VimuxTmux('last-'.VimuxOption('VimuxRunnerType'))
|
||||
call VimuxSendKeys('C-u')
|
||||
endfunction
|
||||
|
||||
def clear_vim_cached_runner_pane
|
||||
Vim.command("unlet g:_VimTmuxRunnerPane")
|
||||
end
|
||||
function! VimuxScrollDownInspect() abort
|
||||
call VimuxInspectRunner()
|
||||
call VimuxTmux('last-'.VimuxOption('VimuxRunnerType'))
|
||||
call VimuxSendKeys('C-d')
|
||||
endfunction
|
||||
|
||||
def height
|
||||
if Vim.evaluate('exists("g:VimuxHeight")') != 0
|
||||
Vim.evaluate('g:VimuxHeight')
|
||||
else
|
||||
20
|
||||
end
|
||||
end
|
||||
function! VimuxInterruptRunner() abort
|
||||
call VimuxSendKeys('^c')
|
||||
endfunction
|
||||
|
||||
def inspect_runner
|
||||
run("select-pane -t #{target(:pane => runner_pane)}")
|
||||
run("copy-mode")
|
||||
end
|
||||
function! VimuxClearTerminalScreen() abort
|
||||
if exists('g:VimuxRunnerIndex')
|
||||
call VimuxSendKeys('C-l')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
def current_panes
|
||||
run('list-panes').split("\n").map do |line|
|
||||
line.split(':').first
|
||||
end
|
||||
end
|
||||
function! VimuxClearRunnerHistory() abort
|
||||
if exists('g:VimuxRunnerIndex')
|
||||
call VimuxTmux('clear-history -t '.g:VimuxRunnerIndex)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
def active_pane_id
|
||||
run('list-panes').split("\n").map do |line|
|
||||
return line.split[-2] if line =~ /\(active\)/
|
||||
end
|
||||
end
|
||||
function! VimuxPromptCommand(...) abort
|
||||
let command = a:0 ==# 1 ? a:1 : ''
|
||||
if VimuxOption('VimuxCommandShell')
|
||||
let l:command = input(VimuxOption('VimuxPromptString'), command, 'shellcmd')
|
||||
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 target(args={})
|
||||
"#{args.fetch(:session, @session)}:#{args.fetch(:window, @window)}.#{args.fetch(:pane, @pane)}"
|
||||
end
|
||||
function! VimuxTmux(arguments) abort
|
||||
if VimuxOption('VimuxDebug')
|
||||
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 runner_pane
|
||||
if @runner_pane.nil?
|
||||
run("split-window -p #{height}")
|
||||
@runner_pane = active_pane_id
|
||||
Vim.command("let g:_VimTmuxRunnerPane = '#{@runner_pane}'")
|
||||
end
|
||||
function! s:tmuxSession() abort
|
||||
return s:tmuxProperty('#S')
|
||||
endfunction
|
||||
|
||||
run('list-panes').split("\n").map do |line|
|
||||
return line.split(':').first if line =~ /#{@runner_pane}/
|
||||
function! s:tmuxIndex() abort
|
||||
if VimuxOption('VimuxRunnerType') ==# 'pane'
|
||||
return s:tmuxPaneId()
|
||||
else
|
||||
return s:tmuxWindowId()
|
||||
end
|
||||
endfunction
|
||||
|
||||
@runner_pane = nil
|
||||
clear_vim_cached_runner_pane
|
||||
runner_pane
|
||||
end
|
||||
function! s:tmuxPaneId() abort
|
||||
return s:tmuxProperty('#{pane_id}')
|
||||
endfunction
|
||||
|
||||
def interrupt_runner
|
||||
run("send-keys -t #{target(:pane => runner_pane)} ^c")
|
||||
end
|
||||
function! s:tmuxWindowId() abort
|
||||
return s:tmuxProperty('#{window_id}')
|
||||
endfunction
|
||||
|
||||
def run_shell_command(command)
|
||||
send_command(command, target(:pane => runner_pane))
|
||||
move_up_pane
|
||||
end
|
||||
function! s:vimuxPaneOptions() abort
|
||||
let height = VimuxOption('VimuxHeight')
|
||||
let orientation = VimuxOption('VimuxOrientation')
|
||||
return '-l '.height.'% -'.orientation
|
||||
endfunction
|
||||
|
||||
def close_other_panes
|
||||
# if run("list-panes").split("\n").length > 1
|
||||
run("kill-pane -a")
|
||||
# end
|
||||
end
|
||||
""
|
||||
" @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
|
||||
|
||||
def move_up_pane
|
||||
run("select-pane -t #{target}")
|
||||
end
|
||||
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
|
||||
|
||||
def send_command(command, target)
|
||||
run("send-keys -t #{target} '#{command.gsub("'", "\'")}'")
|
||||
run("send-keys -t #{target} Enter")
|
||||
end
|
||||
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
|
||||
|
||||
def run(command)
|
||||
`tmux #{command}`
|
||||
end
|
||||
end
|
||||
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
|
||||
|
||||
class CurrentTmuxSession < TmuxSession
|
||||
def initialize
|
||||
session = self.get_property(:attached, :session)
|
||||
window = self.get_property(:active, :window)
|
||||
pane = self.get_property(:active, :pane)
|
||||
function! s:tmuxProperty(property) abort
|
||||
return substitute(VimuxTmux("display -p '".a:property."'"), '\n$', '', '')
|
||||
endfunction
|
||||
|
||||
super(session, window, pane)
|
||||
end
|
||||
function! s:hasRunner(index) abort
|
||||
let runnerType = VimuxOption('VimuxRunnerType')
|
||||
return match(VimuxTmux('list-'.runnerType."s -F '#{".runnerType."_id}'"), a:index)
|
||||
endfunction
|
||||
|
||||
def get_property(match, type)
|
||||
run("list-#{type.to_s}").split("\n").each do |line|
|
||||
return line.split(':').first if line =~ /\(#{match.to_s}\)/
|
||||
end
|
||||
end
|
||||
end
|
||||
EOF
|
||||
function! s:autoclose() abort
|
||||
if VimuxOption('VimuxCloseOnExit')
|
||||
call VimuxCloseRunner()
|
||||
endif
|
||||
endfunction
|
||||
|
Loading…
Reference in New Issue