forked from VimPlug/jedi
Cleanup to the Jedi .pythonrc.py example
This commit is contained in:
@@ -20,20 +20,32 @@ def setup_readline():
|
|||||||
from jedi.utils import setup_readline
|
from jedi.utils import setup_readline
|
||||||
setup_readline()
|
setup_readline()
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print('Install Jedi! No autocompletion otherwise.')
|
# Fallback to the stdlib readline completer if it is installed.
|
||||||
|
# Taken from http://docs.python.org/2/library/rlcompleter.html
|
||||||
|
try:
|
||||||
|
import readline
|
||||||
|
import rlcompleter
|
||||||
|
readline.parse_and_bind("tab: complete")
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
|
||||||
Alternately, you can fall back to regular readline completion with
|
This will fallback to the readline completer if Jedi is not installed.
|
||||||
something like::
|
The readline completer will only complete names in the global namespace,
|
||||||
|
so for example,
|
||||||
|
|
||||||
try:
|
>>> ran<TAB>
|
||||||
from jedi.utils import setup_readline
|
|
||||||
setup_readline()
|
will complete to ``range``
|
||||||
except ImportError:
|
|
||||||
import readline, rlcompleter
|
with both Jedi and readline, but
|
||||||
readline.parse_and_bind("tab: complete")
|
|
||||||
|
>>> range(10).cou<TAB>
|
||||||
|
|
||||||
|
will show complete to ``range(10).count`` only with Jedi.
|
||||||
|
|
||||||
You'll also need to add ``export PYTHONSTARTUP=$HOME/.pythonrc.py`` to
|
You'll also need to add ``export PYTHONSTARTUP=$HOME/.pythonrc.py`` to
|
||||||
your bash profile (usually ``.bash_profile`` or ``.profile``).
|
your shell profile (usually ``.bash_profile`` or ``.profile`` if you use
|
||||||
|
bash).
|
||||||
|
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user