Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Control config through vim globals #128

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,12 @@ not work on Windows, please report the issue to ).
-------
Options
-------
You can change these at the top of the ipy.vim::
You can change these in your vimrc::

reselect = False # reselect lines after sending from Visual mode
show_execution_count = True # wait to get numbers for In[43]: feedback?
monitor_subchannel = True # update vim-ipython 'shell' on every send?
run_flags= "-i" # flags to for IPython's run magic when using <F5>
g:ipy_reselect = 0 # reselect lines after sending from Visual mode
g:ipy_show_execution_count = 1 # wait to get numbers for In[43]: feedback?
g:ipy_monitor_subchannel = 1 # update vim-ipython 'shell' on every send?
g:ipy_run_flags = '-i' # flags to for IPython's run magic when using <F5>

**Disabling default mappings**
In your own ``.vimrc``, if you don't like the mappings provided by default,
Expand Down Expand Up @@ -294,6 +294,7 @@ pull request with your attribution.
* @pydave for IPythonTerminate (sending SIGTERM using our hack)
* @luispedro for IPythonNew
* @jjhelmus for IPython 3.x support.
* @wmvanvliet for config support through vim-globals.

Similar Projects
----------------
Expand Down
2 changes: 1 addition & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This is a list of things I'm planning to work on with vim-ipython

[ ] support for non-python kernels (IJulia, IHaskell kernel)

[ ] provide g:ipy variables to set the initial state of python vars
[x] provide g:ipy variables to set the initial state of python vars
e.g. monitor_subchannel

[ ] put debugging support back in
Expand Down
20 changes: 20 additions & 0 deletions ftplugin/python/ipy.vim
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,26 @@ if !exists('g:ipy_completefunc')
let g:ipy_completefunc = 'global'
endif

" reselect lines after sending from Visual mode
if !exists('g:ipy_reselect')
let g:ipy_reselect = 0
endif

" wait to get numbers for In[43]: feedback?
if !exists('g:ipy_show_execution_count')
let g:ipy_show_execution_count = 1
endif

" update vim-ipython 'shell' on every send?
if !exists('g:ipy_monitor_subchannel')
let g:ipy_monitor_subchannel = 1
endif

" flags to for IPython's run magic when using <F5>
if !exists('g:ipy_run_flags')
let g:ipy_run_flags = '-i'
endif

python << EOF
import vim
import sys
Expand Down
13 changes: 7 additions & 6 deletions ftplugin/python/vim_ipython.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
reselect = False # reselect lines after sending from Visual mode
show_execution_count = True # wait to get numbers for In[43]: feedback?
monitor_subchannel = True # update vim-ipython 'shell' on every send?
run_flags= "-i" # flags to for IPython's run magic when using <F5>
current_line = ''

try:
from queue import Empty # python3 convention
except ImportError:
Expand All @@ -20,6 +14,13 @@ def __getattribute__(self, key):

import sys

# Read global configuration variables
reselect = bool(int(vim.eval("g:ipy_reselect")))
show_execution_count = bool(int(vim.eval("g:ipy_show_execution_count")))
monitor_subchannel = bool(int(vim.eval("g:ipy_monitor_subchannel")))
run_flags = vim.eval("g:ipy_run_flags")
current_line = ""

# get around unicode problems when interfacing with vim
vim_encoding=vim.eval('&encoding') or 'utf-8'

Expand Down