mirror of
https://github.com/davidhalter/jedi-vim.git
synced 2025-12-06 10:54:22 +08:00
a17b0333031bd3652ad4c6169caaed05ffb7c49d
* pythonx/jedi 3ad3dc08...3b7106ae (203):
> Fix a typo
> Prepare for 0.17.2
> Fix a Python 3.9 issue on travis
> Properly negate with Interpreter, fixes #1636
> Fix issues with generators, fixes #1624
> Introduce py__next__ to have more clear way to use __next__
> Merge pull request #1633 from mrclary/mrclary-fix-wingkinl-patch-python-environ
> Fix dict completions for inherited dicts, fixes #1631
> Refactor Interpeter completions a bit
> Make sure the interpreter completions work better in Jupyter Notebook, fixes #1628
> Fix an issue with interpreter completion, see also #1628
> Making sure to note that Python 2 will not be supported after 0.17.2
> Mention in Changelog that 3.9 is now supported
> Add download badge
> Some test skips
> Revert some of the Decoratee changes
> Some more signature adjustments
> Change Decoratee slightly
> Fix an issue with decoratee names
> Add Project.path, fixes #1622
> Fix the of a signature with a decorator
> Fix docstrings for method decorators, fixes #1621
> Make partial use the __doc__ of its function, fixes #1621
> Merge pull request #1614 from PeterJCLaw/fix-decorator-factory-passthrough
> Merge pull request #1623 from mallamanis/master
> Remove a print
> Typeshed third party libraries should not be loaded if they don't actually exist in the environment, fixes #1620
> Add the env_vars change to CHANGELOG
> Merge pull request #1619 from mrclary/subprocess-env-vars
> Make sure that Callables are properly represented
> Add Python 3.8 to the tox env list (#1618)
> Use Python 3 in the deployment script
> Prepare release 0.17.1
> Make sure the current version doesn't install a parso version that is new
> Small changelog improvement
> Mention Django Manager support for managers/querysets in changelog
> Add SyntaxError.get_message
> Mention 3.9 support better
> Fix decorator param completion
> Merge branch 'django'
> Merge branch 'master' of github.com:davidhalter/jedi
> Fix some issues with sub class matching, fixes #1560
> Better debugging output for is_sub_class_of
> Ignore runtime_checkable, because we don't really need it
> Fix a small extract_variable issue, fixes #1611
> Try to get get the tests for Python 3.9 passing, fixes #1608
> Make it possible to use inheritance on generics without always specifying type vars, see also discussion in #1593
> Update MANIFEST.in
> Make sure that scopes can only be exact values, see #1590
> Merge pull request #1590 from muffinmad/references-scope
> Fix a small issue with doctest completions, fixes #1585
> Exclude more Linux constants in test_import
> Merge pull request #1601 from yuan-xy/patch_3
> Refactoring about checking \r\n (#1603)
> fix typo (#1602)
> fix typo
> Merge pull request #1599 from isidentical/py38-plus-setuppy
> Merge pull request #1595 from PeterJCLaw/operator-not-in
> Import FileNotFoundError from jedi._compatibility
> Merge pull request #1586 from PeterJCLaw/django-more-fields
> Fix potential AttributeError in get_defintion_start_position/get_defintion_end_position, see #1584
> Fix an error of get_definition_end_pos, see #1584
> Refactor test_definition_start_end_position to use parametrize
> definition_end_position -> get_definition_end_position, same for start, see #1584
> Merge pull request #1584 from pappasam/get_definition_position
> Fix tests in Python 2
> Fix a small issue
> Magic methods fixes for reverse methods
> lists and tuples should not be added
> Use __truediv__ instead of __div__
> Fix an issue with Tuple generics
> A few class renames
> Better debugging
> Skip another non-important Python 2 test that fails on Windows
> Fix a namespace issue when getting references
> Fix an about dict completions
> Fix a None issue
> Implement magic method return values, fixes #1577
> Remove an unused cache method
> Undefined api types should not return a random value
> Add support for generic optional parameters (#1559)
> Fix inline case where a name was removed without the code being used, fixes #1582
> Make the diff nicer if there is no ending newline, fixes #1581
> Merge pull request #1579 from muffinmad/pseudotreenameclass
> Merge pull request #1572 from davidhalter/classvar
> Reduce noise in signatures of compiled params (#1564)
> Fix #1573 again; a tree_node can be None
> Fix argument clinic unpacking, remove dynamic bullshit
> This fixes two issues with the caching on Windows:
> Fix getattr completions on very weird cases, fixes #1573
> Fix tests
> Remove the common folder and move it to a common file
> Remove common.value
> Move infer_type_vars to base_value
> Merge pull request #1554 from PeterJCLaw/fix-nested-tuple-argument
> Add .venv to _IGNORE_FOLDERS
> Correct a test
> Speed up signature fetching for MixedName, see discussion in #1422
> Test that the actual signature of a function is used in Interpreter
> Very small refactoring
> Tell sith that goto_assignments is now goto
> Merge pull request #1561 from PeterJCLaw/newtype-pyclass
> Merge pull request #1553 from PeterJCLaw/generic-tuple-return
> Allow files for get_default_project, fixes #1552
> Don't display unnecessary help, fixes #1557
> Pin Django in a different way so tests can work everywhere
> Make sure that Django's values/values_list is tested (though not implemented
> Properly implement inheritance for Django models
> Make sure Django User inference works
> Pin the Django test dependency
> Mention django stubs support in README
> Include Django stubs license in Jedi package
> Some more django query tests
> Infer many to many fields
> Include Django stubs as a third party repo
> Make sure that infering the Django User model works
> Fix a recursion error issue
> Remove unused imports
> Fix typos in api.classes docstrings
> Remove a redundant check from Name.desc_with_module
> Actually fix #1556, forgot to add this in 94d374c9ceeb16ea1c6fe49b8e039d415c7dbe5a
> Start changelog for 0.17.1
> Fix a small issue with the help method, fixes #1556
> Django is not supported for Python 2
> Work with a NameWrapper, so Django goto works better
> Fix another django modelfield issue
> Some nitpicks
> Fix another issue with foreign keys
> Fix ForeignKey issues with invalid values
> Some other small refactorings
> Refactor a few things for django
> Remove old third party django tests
> Use debug instead of print for Django and fix indentation, see #1467
> Make Django test optional
> Merge branch 'master' of https://github.com/ANtlord/jedi
> Better developer tools
> Make the linter completely private
> Make sure that calling Jedi with a random argument in CLI results in errors
> Fix a small _get_annotated_class_object, fixes #1550
> Also don't complete keywords if kwargs only are allowed, see #1541
> Completion: Don't suggest variables when only kwargs are legal, fixes #1541
> fix #1548
> * Use an explicit environment for subprocess to ensure that existing environment variables are not inherited. This ensures more reliable results, see issue #1540. * Attempt to send SYSTEMROOT variable to Windows subprocess
> Sort test_project::test_search results to fix failures
> Inc difference limit in TestSetupReadline::test_import for py3.8
> Project._python_path -> Project.environment_path
> Set the release date in Changelog
> Some README improvements
> Extract now properly validates line/column and those two params are required
> Some minor CHANGELOG changes
> Upgrade parso version
> Fix a small issue
> Some more code quality fixes
> Some code cleanups
> Don't reuse a variable
> Remove unreachable code
> _convert_names kwargs are not needed
> Add pyproject.toml to the list of files to search for projects
> Use the interpreter environment if the executable is not available, fixes #1531
> Fix a potential AttributeError
> Add a comment to clarify the Type case
> Avoid AttributeErrors for generics when a module is passed
> Merge branch 'improve-type-annotation-inference-refactors' of https://github.com/PeterJCLaw/jedi
> Merge branch 'improve-type-annotation-inference' of https://github.com/PeterJCLaw/jedi
> If branch inference should not trigger for things we don't know, fixes #1530
> Fix string completion issue, fixes #1528
> Fix wrong types for iterate, fixes #1524
> Fix stub conversion for Decoratee, so docstrings work, see #117
> Remove unused environment param
> Fix a Python 2 test
> Merge branch 'refactor'
> Merge branch 'project'
> Included statement as a possible return type for BaseDefinition.type
> Fix partialmethod issues
> Make sure partialmethod tests are only executed for Python 3
> Merge branch 'add-partialmethod' of https://github.com/ffe4/jedi
> Merge branch 'expandtab' of https://github.com/Carreau/jedi
> Changed semantics of ClassVar attributes in classes, fixes #1502
> Avoid duplicate definitions for goto, fixes #1514
> Merge _remove_statements and infer_expr_stmt, fixes #1504
> Fix namedtuple docstring/signature issues, fixes #1506
> Fix a getattr_static issue, fixes #1517
> Disable some more tests for Python 2
> Make InterpreterEnvironment public
> is_typeddict should be part of ClassMixin
> Don't continue searching for values if an annotation is found
> TypedDict checking should be at a later point
> Simplify tests a bit
> Merge branch 'typeddict' of https://github.com/pappasam/jedi
> Update sith's module docstring to match the available operations
> Remove the word 'class' from annotation_string
> Add a couple of docstrings
> Tell sith that 'completions' became 'complete'
> Add venv to .gitignore
> Remove additional prefix which seems incorrect
> Update use of _source which no longer exists to _code
> Make sure to move up VSCode, because it's used a lot
> Revert "Make sure to mention that VSCode is using Jedi"
> Make sure to mention that VSCode is using Jedi
> Fix a test issue
> Actually use follow_builtin_imports and improve the goto docstring, fixes #1492
> Catch an error with illegal class instances, fixes #1491
> Make Ellipsis without list in Callable work, fixes #1475
.. image:: https://github.com/davidhalter/jedi-vim/blob/master/doc/logotype-a.svg
#################################################
jedi-vim - awesome Python autocompletion with VIM
#################################################
.. image:: https://travis-ci.org/davidhalter/jedi-vim.svg?branch=master
:target: https://travis-ci.org/davidhalter/jedi-vim
:alt: Travis-CI build status
jedi-vim is a VIM binding to the autocompletion library
`Jedi <http://github.com/davidhalter/jedi>`_.
Here are some pictures:
.. image:: https://github.com/davidhalter/jedi/raw/master/docs/_screenshots/screenshot_complete.png
Completion for almost anything (Ctrl+Space).
.. image:: https://github.com/davidhalter/jedi/raw/master/docs/_screenshots/screenshot_function.png
Display of function/class bodies, docstrings.
.. image:: https://github.com/davidhalter/jedi/raw/master/docs/_screenshots/screenshot_pydoc.png
Documentation (Pydoc) support (with highlighting, Shift+k).
There is also support for goto and renaming.
Get the latest from `github <http://github.com/davidhalter/jedi-vim>`_.
Documentation
=============
Documentation is available in your vim: ``:help jedi-vim``. You can also look
it up `on github <http://github.com/davidhalter/jedi-vim/blob/master/doc/jedi-vim.txt>`_.
You can read the Jedi library documentation `here <http://jedi.readthedocs.io/en/latest/>`_.
If you want to report issues, just use the github issue tracker. In case of
questions about the software, please use `stackoverflow
<https://stackoverflow.com/questions/tagged/jedi-vim>`_ and tag your question with ``jedi-vim``.
Contributing
============
We love Pull Requests! Read the instructions in ``CONTRIBUTING.md``.
Features
========
The Jedi library understands most of Python's core features. From decorators to
generators, there is broad support.
Apart from that, jedi-vim supports the following commands
- Completion ``<C-Space>``
- Goto assignment ``<leader>g`` (typical goto function)
- Goto definition ``<leader>d`` (follow identifier as far as possible,
includes imports and statements)
- Goto (typing) stub ``<leader>s``
- Show Documentation/Pydoc ``K`` (shows a popup with assignments)
- Renaming ``<leader>r``
- Usages ``<leader>n`` (shows all the usages of a name)
- Open module, e.g. ``:Pyimport os`` (opens the ``os`` module)
Installation
============
Requirements
------------
You need a VIM version that was compiled with Python 2.7 or later
(``+python`` or ``+python3``). You can check this from within VIM using
``:python3 import sys; print(sys.version)`` (use ``:python`` for Python 2).
Manual installation
-------------------
You might want to use `pathogen <https://github.com/tpope/vim-pathogen>`_ or
`Vundle <https://github.com/gmarik/vundle>`_ to install jedi-vim.
The first thing you need after that is an up-to-date version of Jedi. Install
``git submodule update --init --recursive`` in your jedi-vim repository.
Example installation command using Pathogen:
.. code-block:: sh
git clone --recursive https://github.com/davidhalter/jedi-vim.git ~/.vim/bundle/jedi-vim
Example installation using Vundle:
Add the following line in your `~/.vimrc`
.. code-block:: vim
Plugin 'davidhalter/jedi-vim'
For installing Jedi, ``pip install jedi`` will also work, but you might run
into issues when working in virtual environments. Please use git submodules.
Installation with your distribution
-----------------------------------
On Arch Linux, you can also install jedi-vim from official repositories as
`vim-jedi <https://www.archlinux.org/packages/community/any/vim-jedi/>`__.
It is also available on
`Debian (≥8) <https://packages.debian.org/vim-python-jedi>`__ and
`Ubuntu (≥14.04) <http://packages.ubuntu.com/vim-python-jedi>`__ as
vim-python-jedi.
On Fedora Linux, it is available as
`vim-jedi <https://apps.fedoraproject.org/packages/vim-jedi>`__.
Please note that this version might be quite old compared to using jedi-vim
from Git.
Caveats
-------
Note that the `python-mode <https://github.com/klen/python-mode>`_ VIM plugin seems
to conflict with jedi-vim, therefore you should disable it before enabling
jedi-vim.
To enjoy the full features of jedi-vim, you should have VIM >= 7.3, compiled with
``+conceal`` (which is not the case on some platforms, including OS X). If your VIM
does not meet these requirements, the parameter recommendation list may not appear
when you type an open bracket after a function name. Please read
`the documentation <http://github.com/davidhalter/jedi-vim/blob/master/doc/jedi-vim.txt>`_
for details.
Settings
========
Jedi is by default automatically initialized. If you don't want that I suggest
you disable the auto-initialization in your ``.vimrc``:
.. code-block:: vim
let g:jedi#auto_initialization = 0
There are also some VIM options (like ``completeopt`` and key defaults) which
are automatically initialized, but you can skip this:
.. code-block:: vim
let g:jedi#auto_vim_configuration = 0
You can make jedi-vim use tabs when going to a definition etc:
.. code-block:: vim
let g:jedi#use_tabs_not_buffers = 1
If you are a person who likes to use VIM-splits, you might want to put this in your ``.vimrc``:
.. code-block:: vim
let g:jedi#use_splits_not_buffers = "left"
This options could be "left", "right", "top", "bottom" or "winwidth". It will decide the direction where the split open.
Jedi automatically starts the completion, if you type a dot, e.g. ``str.``, if
you don't want this:
.. code-block:: vim
let g:jedi#popup_on_dot = 0
Jedi selects the first line of the completion menu: for a better typing-flow
and usually saves one keypress.
.. code-block:: vim
let g:jedi#popup_select_first = 0
Jedi displays function call signatures in insert mode in real-time, highlighting
the current argument. The call signatures can be displayed as a pop-up in the
buffer (set to 1 by default (with the conceal feature), 2 otherwise),
which has the advantage of being easier to refer to (but is a hack with
many drawbacks since it changes the buffer's contents),
or in Vim's command line aligned with the function call (set to 2), which
can improve the integrity of Vim's undo history.
.. code-block:: vim
let g:jedi#show_call_signatures = "1"
Here are a few more defaults for actions, read the docs (``:help jedi-vim``) to
get more information. If you set them to ``""``, they are not assigned.
.. code-block:: vim
NOTE: subject to change!
let g:jedi#goto_command = "<leader>d"
let g:jedi#goto_assignments_command = "<leader>g"
let g:jedi#goto_stubs_command = "<leader>s"
let g:jedi#goto_definitions_command = ""
let g:jedi#documentation_command = "K"
let g:jedi#usages_command = "<leader>n"
let g:jedi#completions_command = "<C-Space>"
let g:jedi#rename_command = "<leader>r"
Finally, if you don't want completion, but all the other features, use:
.. code-block:: vim
let g:jedi#completions_enabled = 0
FAQ
===
I don't want the docstring window to popup during completion
------------------------------------------------------------
This depends on the ``completeopt`` option. Jedi initializes it in its
``ftplugin``. Add the following line to your ``.vimrc`` to disable it:
.. code-block:: vim
autocmd FileType python setlocal completeopt-=preview
I want <Tab> to do autocompletion
---------------------------------
Don't even think about changing the Jedi command to ``<Tab>``,
use `supertab <https://github.com/ervandew/supertab>`_!
The completion is too slow!
---------------------------
1. Completion of complex libraries (like Numpy) should only be slow the first
time you complete them. After that the results should be cached and very fast.
2. If it is still slow after the initial completion and you have installed the
python-mode Vim plugin, try disabling its rope mode:
.. code-block:: vim
let g:pymode_rope = 0
See issue `#163 <https://github.com/davidhalter/jedi-vim/issues/163>`__.
3. You can also use `deoplete-jedi <https://github.com/zchee/deoplete-jedi>`__
for completions, which uses Jedi, but does completions asynchronously
(requires Neovim).
It makes sense to use both jedi-vim and deoplete-jedi, but you should disable
jedi-vim's completions then:
.. code-block:: vim
let g:jedi#completions_enabled = 0
Testing
=======
jedi-vim is being tested with a combination of `vspec
<https://github.com/kana/vim-vspec>`_ and `py.test <http://pytest.org/>`_.
The tests are in the ``test`` subdirectory, you can run them calling::
py.test
The tests are automatically run with `travis
<https://travis-ci.org/davidhalter/jedi-vim>`_.
Description
Languages
Python
50.2%
Vim Script
49%
Makefile
0.8%