I broke up with neovim....vim is my best friend now
This commit is contained in:
21
dot_vim/bundle/vimux.git/LICENSE
Normal file
21
dot_vim/bundle/vimux.git/LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2103 Benjamin Mills
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
38
dot_vim/bundle/vimux.git/README.mkd
Normal file
38
dot_vim/bundle/vimux.git/README.mkd
Normal file
@@ -0,0 +1,38 @@
|
||||
# vimux
|
||||
|
||||
Easily interact with tmux from vim.
|
||||
|
||||

|
||||
|
||||
What inspired me to write vimux was [tslime.vim](https://github.com/kikijump/tslime.vim), a plugin that lets you send input to tmux. While tslime.vim works well, I felt it wasn't optimized for my primary use case which was having a smaller tmux pane that I would use to run tests or play with a REPL.
|
||||
|
||||
My goal with vimux is to make interacting with tmux from vim effortless. By default when you call `VimuxRunCommand` vimux will create a 20% tall horizontal pane under your current tmux pane and execute a command in it without losing focus of vim. Once that pane exists whenever you call `VimuxRunCommand` again the command will be executed in that pane. As I was using vimux myself I wanted to rerun commands over and over. An example of this was running the current file through rspec. Rather than typing that over and over I wrote `VimuxRunLastCommand` that will execute the last command you called with `VimuxRunCommand`.
|
||||
|
||||
Other auxiliary functions and the ones I talked about above can be found bellow with a full description and example key binds for your vimrc.
|
||||
|
||||
## Installation
|
||||
|
||||
With **[vim-bundle](https://github.com/benmills/vim-bundle)**: `vim-bundle install benmills/vimux`
|
||||
With **[Vundle](https://github.com/gmarik/Vundle.vim)**: 'Plugin benmills/vimux' in your .vimrc
|
||||
|
||||
Otherwise download the latest [tarball](https://github.com/benmills/vimux/tarball/master), extract it and move `plugin/vimux.vim` inside `~/.vim/plugin`. If you're using [pathogen](https://github.com/tpope/vim-pathogen), then move the entire folder extracted from the tarball into `~/.vim/bundle`.
|
||||
|
||||
_Notes:_
|
||||
|
||||
* Vimux assumes a tmux version >= 1.5. Some older versions might work but it is recommeded to use at least version 1.5.
|
||||
|
||||
## Platform-specific Plugins
|
||||
|
||||
* [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
|
||||
|
||||
## Usage
|
||||
|
||||
The full documentation is available [online](https://raw.github.com/benmills/vimux/master/doc/vimux.txt) and accessible inside vim `:help vimux`
|
||||
355
dot_vim/bundle/vimux.git/doc/vimux.txt
Normal file
355
dot_vim/bundle/vimux.git/doc/vimux.txt
Normal file
@@ -0,0 +1,355 @@
|
||||
*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 .............................. |VimuxClearRunnerHistory|
|
||||
2.7 .............................. |VimuxZoomRunner|
|
||||
2.8 .............................. |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.
|
||||
|
||||
What inspired me to write vimux was tslime.vim [1], a plugin that lets you
|
||||
send input to tmux. While tslime.vim works well, I felt it wasn't optimized
|
||||
for my primary use case which was having a smaller tmux pane that I would use
|
||||
to run tests or play with a REPL.
|
||||
|
||||
My goal with vimux is to make interacting with tmux from vim effortless. By
|
||||
default when you call `VimuxRunCommand` vimux will create a 20% tall
|
||||
horizontal pane under your current tmux pane and execute a command in it
|
||||
without losing focus of vim. Once that pane exists whenever you call
|
||||
`VimuxRunCommand` again the command will be executed in that pane. As I was
|
||||
using vimux myself I wanted to rerun commands over and over. An example of
|
||||
this was running the current file through rspec. Rather than typing that over
|
||||
and over I wrote `VimuxRunLastCommand` that will execute the last command
|
||||
you called with `VimuxRunCommand`.
|
||||
|
||||
Other auxiliary functions and the ones I talked about above can be found
|
||||
bellow with a full description and example key binds for your vimrc.
|
||||
|
||||
[1] https://github.com/kikijump/tslime.vim
|
||||
|
||||
|
||||
==============================================================================
|
||||
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|
|
||||
- |VimuxOpenPane|
|
||||
- |VimuxRunLastCommand|
|
||||
- |VimuxCloseRunner|
|
||||
- |VimuxInspectRunner|
|
||||
- |VimuxInterruptRunner|
|
||||
- |VimuxPromptCommand|
|
||||
- |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 runer pane. This command will not open a new pane if one
|
||||
does not already exist. You will need to use VimuxOpenPane to do this. This
|
||||
command can be used to interact with REPLs or other interactive terminal
|
||||
programs that are not shells.
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*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 VimuxOpenPane to do this. You can
|
||||
use this command to send keys such as "Enter" or "C-c" to the runner pane.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*VimuxOpenPane*
|
||||
VimuxOpenPane~
|
||||
|
||||
This will either open a new pane or use the nearest pane and set it as the
|
||||
vimux runner pane for the other vimux commands. You can control if this command
|
||||
uses the nearest pane or always creates a new one with g: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>
|
||||
<
|
||||
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*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>
|
||||
>
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*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 VimuxSendText(@v)
|
||||
call VimuxSendKeys("Enter")
|
||||
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 like this:
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*VimuxConfiguration_height*
|
||||
2.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*
|
||||
2.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*
|
||||
2.3 g:VimuxUseNearest
|
||||
|
||||
Use exising pane or window (not used by vim) if found instead of running
|
||||
split-window.
|
||||
|
||||
let VimuxUseNearest = 1
|
||||
|
||||
Default: 1
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*VimuxConfiguration_reset_sequence*
|
||||
2.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 VimuxResetSequence = ""
|
||||
|
||||
Default: "q C-u"
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*VimuxPromptString*
|
||||
2.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*
|
||||
2.6 g:VimuxRunnerType~
|
||||
|
||||
The type of view object Vimux should use for the runner. For reference, a
|
||||
tmux session is a group of windows, and a window is a layout of panes.
|
||||
|
||||
let g:VimuxRunnerType = "window"
|
||||
|
||||
Options:
|
||||
"pane": for panes
|
||||
"window": for windows
|
||||
|
||||
Default: "pane"
|
||||
|
||||
==============================================================================
|
||||
vim:tw=78:ts=2:sw=2:expandtab:ft=help:norl:
|
||||
1
dot_vim/bundle/vimux.git/dot_gitignore
Normal file
1
dot_vim/bundle/vimux.git/dot_gitignore
Normal file
@@ -0,0 +1 @@
|
||||
doc/tags
|
||||
198
dot_vim/bundle/vimux.git/plugin/vimux.vim
Normal file
198
dot_vim/bundle/vimux.git/plugin/vimux.vim
Normal file
@@ -0,0 +1,198 @@
|
||||
if exists("g:loaded_vimux") || &cp
|
||||
finish
|
||||
endif
|
||||
let g:loaded_vimux = 1
|
||||
|
||||
command -nargs=* VimuxRunCommand :call VimuxRunCommand(<args>)
|
||||
command VimuxRunLastCommand :call VimuxRunLastCommand()
|
||||
command VimuxCloseRunner :call VimuxCloseRunner()
|
||||
command VimuxZoomRunner :call VimuxZoomRunner()
|
||||
command VimuxInspectRunner :call VimuxInspectRunner()
|
||||
command VimuxScrollUpInspect :call VimuxScrollUpInspect()
|
||||
command VimuxScrollDownInspect :call VimuxScrollDownInspect()
|
||||
command VimuxInterruptRunner :call VimuxInterruptRunner()
|
||||
command -nargs=? VimuxPromptCommand :call VimuxPromptCommand(<args>)
|
||||
command VimuxClearRunnerHistory :call VimuxClearRunnerHistory()
|
||||
command VimuxTogglePane :call VimuxTogglePane()
|
||||
|
||||
function! VimuxRunCommandInDir(command, useFile)
|
||||
let l:file = ""
|
||||
if a:useFile ==# 1
|
||||
let l:file = shellescape(expand('%:t'), 1)
|
||||
endif
|
||||
call VimuxRunCommand("cd ".shellescape(expand('%:p:h'), 1)." && ".a:command." ".l:file." && cd - > /dev/null")
|
||||
endfunction
|
||||
|
||||
function! VimuxRunLastCommand()
|
||||
if exists("g:VimuxRunnerIndex")
|
||||
call VimuxRunCommand(g:VimuxLastCommand)
|
||||
else
|
||||
echo "No last vimux command."
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! VimuxRunCommand(command, ...)
|
||||
if !exists("g:VimuxRunnerIndex") || _VimuxHasRunner(g:VimuxRunnerIndex) == -1
|
||||
call VimuxOpenRunner()
|
||||
endif
|
||||
|
||||
let l:autoreturn = 1
|
||||
if exists("a:1")
|
||||
let l:autoreturn = a:1
|
||||
endif
|
||||
|
||||
let resetSequence = _VimuxOption("g:VimuxResetSequence", "q C-u")
|
||||
let g:VimuxLastCommand = a:command
|
||||
|
||||
call VimuxSendKeys(resetSequence)
|
||||
call VimuxSendText(a:command)
|
||||
|
||||
if l:autoreturn == 1
|
||||
call VimuxSendKeys("Enter")
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! VimuxSendText(text)
|
||||
call VimuxSendKeys('"'.escape(a:text, '"$').'"')
|
||||
endfunction
|
||||
|
||||
function! VimuxSendKeys(keys)
|
||||
if exists("g:VimuxRunnerIndex")
|
||||
call system("tmux send-keys -t ".g:VimuxRunnerIndex." ".a:keys)
|
||||
else
|
||||
echo "No vimux runner pane/window. Create one with VimuxOpenRunner"
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! VimuxOpenRunner()
|
||||
let nearestIndex = _VimuxNearestIndex()
|
||||
|
||||
if _VimuxOption("g:VimuxUseNearest", 1) == 1 && nearestIndex != -1
|
||||
let g:VimuxRunnerIndex = nearestIndex
|
||||
else
|
||||
if _VimuxRunnerType() == "pane"
|
||||
let height = _VimuxOption("g:VimuxHeight", 20)
|
||||
let orientation = _VimuxOption("g:VimuxOrientation", "v")
|
||||
call system("tmux split-window -p ".height." -".orientation)
|
||||
elseif _VimuxRunnerType() == "window"
|
||||
call system("tmux new-window")
|
||||
endif
|
||||
|
||||
let g:VimuxRunnerIndex = _VimuxTmuxIndex()
|
||||
call system("tmux last-"._VimuxRunnerType())
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! VimuxCloseRunner()
|
||||
if exists("g:VimuxRunnerIndex")
|
||||
call system("tmux kill-"._VimuxRunnerType()." -t ".g:VimuxRunnerIndex)
|
||||
unlet g:VimuxRunnerIndex
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! VimuxTogglePane()
|
||||
if exists("g:VimuxRunnerIndex")
|
||||
if _VimuxRunnerType() == "window"
|
||||
call system("tmux join-pane -d -s ".g:VimuxRunnerIndex." -p "._VimuxOption("g:VimuxHeight", 20))
|
||||
let g:VimuxRunnerType = "pane"
|
||||
elseif _VimuxRunnerType() == "pane"
|
||||
let g:VimuxRunnerIndex=substitute(system("tmux break-pane -d -t ".g:VimuxRunnerIndex." -P -F '#{window_index}'"), "\n", "", "")
|
||||
let g:VimuxRunnerType = "window"
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! VimuxZoomRunner()
|
||||
if exists("g:VimuxRunnerIndex")
|
||||
if _VimuxRunnerType() == "pane"
|
||||
call system("tmux resize-pane -Z -t ".g:VimuxRunnerIndex)
|
||||
elseif _VimuxRunnerType() == "window"
|
||||
call system("tmux select-window -t ".g:VimuxRunnerIndex)
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! VimuxInspectRunner()
|
||||
call system("tmux select-"._VimuxRunnerType()." -t ".g:VimuxRunnerIndex)
|
||||
call system("tmux copy-mode")
|
||||
endfunction
|
||||
|
||||
function! VimuxScrollUpInspect()
|
||||
call VimuxInspectRunner()
|
||||
call system("tmux last-"._VimuxRunnerType())
|
||||
call VimuxSendKeys("C-u")
|
||||
endfunction
|
||||
|
||||
function! VimuxScrollDownInspect()
|
||||
call VimuxInspectRunner()
|
||||
call system("tmux last-"._VimuxRunnerType())
|
||||
call VimuxSendKeys("C-d")
|
||||
endfunction
|
||||
|
||||
function! VimuxInterruptRunner()
|
||||
call VimuxSendKeys("^c")
|
||||
endfunction
|
||||
|
||||
function! VimuxClearRunnerHistory()
|
||||
if exists("g:VimuxRunnerIndex")
|
||||
call system("tmux clear-history -t ".g:VimuxRunnerIndex)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! VimuxPromptCommand(...)
|
||||
let command = a:0 == 1 ? a:1 : ""
|
||||
let l:command = input(_VimuxOption("g:VimuxPromptString", "Command? "), command)
|
||||
call VimuxRunCommand(l:command)
|
||||
endfunction
|
||||
|
||||
function! _VimuxTmuxSession()
|
||||
return _VimuxTmuxProperty("#S")
|
||||
endfunction
|
||||
|
||||
function! _VimuxTmuxIndex()
|
||||
if _VimuxRunnerType() == "pane"
|
||||
return _VimuxTmuxPaneIndex()
|
||||
else
|
||||
return _VimuxTmuxWindowIndex()
|
||||
end
|
||||
endfunction
|
||||
|
||||
function! _VimuxTmuxPaneIndex()
|
||||
return _VimuxTmuxProperty("#I.#P")
|
||||
endfunction
|
||||
|
||||
function! _VimuxTmuxWindowIndex()
|
||||
return _VimuxTmuxProperty("#I")
|
||||
endfunction
|
||||
|
||||
function! _VimuxNearestIndex()
|
||||
let views = split(system("tmux list-"._VimuxRunnerType()."s"), "\n")
|
||||
|
||||
for view in views
|
||||
if match(view, "(active)") == -1
|
||||
return split(view, ":")[0]
|
||||
endif
|
||||
endfor
|
||||
|
||||
return -1
|
||||
endfunction
|
||||
|
||||
function! _VimuxRunnerType()
|
||||
return _VimuxOption("g:VimuxRunnerType", "pane")
|
||||
endfunction
|
||||
|
||||
function! _VimuxOption(option, default)
|
||||
if exists(a:option)
|
||||
return eval(a:option)
|
||||
else
|
||||
return a:default
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! _VimuxTmuxProperty(property)
|
||||
return substitute(system("tmux display -p '".a:property."'"), '\n$', '', '')
|
||||
endfunction
|
||||
|
||||
function! _VimuxHasRunner(index)
|
||||
return match(system("tmux list-"._VimuxRunnerType()."s -a"), a:index.":")
|
||||
endfunction
|
||||
Reference in New Issue
Block a user