Add support for python syntactic whitespace
Closes #18 - Stripping whitespace Add ipython readline and auto-indent notes
This commit is contained in:
parent
18d5ef9acd
commit
191d9d843c
21
README.mkd
21
README.mkd
@ -37,6 +37,27 @@ cd bundles
|
|||||||
git clone https://github.com/christoomey/vim-tmux-runner.git
|
git clone https://github.com/christoomey/vim-tmux-runner.git
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Python Notes
|
||||||
|
|
||||||
|
If you are using python, or any other language with syntactic whitespace, you
|
||||||
|
will likely want to change the following settings to better support the
|
||||||
|
required whitespace:
|
||||||
|
|
||||||
|
``` vim
|
||||||
|
let g:VtrStripLeadingWhitespace = 0
|
||||||
|
let g:VtrClearEmptyLines = 0
|
||||||
|
let g:VtrAppendNewline = 1
|
||||||
|
```
|
||||||
|
|
||||||
|
Additionally, if you are using ipython, you will need to ensure it is
|
||||||
|
installed with proper readline support. Ref [this Stack Overflow thread][] and
|
||||||
|
answer for more detail.
|
||||||
|
|
||||||
|
You will also need to start ipython with auto-indentation disabled, which can
|
||||||
|
be done with the following `ipython --no-autoindent`.
|
||||||
|
|
||||||
|
[this Stack Overflow thread]: http://stackoverflow.com/a/1840304/2751777
|
||||||
|
|
||||||
## Development Status
|
## Development Status
|
||||||
|
|
||||||
This plugin is currently very much an alpha. Although the major features are
|
This plugin is currently very much an alpha. Although the major features are
|
||||||
|
@ -34,6 +34,9 @@ CONTENTS *vtr-contents*
|
|||||||
3.9 ................................ |VtrClearOnReattach|
|
3.9 ................................ |VtrClearOnReattach|
|
||||||
3.10 ............................... |VtrDetachedName|
|
3.10 ............................... |VtrDetachedName|
|
||||||
3.11 ............................... |VtrClearSequence|
|
3.11 ............................... |VtrClearSequence|
|
||||||
|
3.12 ............................... |VtrStripLeadningWhitespace|
|
||||||
|
3.13 ............................... |VtrClearEmptyLines|
|
||||||
|
3.14 ............................... |VtrAppendNewline|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
ABOUT (1) *VTR-About*
|
ABOUT (1) *VTR-About*
|
||||||
@ -398,5 +401,47 @@ insert mode. See the help file, ':help i_Ctrl-v', for more detail.
|
|||||||
|
|
||||||
Default: ""
|
Default: ""
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
*VtrStripLeadningWhitespace*
|
||||||
|
|
||||||
|
3.12 g:VtrStripLeadingWhitespace~
|
||||||
|
|
||||||
|
When interacting with most REPLs, indentation will automatically be added to
|
||||||
|
the beginning of lines based on the syntax. The setting causes VTR to strip
|
||||||
|
leading whitespace before sending lines to avoid doubly indented lines.
|
||||||
|
|
||||||
|
By default this setting is enabled, but if you are using a language with
|
||||||
|
syntactic whitespace like python or coffeescript then you will likely want to
|
||||||
|
disable this setting.
|
||||||
|
|
||||||
|
let g:VtrStripLeadingWhitespace = 0
|
||||||
|
|
||||||
|
Default: 1
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
*VtrClearEmptyLines*
|
||||||
|
|
||||||
|
3.13 g:VtrClearEmptyLines~
|
||||||
|
|
||||||
|
VTR will clear out empty lines in visually selected regions to avoid clutter in
|
||||||
|
the REPLs. If the blank lines are relevant, you can disable this behavior.
|
||||||
|
|
||||||
|
let g:VtrClearEmptyLines = 0
|
||||||
|
|
||||||
|
Default: 1
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
*VtrAppendNewline*
|
||||||
|
|
||||||
|
3.14 g:VtrAppendNewline
|
||||||
|
|
||||||
|
If you are using python or any language with syntactic whitespace, an empty
|
||||||
|
line might be needed to close the preceding context. To enable appending a new
|
||||||
|
line to any multi line send, use the following setting.
|
||||||
|
|
||||||
|
let g:VtrAppendNewline = 1
|
||||||
|
|
||||||
|
Default: 0
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
vim:tw=78:ts=2:sw=2:expandtab:ft=help:norl:
|
vim:tw=78:ts=2:sw=2:expandtab:ft=help:norl:
|
||||||
|
@ -342,10 +342,23 @@ function! s:SendSelectedToRunner()
|
|||||||
call s:SendTextToRunner(lines)
|
call s:SendTextToRunner(lines)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:PrepareLines(lines)
|
||||||
|
let prepared = a:lines
|
||||||
|
if g:VtrStripLeadingWhitespace
|
||||||
|
let prepared = map(a:lines, 'substitute(v:val,"^\\s*","","")')
|
||||||
|
endif
|
||||||
|
if g:VtrClearEmptyLines
|
||||||
|
let prepared = filter(prepared, "!empty(v:val)")
|
||||||
|
endif
|
||||||
|
if g:VtrAppendNewline && len(a:lines) > 1
|
||||||
|
let prepared = add(prepared, "\r")
|
||||||
|
endif
|
||||||
|
return prepared
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:SendTextToRunner(lines)
|
function! s:SendTextToRunner(lines)
|
||||||
let whitespace_stripped = map(a:lines, 'substitute(v:val,"^\\s*","","")')
|
let prepared = s:PrepareLines(a:lines)
|
||||||
let without_empty_lines = filter(whitespace_stripped, "!empty(v:val)")
|
let joined_lines = join(prepared, "\r") . "\r"
|
||||||
let joined_lines = join(without_empty_lines, "\r") . "\r"
|
|
||||||
let send_keys_cmd = s:TargetedTmuxCommand("send-keys", s:runner_pane)
|
let send_keys_cmd = s:TargetedTmuxCommand("send-keys", s:runner_pane)
|
||||||
let targeted_cmd = send_keys_cmd . ' ' . shellescape(joined_lines)
|
let targeted_cmd = send_keys_cmd . ' ' . shellescape(joined_lines)
|
||||||
call s:SendTmuxCommand(targeted_cmd)
|
call s:SendTmuxCommand(targeted_cmd)
|
||||||
@ -409,6 +422,9 @@ function! s:InitializeVariables()
|
|||||||
call s:InitVariable("g:VtrDetachedName", "VTR_Pane")
|
call s:InitVariable("g:VtrDetachedName", "VTR_Pane")
|
||||||
call s:InitVariable("g:VtrClearSequence", "")
|
call s:InitVariable("g:VtrClearSequence", "")
|
||||||
call s:InitVariable("g:VtrDisplayPaneNumbers", 1)
|
call s:InitVariable("g:VtrDisplayPaneNumbers", 1)
|
||||||
|
call s:InitVariable("g:VtrStripLeadingWhitespace", 1)
|
||||||
|
call s:InitVariable("g:VtrClearEmptyLines", 1)
|
||||||
|
call s:InitVariable("g:VtrAppendNewline", 0)
|
||||||
let s:vtr_percentage = g:VtrPercentage
|
let s:vtr_percentage = g:VtrPercentage
|
||||||
let s:vtr_orientation = g:VtrOrientation
|
let s:vtr_orientation = g:VtrOrientation
|
||||||
endfunction
|
endfunction
|
||||||
|
Loading…
x
Reference in New Issue
Block a user