mirror of
https://github.com/davidhalter/jedi-vim.git
synced 2025-12-06 10:54:22 +08:00
e99cfd32de1c8b53a7c846e4dfe7141d6ef97cbc
* pythonx/jedi afbd8cad...3ad3dc08 (197):
> Run get_type_hint tests only for 3.6+
> Stubs should not become stubs again in the conversion function, fixes #1475
> Make sure to print errors in __main__ completions
> Make sure param hints are working for functions
> Generate type hints, fixes #987
> Bump version to 0.16.1
> Make sure to be able to deal with all kinds of loaders, fixes #1487
> Make generators return more correct values with while loops, fixes #683
> Avoid aborting search for yields when they are still reachable, see #683
> Jedi understand now when you use del, fixes #313
> Remove dead code
> Remove Python 3.3 from environment tests
> Make sure to skip some tests for Python 3.5
> Small Changelog updates
> Fix a small signature issue
> Create a private helper to test completions
> Fix an issue with names
> compiled_object -> compiled_value
> Remove dead code
> CompiledObject -> CompiledValue
> CompiledValue -> ExactValue
> Revisit caching of mixed
> Make MixedName a Namewrapper instead of inheritance
> Remove underscore_memoization caching method
> Refactor MixedName quite a bit
> Fix issue with mixed objects, fixes #1480
> Remove some dead code
> Prepare a test for #1479
> Avoid a print in tests
> Fix value/context mixup in mixed, fixes #1479
> Clarify that for Python 2 we will not fix bugs anymore
> Skip a test in Python 2
> Use is_compiled instead of isinstance checks
> Create CompiledModule to have a better differentiation between compiled modules and compiles values
> Make sure that the builtin docstring works again for infer calls
> Fix a bug with version_info, fixes #1477
> Make sure that del_stmt as a name can be handled, see #313
> Remove use_filesystem_cache and additional_dynamic_modules, it hasn't been implemented for a long time
> Removed settings.no_completion_duplicates
> Make sure to stop gathering buildout paths at a certain point, fixes #1325
> Rewrite some whitespace
> Reformat the changelog a bit
> Add follow_imports to Definition.goto, fixes #1474
> Raise a proper exception instead of assert in case only_stubs and prefer_stubs are given
> Make sure a certain test passes as well with tox
> Fix a Python 2 issue
> Rename Script.names to Script.get_names, fixes #1476
> find_signatures -> get_signatures, see #1476
> find_references -> get_references, see #1476
> Fix remaining tests
> Reduce limits of files to parse by quite a bit
> Make sure that CompiledObject doesn't have a file_io
> Use different limits for references and dynamic calls
> Explain why the references limits were chosen
> Start limiting opened files and parsed files for references
> Remove a few imports
> Make sure to not scan the same directory multiple times
> Don't search for usages when we are working with params
> Ignore .gitignore in get_references and therefore make get_references usable again
> Revisit reference finding, scan a lot of folders
> Added FolderIO.walk and FolderIO.get_base_name
> Move get_module_contexts_containing_name to the references module
> Apparently this one variable is needed
> Small changelog fix
> Forgot to use sudo for installing dependencies in travis
> Another few travis fixes
> Don't run some usage tests on Python 2
> Interpreter test fix for travis config
> Add a few more stub usage tests
> Disable flow analysis for finding usages
> Add another stub usage test
> Fix stub conversion
> Make sure to find both stubs and non-stubs with usages
> Use the proper fixture
> Implement interpreter test on travis
> Get interpreter environment tests working
> Make sure tests are proper packages, so that pytest doesn't do shenannigans with sys path
> Remove NestedImportModule, because it hasn't been used in years
> Refactor execute_operation a bit
> Finally get rid of call_of_leaf
> Refactor the isinstance checks a bit
> Makes sure examples are excluded from pytest
> speed test to examples
> Move not_in_sys_path tests to examples
> Move namespace tests to examples
> Moved zipped imports test files
> Move sample_venvs to examples
> Move the extension test to examples
> Move another test to examples
> Remove unused test code
> Move implicit namespace package code to example dir
> Move flask tests to examples folder
> Move the absolute import test files
> Avoid a bug that a compiler might have found, fixes #1469
> Make sure the latest changes work with Python 3.6/3.7
> Properly convert compiled values to generic classes
> Make Union/Optional works with compiled objects
> Make sure that CompiledValue can deal with string annotations
> Avoid a few warnings
> Skip a test that doesn't work in Python 2
> Remove a statement that didn't make sense
> Remove a method that was not necessary
> Fix a bug where parent_context was a value
> Fix some issues with converting names, see #1466
> Use one single way to convert stubs to Python, see #1466
> Make sure to use _stub_to_python_value_set for all conversions, see #1466
> Make sure fixture resolving works in conftest.py, see #791
> Fix signatures when used for Generic classes, fixes #1468
> Make sure inheritance works for fixtures, fixes #791
> Add a test to check if numpy tensorflow stuff is now cached, see #1116
> Make sure to check the module cache before loading a module (again)
> Add a completion cache for numpy/tensorflow, fixes #1116
> Ignore processing param names, fixes #520
> Avoid using params in tests and use get_signatures().params
> Make sure params have no name
> Make sure that kwargs are not repeated when they are inferred
> Undo finding signatures for everything and only do it for stubs and non-statements for when used in docstrings
> Fix an issue with the is_big_annoying_library function, see #520
> Make sure decorators are also not inferred for big annoying libraries, see #520
> Make sure the repr of compiled access isn't huge
> Disable some features for big annoying libraries like pandas, tensorflow, see #520
> Fix a debug message
> Fix a small issue
> Little refactoring
> Remove the old definition tests
> Remove get_signatures again from names
> Infer doctests and signatures uniformly, fixes #1466
> Fix a small pytest fixture bug
> Raise a deprecation warning on Definition.params
> Remove a weird assert
> Make sure coverage works again
> Use Python 3.7 for calculating test coverage
> Remoeve dead code
> Remove unnecessary code
> Separate getting docstrings and getting signatures for names, see discussion #1466
> LazyInstanceClassName -> Use NameWrapper
> Make sure that equals will only be added to keyword arguments and not just randomly
> Make some test code prettier
> Remove some skips around attribute docstrings
> Add some more dict completion tests with whitespace
> Change ModuleValue param order and add defaults
> Make sure to pass tests again on Python 3.4
> Make sure that include_signature always works, fixes #1466
> Add a test for #1465
> Skip dict key completion tests for Python 3.5, because it's just annoying with all the f-string stuff
> Revert "Use the root implementation for get_root_context"
> Added debug.warning to coveragerc, it's not relevant
> Remove unused code
> Use the root implementation for get_root_context
> Add github sponsor FUNDING.yml file
> Merge branch 'qa' of https://github.com/blueyed/jedi
> Get rid of most flake8 errors
> Get rid of a lot of flake8 errors
> Make sure to get completions for backticks in docstrings work, see #860
> Some more clarifications around docstrings, see #860
> Get doctest completions working, fixes #860
> Fix tests, skip more Python 2
> Make sure test prefixed functions are checked for pytest fixtures, see #791
> Make sure pytester is also used for fixtures, see #791
> Clarify a sentence around virtualenv security, see #1250
> Add the CHANGELOG entries for dict completions.
> Merge branch 'dict', fixes #951
> Make sure to mention that Jedi understands Pytest fixtures
> Fix namedtuple issues that were uncovered by the 'self' changes
> Self manipulations are now more correct, fixes #1392
> Skip pytest tests when environments is not the same one
> Make sure pytest stdlib fixtures are completable
> Make sure the monkeypatch fixture completion works
> Merge branch 'pytest', fixes parts of #791
> Make sure py__name__ and name are defined on all values
> Fix tests
> Keyword completion after ... should not work, fixes davidhalter/jedi-vim#506
> Fix python 2 environment finalizing, fixes #1412
> Remove a function that did nothing anymore
> Make sure modules for dynamic searches are not checked twice
> Make sure classmethod param completion works better for the first param
> Make sure staticmethod params are (mostly) inferred correctly, fixes #735
> Python 2 test fixes
> Add the fix for #997 to the changelog
> Goto on a function/attribute in a class now goes to the definition in its super class, fixes #1175
> Fix a few tests
> Add support for completion even when __getattr__ is present, fixes #997
> Fix an error recovery goto issue, fixes davidhalter/jedi-vim#962
> Add a test to make sure some renamings work always
> Refactor references: Matching more names that might be related
> Catch an additional case for get_context where the cursor is e.g. on the function name
> Add Script().get_context, fixes #253
> Fix some issues with Definition.parent()
> Test parents a bit better
> Refactor tests a bit
> Attribute docstrings work now, fixes #138
> Avoid some duplication of code
> Remove the _Help class completely
> Move the docstring checking code to the names
> Add the Script.help function, fixes #392
> Add big API changes to Changelog
> Merge branch 'api', fixes #1166
.. 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, the default), which has the advantage of being easier to refer
to, 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%