|
| 1 | +*ipython.txt* |
| 2 | + |
| 3 | +============================================================================== |
| 4 | +Contents *vim-ipython-contents* |
| 5 | + |
| 6 | +1. Completion Metadata |vim-ipython-metadata| |
| 7 | +2. IPython Monitor |vim-ipython-monitor| |
| 8 | +3. Variables |vim-ipython-variables| |
| 9 | + 3.1. g:ipy_autostart |g:ipy_autostart| |
| 10 | + 3.2. g:ipy_completefunc |g:ipy_completefunc| |
| 11 | + 3.3. g:ipy_input |g:ipy_input| |
| 12 | + 3.4. g:ipy_perform_mappings |g:ipy_perform_mappings| |
| 13 | + 3.5. g:ipython_completion_timeout |g:ipython_completion_timeout| |
| 14 | + 3.6. g:ipython_dictionary_completion |g:ipython_dictionary_completion| |
| 15 | + 3.7. g:ipython_greedy_matching |g:ipython_greedy_matching| |
| 16 | + 3.8. g:ipython_history_len |g:ipython_history_len| |
| 17 | + 3.9. g:ipython_history_raw |g:ipython_history_raw| |
| 18 | + 3.10. g:ipython_history_timeout |g:ipython_history_timeout| |
| 19 | + 3.11. g:ipython_history_unique |g:ipython_history_unique| |
| 20 | + 3.12. g:ipython_run_flags |g:ipython_run_flags| |
| 21 | + 3.13. g:ipython_store_history |g:ipython_store_history| |
| 22 | + 3.14. g:ipython_timeout |g:ipython_timeout| |
| 23 | + |
| 24 | +============================================================================== |
| 25 | +1. Completion Metadata *vim-ipython-metadata* |
| 26 | + |
| 27 | +vim-ipython supports user-supplied metadata associated with completions from |
| 28 | +the IPython shell. The plugin fetches the metadata from the IPython kernel |
| 29 | +using the user-defined function `completion_metadata` which takes one |
| 30 | +parameter - the result of `get_ipython()`. If the function does not exist in |
| 31 | +IPython's namespace, completion will still work but without any menu/info |
| 32 | +entries in the completion menu. Each completion match should have a |
| 33 | +corresponding metadata dictionary with "word", "menu", and "info" fields. A |
| 34 | +basic (and slow) implementation of such a function follows: > |
| 35 | +
|
| 36 | + def completion_metadata(ip): |
| 37 | + import inspect |
| 38 | + import six |
| 39 | + metadata = [dict(word=m) for m in ip.Completer.matches] |
| 40 | + for m in metadata: |
| 41 | + try: |
| 42 | + obj = eval(m['word'], ip.user_ns) |
| 43 | + except Exception: |
| 44 | + continue |
| 45 | + m['menu'] = six.moves.reprlib.repr(obj) |
| 46 | + info = inspect.getdoc(obj) |
| 47 | + if info: |
| 48 | + m['info'] = info |
| 49 | + return metadata |
| 50 | +
|
| 51 | +============================================================================== |
| 52 | +2. IPython Monitor *vim-ipython-monitor* |
| 53 | + |
| 54 | +The included `monitor.py` script listens in on message from Vim to the IPython |
| 55 | +kernel to echo inputs and outputs to the kernel in real-time. The script must |
| 56 | +be started before connecting Vim to the IPython kernel so that it can |
| 57 | +differentiate between Vim and the Jupyter shell clients. The `:IPython` |
| 58 | +command can be executed multiple times without ill effect in case the monitor |
| 59 | +is started later on. |
| 60 | + |
| 61 | +Basic usage: > |
| 62 | +
|
| 63 | + $ python monitor.py &; jupyter console |
| 64 | + :IPython |
| 65 | +
|
| 66 | +Note: Currently the script looks for a connection file automatically and will |
| 67 | +connect to the first connection file it finds matching the glob pattern |
| 68 | +"kernel-[0-9]*.json'. This means the script will not connect to IPython |
| 69 | +notebook kernels by design. |
| 70 | + |
| 71 | +============================================================================== |
| 72 | +3. Variables *vim-ipython-variables* |
| 73 | + |
| 74 | +------------------------------------------------------------------------------ |
| 75 | +3.1. `g:ipy_autostart` *g:ipy_autostart* |
| 76 | + |
| 77 | +------------------------------------------------------------------------------ |
| 78 | +3.2. `g:ipy_completefunc` *g:ipy_completefunc* |
| 79 | + |
| 80 | +------------------------------------------------------------------------------ |
| 81 | +3.3. `g:ipy_input` *g:ipy_input* |
| 82 | + |
| 83 | +------------------------------------------------------------------------------ |
| 84 | +3.4. `g:ipy_perform_mappings` *g:ipy_perform_mappings* |
| 85 | + |
| 86 | +------------------------------------------------------------------------------ |
| 87 | +3.5. `g:ipython_completion_timeout` *g:ipython_completion_timeout* |
| 88 | + |
| 89 | +------------------------------------------------------------------------------ |
| 90 | +3.6. `g:ipython_dictionary_completion` *g:ipython_dictionary_completion* |
| 91 | + |
| 92 | +------------------------------------------------------------------------------ |
| 93 | +3.7. `g:ipython_greedy_matching` *g:ipython_greedy_matching* |
| 94 | + |
| 95 | +------------------------------------------------------------------------------ |
| 96 | +3.8. `g:ipython_history_len` *g:ipython_history_len* |
| 97 | + |
| 98 | +------------------------------------------------------------------------------ |
| 99 | +3.9. `g:ipython_history_raw` *g:ipython_history_raw* |
| 100 | + |
| 101 | +------------------------------------------------------------------------------ |
| 102 | +3.10. `g:ipython_history_timeout` *g:ipython_history_timeout* |
| 103 | + |
| 104 | +------------------------------------------------------------------------------ |
| 105 | +3.11. `g:ipython_history_unique` *g:ipython_history_unique* |
| 106 | + |
| 107 | +------------------------------------------------------------------------------ |
| 108 | +3.12. `g:ipython_run_flags` *g:ipython_run_flags* |
| 109 | + |
| 110 | +------------------------------------------------------------------------------ |
| 111 | +3.13. `g:ipython_store_history` *g:ipython_store_history* |
| 112 | + |
| 113 | +------------------------------------------------------------------------------ |
| 114 | +3.14. `g:ipython_timeout` *g:ipython_timeout* |
| 115 | + |
| 116 | + vim: textwidth=78 et filetype=help:norightleft: |
0 commit comments