From 562bbf1435bbc6657f6d4fbd44ab5711ebbd9866 Mon Sep 17 00:00:00 2001 From: Chris Toomey Date: Tue, 27 Nov 2012 21:06:20 -0500 Subject: [PATCH] Normalize command and function names to match docs --- README.mkd | 52 +++++++++++++++++----- plugin/vim-tmux-runner.vim | 91 +++++++++++++++++++------------------- 2 files changed, 87 insertions(+), 56 deletions(-) diff --git a/README.mkd b/README.mkd index 32513a8..961e265 100644 --- a/README.mkd +++ b/README.mkd @@ -1,19 +1,46 @@ -# Vim Tmux Runner +# VTR [Vim Tmux Runner] A simple, vimscript only, command runner for sending commands from vim to tmux -## Commands +## Usage -This plugin exposes a command to open a small command runner window in a tmux -pane, then send commands to it. +VTR provides a handful of commands for managing and interacting with [tmux][], +the terminal multiplexer. The main command is: -- Open runner window -- Automatic cd to project root (via git cdup) -- Send command (with escaping, auto-enter, auto-pre-clear) -- Enter tmux-copy mode in pane -- Maximize the runner pane +``` vim +VtrSendCommandToRunner +``` -Full documentation can be found [here][]. +This command will prompt for a command to run, then send it to the runner pane +for execution. If one doesn't currently exist, a new runner pane will be +created. Subsequent calls to `VtrSendCommandToRunner` will reuse the provided +command. + +VTR provides configuration options that allow for control over the size and +location of the VTR runner pane. In addition, VTR provides commands to resize, +reorient, and even detach the runner pane making the interaction as painless as +possible. + +For a complete summary of the available commands and configuration options in +VTR, check [the included doc file][]. + +## Installation + +The easiest way to install VTR is to add the git repo as a bundle, then use +[Pathogen][], [Vundle][] or similar plugin management option to add it to Vim's +runtime path. + +``` shell +cd ~/.vim +mkdir bundles # only +cd bundles +git clone https://github.com/christoomey/vim-tmux-runner.git +``` + +## Development Status + +This plugin is currently very much an alpha. Although the major features are +implemented, the API is subject to change any time up until v1.0. ## Inspiration @@ -22,4 +49,7 @@ plugin aims to implement a similar feature set while not requiring Vim with ruby requirement. In addition a few new commands not found in Vimux have been added to provide additional control over the tmux runner pane. -[here]: https://github.com/christoomey/vim-tmux-runner/blob/master/doc/vim-tmux-runner.txt +[the included doc file]: https://github.com/christoomey/vim-tmux-runner/blob/master/doc/vim-tmux-runner.txt +[Pathogen]: https://github.com/tpope/vim-pathogen +[Vundle]: https://github.com/gmarik/vundle +[tmux]: http://tmux.sourceforge.net/ diff --git a/plugin/vim-tmux-runner.vim b/plugin/vim-tmux-runner.vim index 35b4935..6f32f56 100644 --- a/plugin/vim-tmux-runner.vim +++ b/plugin/vim-tmux-runner.vim @@ -11,21 +11,6 @@ function! s:InitVariable(var, value) return 0 endfunction -function! s:InitializeVariables() - call s:InitVariable("g:VtrPercentage", 20) - call s:InitVariable("g:VtrOrientation", "v") - call s:InitVariable("g:VtrInitialCommand", "") - call s:InitVariable("g:VtrClearBeforeSend", 1) - call s:InitVariable("g:VtrGitCdUpOnOpen", 1) - call s:InitVariable("g:VtrPrompt", "Command to run: ") - call s:InitVariable("g:VtrUseVtrMaps", 1) - call s:InitVariable("g:VtrClearOnResize", 1) - call s:InitVariable("g:VtrClearOnReorient", 1) - call s:InitVariable("g:VtrClearOnReattach", 1) - call s:InitVariable("g:VtrDetachedName", "VTR_Pane") - call s:InitVariable("g:VtrClearSequence", " ") -endfunction - function! s:OpenRunnerPane() let s:vim_pane = s:ActiveTmuxPaneNumber() let cmd = join(["split-window -p", g:VtrPercentage, "-".g:VtrOrientation]) @@ -261,44 +246,16 @@ function! s:FlushCommand() endfunction function! s:SendCommandToRunner() - call s:EnsureRunnerPane() if !exists("s:user_command") let s:user_command = s:HighlightedPrompt(g:VtrPrompt) endif + call s:EnsureRunnerPane() if g:VtrClearBeforeSend call s:SendClearSequence() endif call s:SendKeys(s:user_command) endfunction -function! s:DefineCommands() - command! VTROpenRunner :call s:EnsureRunnerPane() - command! VTRKillRunner :call s:KillRunnerPane() - command! VTRFocusRunnerPane :call s:FocusRunnerPane() - command! VTRSendCommandToRunner :call s:SendCommandToRunner() - command! VTRReorientRunner :call s:ReorientRunner() - command! VTRResizePane :call s:ResizeRunnerPane() - command! VTRDetachPane :call s:DetachRunnerPane() - command! VTRReattachPane :call s:ReattachPane() - command! VTRClearRunner :call s:SendClearSequence() - command! VTRFlushCommand :call s:FlushCommand() -endfunction - -function! s:DefineKeymaps() - if g:VtrUseVtrMaps - nmap ,rr :VTRResizePane - nmap ,ror :VTRReorientRunner - nmap ,sc :VTRSendCommandToRunner - nmap ,or :VTROpenRunner - nmap ,kr :VTRKillRunner - nmap ,fr :VTRFocusRunnerPane - nmap ,dr :VTRDetachPane - nmap ,ar :VTRReattachPane - nmap ,cr :VTRClearRunner - nmap ,fc :VTRFlushCommand - endif -endfunction - function! s:EnsureRunnerPane() if exists('s:detached_window') call s:ReattachPane() @@ -309,12 +266,56 @@ function! s:EnsureRunnerPane() endif endfunction -function! VTRSendCommand(command) +function! VtrSendCommand(command) call s:EnsureRunnerPane() let escaped_command = shellescape(a:command) call s:SendKeys(escaped_command) endfunction +function! s:DefineCommands() + command! VtrSendCommandToRunner :call s:SendCommandToRunner() + command! VtrOpenRunner :call s:EnsureRunnerPane() + command! VtrKillRunner :call s:KillRunnerPane() + command! VtrFocusRunner :call s:FocusRunnerPane() + command! VtrResizeRunner :call s:ResizeRunnerPane() + command! VtrReorientRunner :call s:ReorientRunner() + command! VtrDetachRunner :call s:DetachRunnerPane() + command! VtrReattachRunner :call s:ReattachPane() + command! VtrClearRunner :call s:SendClearSequence() + command! VtrFlushCommand :call s:FlushCommand() +endfunction + +function! s:DefineKeymaps() + if g:VtrUseVtrMaps + nmap ,rr :VtrResizeRunner + nmap ,ror :VtrReorientRunner + nmap ,sc :VtrSendCommandToRunner + nmap ,or :VtrOpenRunner + nmap ,kr :VtrKillRunner + nmap ,fr :VtrFocusRunner + nmap ,dr :VtrDetachRunner + nmap ,ar :VtrReattachRunner + nmap ,cr :VtrClearRunner + nmap ,fc :VtrFlushCommand + endif +endfunction + +function! s:InitializeVariables() + call s:InitVariable("g:VtrPercentage", 20) + call s:InitVariable("g:VtrOrientation", "v") + call s:InitVariable("g:VtrInitialCommand", "") + call s:InitVariable("g:VtrGitCdUpOnOpen", 0) + call s:InitVariable("g:VtrClearBeforeSend", 1) + call s:InitVariable("g:VtrPrompt", "Command to run: ") + call s:InitVariable("g:VtrUseVtrMaps", 0) + call s:InitVariable("g:VtrClearOnResize", 1) + call s:InitVariable("g:VtrClearOnReorient", 1) + call s:InitVariable("g:VtrClearOnReattach", 1) + call s:InitVariable("g:VtrDetachedName", "VTR_Pane") + call s:InitVariable("g:VtrClearSequence", " ") +endfunction + + call s:InitializeVariables() call s:DefineCommands() call s:DefineKeymaps()