214 Commits

Author SHA1 Message Date
Daniel Hahler
b9f8317595 Update submodule pythonx/jedi 454447d4...60415033
* pythonx/jedi 454447d4...60415033 (54):
      > Prepare the v0.14.1 release
      > Use fixture names everywhere
      > Cleanup a test file
      > Use parametrize instead of TestCase
      > Remove a TestCase class usage
      > Use pytest.mark.parametrize for something instad of a class
      > Use the names fixture even more
      > Use the names fixture more
      > A small rename
      > Refactor names tests
      > A small refactoring
      > Make sure __wrapped__ works properly when using an Interpreter, fixes #1353
      > Small refactoring
      > Make API param names appear without leading double underscores, fixes #1357 again
      > Fix some call signature tests
      > Make expected index work in Python 3
      > Test both closing brackets and non-closing brackets for CallSignature.index
      > Fix a case with errors
      > Move some code around
      > Fix some kwargs cases
      > Fix some *args issues
      > Deal better with some error nodes
      > Delete unused code
      > Fix some error node handling for call signatures
      > Fix CallSignature index for a looot of cases, fixes #1364,#1363
      > Use recursion rather than other stuff
      > Even more refactorings
      > small name refactoring
      > Refactor some call details
      > Disable a test for Python 2
      > Fix pow() signature, fixes #1357
      > Merge branch 'master' of github.com:davidhalter/jedi
      > Fix signature to_string
      > Fix an issue with keyword params, fixes #1356
      > Simplify some test code for param defaults, see #1356
      > Merge branch 'function_signature_in_interpreter' of https://github.com/linupi/jedi
      > Improve a bit of dataclasses support, so at least the attributes can be seen
      > Make sure in tests that pep 0526 variables are also able to be used when using self, see #933
      > Get typing.NewType working (#1344)
      > Cannot use pytest 5 yet
      > Fix filters for classes and functions
      > Fix some small things to get more tests passing
      > A better repr for Definition
      > Merge branch 'master' of github.com:davidhalter/jedi
      > Fix ClassVar filter for instances
      > Keyword completions are no longer possible directly after a number, fixes #1085
      > Fix super call goto for multiple inheritance, fixes #1311
      > goto should always goto definitions, fixes #1304
      > Fix star imports checks, fixes #1235
      > Actually import IsADirectoryError
      > Add 3.8 to supported versions
      > Fix project search if a directory is called manage.py, fixes #1314
      > Return annotations for compiled objects now help to infer
      > Update parso requirement
2019-07-13 20:21:56 +02:00
Daniel Hahler
d3f40d13ec Update submodule pythonx/parso 59df3fa...c0ace63
* pythonx/parso 59df3fa...c0ace63 (9):
      > For Python 2.7 and 3.4 pytest 5 doesn't work anymore
      > Prepare the 0.5.1 release
      > Fix name tokenizing for Python 2
      > Fix positioning for names that are interleaved with error tokens
      > Merge branch 'master' of github.com:davidhalter/parso
      > Fixed name tokenizing issues for tamil characters, fixes davidhalter/jedi#1368
      > Document that the cache uses pickle files
      > Fix changelog dates, fixes #77
      > Try to use collections.abc.Mapping instead of collections.Mapping
2019-07-13 20:21:56 +02:00
Dave Halter
016fb7c78e Merge pull request #915 from davidhalter/typeshed
With typeshed coming to Jedi, builtin modules should be displayed
2019-06-23 01:13:14 +02:00
Dave Halter
e736eea934 Use staticmethod for call signature tests instead of str
str has different signatures for Python 2 and 3 and is therefore annoying to test.
2019-06-21 00:28:18 +02:00
Dave Halter
6c6b4dcf92 Make sure that formatting happens on unicode 2019-06-20 23:56:46 +02:00
Dave Halter
73289427ba Modules should be accessible if column is not None 2019-06-20 23:46:34 +02:00
Dave Halter
1a053d2a23 Fix some call signature tests 2019-06-20 23:37:43 +02:00
Dave Halter
636ad08d32 Get rid of documentation about pip install jedi
pip install jedi doesn't work with properly with virtualenvs, if jedi-vim is
used.
2019-06-20 23:15:16 +02:00
Dave Halter
d32962f3b2 Upgrade Jedi to 0.14.0 and parso to 0.5.0 2019-06-20 22:38:57 +02:00
Dave Halter
717446dd71 For whatever reason tabs were used as indentation 2019-06-17 20:52:31 +02:00
Dave Halter
9c9a513aaf Add a goto_stubs command 2019-06-16 09:39:50 +02:00
Daniel Hahler
69aa410afa Fix :JediClearCache!
Parso's cache can be cleaned from Jedi now.
2019-04-28 21:19:39 +02:00
Daniel Hahler
914754a04e Disable smart_auto_mappings by default
Ref: https://github.com/davidhalter/jedi-vim/issues/568
2019-04-06 01:02:23 +02:00
Dave Halter
f26b2a8802 Change supported Python version in docs 2019-03-22 12:40:28 +01:00
Daniel Hahler
d879d2f216 jedi#show_documentation: check len of g:jedi#documentation_command 2019-03-22 12:35:43 +01:00
Dave Halter
23c14f6826 With typeshed coming to Jedi, builtin modules should be displayed
(If there's a module_path (which most will have)).

This change is still backwards compatible and can be used with older Jedi
versions (<0.14.0).
2019-03-09 13:35:56 +01:00
Dave Halter
1f7e661d9d Upgrade parso 2019-02-24 18:59:53 +01:00
Dave Halter
c6fe4fee76 Upgrade Jedi to latest 2019-02-24 18:59:29 +01:00
Dave Halter
ea5e87a703 Remove jedi.NotFoundError, because that was removed quite a while ago, see #899 2019-02-17 18:04:15 +01:00
Henré Botha
d02a72e792 Update Python version in README (#911)
As per the author's comment here, Python 2.6 is no longer supported. https://github.com/davidhalter/jedi-vim/issues/866#issuecomment-409852888
2019-02-12 14:30:02 +01:00
Daniel Hahler
42d24387ac Update parso to 0.3.3 (#909)
Update submodule pythonx/parso a2b153e...f1ee761

    * pythonx/parso a2b153e...f1ee761 (6):
      > Release of 0.3.3
      > Rename a test
      > Remove some unused code
      > Fix working with async functions in the diff parser, fixes #56
      > Fix bytes/fstring mixing when using iter_errors, fixes #57.
      > Improve a docstring, fixes #55.
2019-02-06 13:09:45 +01:00
Stevan Milic
ba5915bf26 Fix rename with folds: replace line in buffer directly (#906)
Fixes #789
2019-02-05 20:28:46 +01:00
Daniel Hahler
c5c13d69d6 ci: Travis: Ubuntu Xenial, and pynvim (#908) 2019-02-05 20:03:33 +01:00
Daniel Hahler
f36749776d Update parso to v0.3.2
Update submodule pythonx/parso 930ec08...a2b153e

    * pythonx/parso 930ec08...a2b153e (91):
      > Upgrade the Changelog
      > Escape a backslash properly
      > Bump the parso version to 0.3.2
      > f-string parts are also PythonLeaf instances
      > Fix get_start_pos_of_prefix
      > Remove dead code
      > Refactor f-string support
      > Fix: End detection for strings was mostly wrong, fixes #51
      > Fix f-string escapes, fixes #48
      > Tokenizer: Simplify end of string regexes
      > Add a comment from the Python3.7 code base
      > Fix diff parser: The previous fix was a bit off
      > Change fuzzer: Add ways to not always use correct parse input
      > Fix diff parser: issue with opening brackets
      > Async doesn't work in 3.4
      > Skip some tests for Python2.6 and Python3.3
      > Fix diff parser: DEDENT as error leaves should also be ignored and reparsed
      > Fix diff parser: error dedents in between nodes should be ignored for now when copying
      > Fix diff parser: Don't copy error nodes/leaves in the beginning, leads to strange issues in some cases
      > Diff fuzzer: Create a check to see if the errors make sense.
      > Fix diff parser: Don't copy DEDENT tokens at the beginning
      > Fix diff parser: Skip last leaves for last line offset leaves
      > Fix indentation error tokens
      > Fix diff parser: Avoid side effects for prefix
      > Fix tokenizer: backslashes sometimes led to newline token generation
      > Make lines easier copyable in the fuzzer
      > Fix tokenizer: Carriage returns after backslashes were not properly handled
      > Fix in diff parser: prefix calculation was wrong when copying nodes
      > Replace --print-diff with --print-code
      > Fix diff parser generation for empty files
      > Docopt should not be needed for tests
      > Fix tokenizer: Form feeds and multiline docstrings didn't work together
      > Fix diff parser: Need to calculate the prefix for the diff tokenizer better
      > Remove copied nodes stuff, to simplify some things
      > Fix newline endings and a few parser/copy counts
      > Feature: The diff parser fuzzer is now able to use random Python fragments
      > Fix: The Python 3.8 grammar did not include f-string support
      > Fix tokenizer: Closing parentheses in the wrong place should not lead to strange behavior
      > Fix end positions with error dedents
      > Fix diff parser tests for Python 2
      > Randomize the fuzzer a bit more with inserting characters
      > Simplify the regexes
      > Fix a regex clause that was totally wrong
      > Fix another tokenizer issue
      > Apply \r changes in syntax trees
      > Actually make \r usable
      > Fix split lines for Python code
      > Add \r as a valid linebreak for splitlines
      > Move split_lines tests around
      > Start generating really random strings with the fuzzer
      > Fix tokenizer: Dedents before error tokens are properly done, now.
      > Fix diff parser: Also check async with
      > Make the diff parser use a lot of different files by default
      > Fix diff parser: Forgot that with statments are also flows
      > Fix valid graph asserting for some dedents that are errors
      > Fix diff parser: If funcs are not copied, errors shouldn't either
      > Better documentation for the fuzz diff parser script
      > Rename a test
      > More verbose output for the diff fuzzer
      > Fix diff parser: error dedent issues
      > Fix diff parser: Avoid indentation issues
      > Use the right diff order in debug output
      > Fix diff parser: The prefix was wrong in some copy cases
      > Make fuzz parser compatible with Python 2
      > Make it possible to print all diffs in fuzzer
      > Introduce a redo flag 'only_last' to narrow down issues
      > Add docopt to testing dependencies
      > Rewrite the fuzz diff parser to cache errors (so we can re-run those)
      > Fix diff parser: Decorators were sometimes parsed without their functions
      > Fix tokenizer: Dedents should only happen after newlines
      > Usability for diff parser fuzzing
      > Fix for diff parser: Rewrite prefix logic and don't mutate prematurely
      > Fix diff parser: positioning of functions if decorators were removed
      > Ignore ERROR_DEDENT in graph validation
      > Add a small diff parser fuzzer
      > Fix diff parser: get_last_line was sometimes wrong
      > Fix error reporting order for diff issues
      > Clean up the test diff parser file
      > Avoid nasty side effects in creation of Node
      > Make parso errors even more informative
      > Fix diff parser get_last_line calculation
      > Fix graph asserting for error indents
      > Better checks for checking valid graphs
      > Create better ways for debugging the diff parser
      > Fix diff-parser: Copying parts of if else should not lead to the whole thing being copied
      > Reenable diff parser parser counting in all tests
      > Fix: Make the NodesStack to a NodesTree
      > Fix for diff parser : Make sure that start_pos are growing always The problem was that functions/classes were sometimes not well positioned. Now all diff tests are ensuring that leaves always grow.
      > Add a check to see if leaves have the right start positions
      > Add parso version to an exception
      > MNT: add grammar for python 3.8
2019-01-25 01:21:33 +01:00
Brian Mego
7f4f2db260 Fixes incorrect documentation 2018-12-03 23:51:19 +01:00
Daniel Hahler
2f65c636f8 ftplugin: do not duplicate jedi_usages autocommands (#883)
Fixes https://github.com/davidhalter/jedi-vim/issues/882.
2018-11-08 08:43:28 +01:00
Daniel Hahler
b6dfc5fd49 Update submodule pythonx/parso e6bc924...930ec08
* pythonx/parso e6bc924...930ec08 (7):
      > Use SVG badges
      > tox.ini: simplify deps
      > tox: add pypy to envlist for tox-travis
      > setup.py: add "testing" extras_require
      > Add Python 3.7 stable to test matrix and update classifiers
      > Update usage.rst
      > Don't use invalid escape sequences in regex, see https://github.com/davidhalter/jedi-vim/issues/843
2018-10-14 17:55:56 +02:00
Daniel Hahler
2a43448f3b Update submodule pythonx/jedi a79a1fb...bd1010b
* pythonx/jedi a79a1fb...bd1010b (91):
      > Create a new 0.13.1 release
      > Fixed completions of global vars and tensorflow slowness, fixes #1228, #1116
      > The changelog date was wrong
      > Release notes for 0.13.0
      > Fix tensorflow issues with a few hacks (temporary), fixes #1195
      > If the VIRTUAL_ENV variable changes, need to reload the default environment, fixes #1201, #1200
      > Return SameEnvironment as a default, fixes #1226, #1196
      > Document that using the REPL autocompletion is only available on Linux/Mac, fixes #1184
      > Fix an issue with f-strings, fixes #1224
      > Ignore some errors that are happening when the Python process ends and its subprocesses are cleaned up
      > also remove crashes with pep 448 unpacking of lists and sets
      > Fixed crash (and now recognises correctly) {**d, "b": "b"}["b"]
      > Recognize {**d} as a dict instead of set
      > Add extras_require=testing
      > _get_virtual_env_from_var: use safe=False
      > tests: venv_path: use session scope
      > jedi/api/environment.py: minor flake8 fix
      > jedi.api.environment._SUPPORTED_PYTHONS: add 3.7
      > Removing a test from doctests, becaues it shouldn't be one
      > Refactor argument clinic usage
      > With the recent changes one performance optimization got lost
      > FunctionExecutionContext should use the parent if possible
      > Use anonymous instance arguments in a different way
      > Move some anonymous instance function execution stuff
      > Get rid of InstanceFunctionExecution, because it's really not needed
      > Use the InstanceArguments for super as well
      > Use InstanceArguments directly and not via InstanceFunctionExecution
      > Remove old garbage code
      > Don't use arguments that are not needed
      > Also move the remaining get_params to get_executed_params
      > get_params -> get_executed_params where possible
      > Subprocess error reporting improvements
      > Fix a recursion issue about compiled objects
      > Use a CompiledInstanceNameFilter that wraps the class name as well
      > Prefer Python 3 import over 2
      > Now it's actually possible to specify a pytest environment for the same Python version
      > Note that Python 3.3 support was dropped in Changelog
      > Drop support for EOL Python 3.3 (#1019)
      > Rewrite the pyc test
      > Fix an issue with stderr debugging of subprocesses
      > stderr of the child processes should be printed in debug output
      > Use close_fds for posix.
      > Remove some redundant code
      > Use names of classes to infer names of instances
      > Don't have execute and execute_evaluated on name
      > Fix an issue where __ prefixed variables where not hidden when accessed from a class
      > Bound methods are now working correctly in all Python versions. Therefore a test was wrong.
      > Remove a print in tests
      > BoundMethods now have access to the function that they are using
      > Remove another usage of is_class where it's not needed
      > FunctionContext should be created from a unified interface
      > Don't create a FunctionExecutionContext if it's not used.
      > Use TreeContext in a good way
      > Fix broken link in documentation
      > The implicit namespace package test from 4b276bae87a3170672f7ddb3e00f5851fe24d562 can only be used for Python 3.4+
      > The import resolution for namespace packages was wrong
      > Add a way to use the interpreter environment for tests
      > MergedExecutedParams -> DynamicExecutedParams
      > Fix a recursion error, fixes #1173
      > Remove two recursion tests again that will belong into a commit at a point where it is not failing anymore
      > Don't merge params if it's just one param
      > Add a repr for AnonymousArguments
      > Fix a doctest
      > Some minor flake8 fixes
      > Script.__repr__: include environment
      > Add params to CallSignature.__repr__
      > Environments are now always created on request
      > Improve Environment
      > Add max line length 100 to the config for flake8
      > tests: use monkeypatch.setenv
      > Don't test Python 3.3 on appveyor anymore, it's getting really hard to get all the right dependencies for it, because 3.3 is deprecated everywhere.
      > Mention that it's ok to have a line length of 100 characters in our files.
      > Don't use invalid escape sequences in regex, see https://github.com/davidhalter/jedi-vim/issues/843
      > subprocess: listen: exit normally with EOFError
      > Script: improve ValueError for column
      > The sys path might be lazy or not in a venv
      > The encoding parameter should be used again (includes test), fixes #1167
      > Remove source_encoding from documentation (see #1167)
      > Actually use the fast_parser setting again
      > Use an import name list as long as possible
      > Different _load_module API
      > Directly load modules if possible, with this it's not necessary anymore to use dotted_from_fs_path, also fixes #1013.
      > Don't mutate the sys.path. This is pretty nasty bug that fixes #1148
      > Don't follow builtin imports anymore by default when follow_imports is on (goto)
      > Add a changelog entry for the include_builtins change
      > additional_module_paths in usages never actually worked
      > Add include_builtins to usages, fixes #1131.
      > Finally make it possible to use auto_import_modules for packages
      > Test auto_import_modules in a very basic way
      > Fix a bug about fstring completion
      > Comprehensions are also possible arguments. Fixes 1146
2018-10-14 17:55:56 +02:00
Daniel Hahler
c6f05cd82c .coveragerc: concurrency = greenlet (#874)
Fixes https://github.com/neovim/python-client/issues/354
2018-08-16 16:37:00 +02:00
Daniel Hahler
132d8506ab tests: move/rename/cleanup vspec based tests (#860)
The main motivation is to being able to use normal/other pytest based
tests.

Therefore this moves everything from conftest into test_integration
itself.
2018-08-01 23:57:37 +02:00
Daniel Hahler
399c57ff72 Fix displaying of error information with shortmess+=F
When being initialized via ftplugin `set shortmess+=F` (default in
Neovim by now) causes the additional information (the full traceback) to
be silenced.

This patch uses `:unsilent` to always display it.

Ref: https://github.com/neovim/neovim/issues/8675
2018-08-01 22:50:23 +02:00
Daniel Hahler
1126ffde9b Makefile: make pip-install quiet 2018-08-01 22:50:23 +02:00
Daniel Hahler
88502891ba Report coverage (#863) 2018-07-30 22:45:06 +02:00
Dave Halter
b33392c8c8 Merge pull request #864 from blueyed/nvim (neovim testing)
Testing is now alow possible with Neovim
2018-07-30 18:09:45 +02:00
Daniel Hahler
ffec4d7fc5 Test with Neovim 2018-07-30 14:24:53 +02:00
Daniel Hahler
43a9a9b191 Fix test/signatures.vim: ensure there is no indent (nvim) 2018-07-30 14:24:53 +02:00
Daniel Hahler
e05f34646e Fix test/signatures.vim: take into account &ruler (nvim) 2018-07-30 14:24:53 +02:00
Daniel Hahler
713e78dd39 tests: harden/fix completions with regard to longest/nvim mostly 2018-07-30 14:24:53 +02:00
Daniel Hahler
e49638ffc8 Upgrade vim-vspec to 1.8.1 (#862)
This fixes some tests to make it work with the newer version.
2018-07-30 11:16:51 +02:00
Daniel Hahler
4c430ed536 Improve JediDebugInfo for envs (#858)
Improve JediDebugInfo for envs

This is taken out of https://github.com/davidhalter/jedi-vim/pull/836.
2018-07-28 01:46:12 +02:00
Daniel Hahler
40fc5ab27f test/signatures.vim: remove trailing spaces 2018-07-25 02:21:54 +02:00
Daniel Hahler
9a4a4f4074 Skip duplicate call signatures
I am seeing `p` twice for os.path.dirname, which seems to come from
Lib/posixpath.py and Lib/ntpath.py, as can be seen with `os.path.join`,
where I still see two with this patch:

```
            (path, *paths)
import os   (a, *p)
os.path.join()
```
2018-07-16 13:50:49 +02:00
Daniel Hahler
c6716c6392 Makefile: use a single venv 2018-07-15 21:22:29 +02:00
Daniel Hahler
5123dbbbc7 Fix flake8 issue 2018-07-15 20:57:27 +02:00
Daniel Hahler
ee0f759a2e qa: add flake8 to check make target 2018-07-15 20:57:27 +02:00
Daniel Hahler
66b6a20041 Factor out annotate_description
This uses d.type, but special-cases functions and statements.
2018-07-15 19:26:11 +02:00
Daniel Hahler
8e077adb2f show_goto_multi_results: use relpath
This helps Vim to display the path for unlisted buffers relative to cwd
in the quickfix list.
2018-07-15 19:26:11 +02:00
Dave Halter
e7cb9a186e Also add remove_usages on InsertEnter 2018-07-15 19:26:11 +02:00
Dave Halter
b5774a9554 Add an augroup for usages 2018-07-15 19:26:11 +02:00
Dave Halter
f0d80048f1 Remove usages after text has changed in normal mode 2018-07-15 19:26:11 +02:00
Dave Halter
9e2244c44e Use standout/reverse instead of yellow for jediUsages
It uses cterm=reverse, which is supported by current Neovim, and at
least for xterm and rxvt-unicode reverse and standout are the same.

See `infocmp`:

> smso=\E[7m / rev=\E[7m
2018-07-15 19:26:11 +02:00
Dave Halter
cc087ef463 Somehow show_goto_multi_results was called without arguments
This was obviously wrong and fixed by inserting the obvious param
2018-07-15 19:26:11 +02:00
Dave Halter
efaef9cee3 Rename was in the wrong spot when using it at the end of a line. 2018-07-15 19:26:11 +02:00
Dave Halter
58561d45f1 Fix renaming and also highlight the renamed classes. 2018-07-15 19:26:11 +02:00
Dave Halter
84b8eeb954 Highlight usages
Use matchaddpos to highlight usages in the current file.
2018-07-15 19:26:11 +02:00
Dave Halter
2bb7677b43 Make it clearer which versions make check requires 2018-07-14 15:39:02 +02:00
Dave Halter
81ada14f0b Upgrade jedi to 0.12.1, forgot to upgrade it when upgrading parso
a79a1fb Merge branch 'parso'
58141f1 Don't use requirements for now, and use the git version instead in tox
e0e2be3 Add a better comment about why people need to upgrade parso
1e7662c Prepare release of 0.12.1
68974ae Don't use internal parso APIs if possible
c208d37 Remove code that is no longer used, because parso was refactored.
3847406 Make jedi work with the next parso release
95f835a Force unicode when listing module names
282c6a2 Use highest possible pickle protocol
ea71ded Include stderr with "subprocess has crashed" exception (#1124)
106b11f Set stdout and stdin to binary mode on Python 2 and Windows
f9e90e8 Use system default buffering on Python 2
197aa22 Use cPickle on Python 2 if available
e96ebbe Add tests for DefaultDict support.
55941e5 Add support for DefaultDict on jedi_typing.py.
ff4a773 Parse correct AST attribute for version
70c2fce Replace distutils.spawn.find_executable with shutil.which
5dab97a Add an error message, see also #1139.
e2cd228 Dict comprehension items call should now work, fixes #1129
c1014e0 Fix flow analysis test
62a3f99 Fix a wrong branch check, fixes #1128
6ebe3f8 Drop 3.3 tests from travis
50812b5 A simple yield should not cause an error, fixes #1117
d10eff5 Travis: report coverage also to codecov.io
6748faa Fix _get_numpy_doc_string_cls: use cache
fc14aad Fix namespace autocompletion error
3c909a9 Travis: remove TOXENV=cov from allowed failures
b94b45c Environment._get_version: add msgs with exceptions
a95274d None/False/True are atom non-terminals in the syntax tree, fixes #1103
8d48e74 When searching submodules, use all of __path__, fixes #1105
9149956 Specially crafted docstrings sometimes lead to errors, fixes #1103
ba96c21 Follow up from the last async issue, fixes more related things about #1092.
8494164 Fix an async funcdef issue, fixes 1092.
4075c38 In some very rare cases it was possible to get an interpreter crash
because of this bug. Fixes #1087
0bcd170 Start using our own monkeypatch function for some things
ceb5509 Include function return type annotation in docstring if it is present
88243d2 Don't catch IndexError where we don't have to
5f37d08 Extend create_environment to accept an executable path
aa6857d check_fs: handle FileNotFoundError
2018-07-14 12:31:11 +02:00
Daniel Hahler
7cade1fb62 Update submodule pythonx/parso 6f385bd...e6bc924
* pythonx/parso 6f385bd...e6bc924 (44):
      > Use a setuptools that still supports py33
      > 3.1 release notes
      > Use one simple functions to check for funcdefs in diff parser
      > Make sure to treat async funcdefs the same way as normal funcdefs
      > Fix an issue in the diff parser
      > Asterisks in function definitions may be at the end of a func without a comma, fixes #44
      > Remove some TODOs that were fixed
      > Error recovery should not match the whole line in case of an invalid token, fixes #40
      > docs: enable searchbox
      > Merge branch 'pgen'
      > Merge branch 'master' of github.com:davidhalter/parso
      > Add docstring
      > Add some comments
      > Use a set instead of dict if it's not necessary
      > Simplify some code
      > Some refactorings for simplicity
      > Use NFAArc as a class
      > Some more renames
      > Another rename
      > Rename
      > Move the grammar parsing to a separate module
      > More renames
      > Rename
      > Separate generating dfas from parsing
      > Cleanup some names
      > Remove some code that is not used anymore
      > Some cleanups and documentation
      > Move out some more functions out of classes
      > Some more refactorings for clarification
      > Factor out start_symbol into a better position
      > Refactor out dfas
      > Document pgen grammars a bit better
      > addarc -> add_arc
      > Refactor some things in pgen
      > Move some initializations
      > Change license again. The year shouldn't matter
      > Make first private
      > Change copyright years
      > Remove some code from the grammar
      > Separate the grammar generation from the grammar parsing
      > In pgen now everything is named grammar and not c
      > Better recovery for online classes and functions
      > Fix one-line error recovery for all things that are using a suite
      > Add a debug function for first tokens
2018-07-10 14:46:01 +02:00
Daniel Hahler
1773837a11 syntax: use "hi def" everywhere
This allows for keeping user configuration.
2018-07-10 12:49:48 +02:00
Daniel Hahler
67fd8c6572 s:init_python: fix check for Python 2
Fixes https://github.com/davidhalter/jedi-vim/issues/841.
2018-07-08 04:31:58 +02:00
Daniel Hahler
d3d9a91ae6 init: improve handling of import errors (#840)
* jedi_vim.jedi_import_error: add location

This is useful for debugging.  It contains e.g. the path to parso, if
importing failed from there.

Example:

> Error: jedi-vim failed to initialize Python: jedi#setup_python_imports: could not import jedi: cannot import name 'PythonTokenTypes' (in /…/jedi-vim/pythonx/jedi/jedi/api/completion.py:1). (in function jedi#init_python[3]..<SNR>44_init_python[27]..jedi#setup_python_imports, line 37)

* init: handle jedi_vim.jedi_import_error in Vim plugin

Using `set shortmess+=F` would suppress the `:echom` used in
`jedi_vim.no_jedi_warning` [1].

This patch makes `jedi#setup_python_imports` handle the error instead.

1: https://github.com/neovim/neovim/issues/8675

* Revisit error handling with loading jedi_vim

* jedi#debug_info: display parso submodule separately

* Fix jedi#reinit_python

* fixup! Revisit error handling with loading jedi_vim

* display_debug_info: handle exceptions with environment.get_sys_path

* fixup! Revisit error handling with loading jedi_vim

[ci skip]
2018-07-04 22:12:07 +02:00
Daniel Hahler
0361d6c633 s:init_python: handle g:jedi#force_py_version again (#834)
It was removed previously, since it now refers to the environment being
used.

This brings it back for now.

There could be a separate var for it later, and/or it needs changes
later (or rather the environment needs a new variable name, since it
should refer to the executable really) - but this is good for now I think.

Fixes https://github.com/davidhalter/jedi-vim/issues/833
2018-07-04 17:55:25 +02:00
Dave Halter
a54729ef63 Use the official Jedi goto API instead of multiple calls
Fixes #802.
2018-07-04 00:03:11 +02:00
tobaloidee
5f98bfb62e Add logo (#837)
This has been force-pushed.

See https://github.com/davidhalter/jedi-vim/pull/837 for other variants,
and the reason for force-pushing.
2018-06-26 18:07:14 +02:00
Daniel Hahler
745dc8a559 jedi#setup_python_imports: better SyntaxError handling
Uses `repr` for SyntaxErrors.

Related: https://github.com/neovim/python-client/pull/221
2018-06-23 11:28:41 +02:00
Vivian
84a5299c8f Fix spelling error 2018-05-29 19:33:30 +02:00
Daniel Hahler
d4006ab1bf Fix s:init_python
Just check for `has('python3')` / `has('python')`.

Fixes 72a2643f7c (r28922063).
2018-05-21 23:37:14 +02:00
Daniel Hahler
ed8153ef2b Update submodule pythonx/parso 579146b...6f385bd
* pythonx/parso 579146b...6f385bd (7):
      > Not testing Python 3.3 anymore on travis. It seems to be broken
      > Add a changelog for 0.2.1
      > Push the version
      > The diff parser was slighly off with prefixes, fixes #1121
      > A better repr for the endmarker
      > Merge branch 'master' of github.com:davidhalter/parso
      > Fix a prefix issue with error leafs.
2018-05-21 23:35:42 +02:00
Daniel Hahler
f07ff6a535 Fix flake8 W605: invalid escape sequence '\{w,d}' 2018-05-10 22:40:58 +02:00
Dave Halter
6781eb17da Small documentation change 2018-05-09 16:04:47 +02:00
Dave Halter
5ad782d920 Remove a strange sentence 2018-05-09 16:04:47 +02:00
Daniel Hahler
d75aaa470e Improve jedi_vim.get_environment
- cache current environment
- s/jedi.get_python_environment/jedi.get_system_environment: the former
  does not exist (renamed in https://github.com/davidhalter/jedi/commit/336087f)
- improve error display
2018-05-09 16:04:47 +02:00
Daniel Hahler
56eb0f6d63 Improve display_debug_info 2018-05-09 16:04:47 +02:00
Dave Halter
835e329883 Some improvements for the virtualenv patch 2018-05-09 16:04:47 +02:00
Dave Halter
49fa267e59 The jedi API changed a bit 2018-05-09 16:04:47 +02:00
Dave Halter
fa1aaa10cf Fix the jedi-vim debug tool, fixes #795 2018-05-09 16:04:47 +02:00
Dave Halter
e54a17ec71 Document force_py_version better 2018-05-09 16:04:47 +02:00
Dave Halter
48a9ea085d Force the Python environment correctly 2018-05-09 16:04:47 +02:00
Dave Halter
72a2643f7c Use the environment for completions. 2018-05-09 16:04:47 +02:00
Dave Halter
57cbf1421f Somehow the virtual env prefix is set in VIM.
This basically corrupts VIM's Python, because it might be having a differnet prefix (Python 3.6) than sys path. I don't know who came up with this - probably it's just how Python loads venvs - but it's definitely not good. Fortunately we can just reset it and be happy.
2018-05-09 16:04:47 +02:00
Daniel Hahler
7894b38c0c tests: move .cache to build, rename test/_utils.vim 2018-04-19 21:55:19 +02:00
Daniel Hahler
1c3078e9f9 get_script: additional_dynamic_modules: add only listed buffers
Unlisted buffers might come e.g. from `set viminfo+=%`, and Jedi would
crash on them.

This could additionally check for them to be readable, but this should
be handled in Jedi itself anyway.
2018-04-17 23:55:30 +02:00
Daniel Hahler
79b332a3c6 Update submodule pythonx/jedi 02f238c...bd7c65d
* pythonx/jedi 02f238c...bd7c65d (413):
      > Finally fix all the get_system_environment issues
      > Fix a test
      > There's really no bin/activate needed for an environment to work
      > Document get_sys_path and change the signature of get_system_environment a bit
      > Rework the time cache.
      > Cache default environment
      > Require parso 0.2.0 at least
      > Set a release date
      > Don't install the latest pip version anymore in appveyor
      > Fix some references
      > Mention Virtualenv support in readme and features
      > Title case for Mänu :)
      > Better overview over functions in the documentation
      > A small docs correction
      > Remove the old static analysis stuff. It was never really used
      > Fix a lot of old docs code that doesn't exist anymore
      > Remove the old parser documentation (that's now part of parso)
      > Don't call it the plugin API anymore, that's confusing
      > Reorder some functions
      > Adda  lot of environment documentation to sphinx
      > find_python_environments -> find_system_environments
      > A small refactoring
      > Remove from_executable, were not really using it, yet.
      > For the second time in a row it's called creationflags not creation_flags
      > Refactor something small
      > Remove an unnecessary else
      > CREATE_NO_WINDOW was introduced in Python 3.7 and didn't exist before
      > The SameEnvironment should not load by default if it's a portable
      > Do binary comparisons to get virtualenvs working and not just venvs
      > Use the correct parameter name for creation flags
      > Add a way to generalize Popen
      > Check the windows environments in a better way
      > Fix some issues with the latest changes
      > DefaultEnvironment -> SameEnvironment
      > Better docs for Environment
      > Some docstrings
      > Make the Environment clearly non-public
      > Make some names public
      > Make sure Windows environments are safe
      > Fix the module_name issue again
      > Write a test for #1079 to avoid a regression in the future.
      > Cleanup some of the module cache stuff
      > Do not cache unimportable compiled module (#1079)
      > Merge branch 'master' of github.com:davidhalter/jedi
      > Multiple inheritance completion in Python 2 did not work
      > Give the run.py script an environment parameter
      > Fix an import
      > Merge the environment changes for Windows
      > Better tests for venvs
      > Write a test for venvs
      > Obviously Python 3 syntax cannot be used in Python 2
      > Update the changelog about f-strings
      > Use the latest parso version from master.
      > Better goto definition for fstrings
      > Fix an issue around the new grammar
      > Fix some fstring issues for now
      > Make a few modifications to always use the latest environment available.
      > Better tests for fstrings
      > With the changes in parso, f-strings are now completable
      > With the changes in parso, f-strings are now completable
      > Fix lambda dynamic param searches, fixes #1070
      > Cleanup the namespace lookups so that it also works for Python 3.7
      > Add a note about the fixed Windows tests in the changelog
      > Add micbou to AUTHORS
      > Add a badge for AppVeyor. Running tests for Windows
      > Add comment explaining why test_versions is disabled on Windows
      > Add JEDI_TEST_ENVIRONMENT_EXECUTABLE for AppVeyor
      > Add AppVeyor configuration
      > Improve venv_and_pths test
      > Properly raise broken pipe exception
      > Remove SourceLair from products, because it's a paid product
      > Add a note to the readme.
      > Fix another windows issue
      > Merge branch 'master' of github.com:davidhalter/jedi
      > Merge the windows fixes
      > Some code cleanup
      > Fix another error that surfaced in pandas
      > Fix an issue with docstrings that contain errors
      > Upgrade the wx widgets paths
      > Somehow forgot about subscriptlist. Just ignore those for now.
      > Fix the first issue in #1010
      > colorama should always color, even if it's not a shell
      > os.path.join completion speed test is sometimes slow, so give it a bit more of time
      > Fix some code_lines issues
      > Remove stdout/stderr from subprocesses (redirected to /dev/null)
      > Add the module_path again
      > Clean up the namedtuple test for #1060
      > All modules now have a code_lines attribute, see #1062
      > The release date for 0.12.0 should not be set, yet. See #1061.
      > And now remove a pep0484 function that is no longer needed
      > Some more code to a function
      > More rewriting of the pep0484 logic
      > Start moving some of the pep0484 comment code around
      > Cleanup some instance stuff
      > Better docs for funciton annotations
      > Fix an error in param comments
      > Catch parser errors instead of error recovery when splitting param comments
      > Merge branch 'function_comment' of https://github.com/wilfred/jedi into mypy-comments
      > Fix a few version issues in tests
      > Use inspect.Parameter.kind for better differentiation between param types
      > Fix REPL completion param name completion
      > Add keyword argument test for #292
      > Fix an interpreter test in Python 2
      > Clean up zombie subprocesses, fixes #1048
      > Fix an issue around __dir__ in the interpreter
      > Fix doctest for replstartup
      > Fix shell completion issues and documentation
      > Merge branch 'master' of github.com:davidhalter/jedi
      > Fix issues with default parameters in functions and classes
      > Correct mistakes of lambda names
      > eval_element -> eval_node
      > Use the correct class for params when used in names. Fixes #1006
      > Get rid of a regex warning, where escaping was not properly used in a normal string
      > Get rid of the imp library import in Python3 to avoid warnings, fixes #1001
      > Don't need the tests from #122
      > Refactor the namespace package tests
      > Add a failing test for nested PEP420 namespace packages
      > Include __init__.py files in search for the project directory, fixes #773
      > Add pytest cache to gitignore
      > Improve some documentation/a failing doctest
      > Fix the recursion error with globals
      > Always pop nodes in recursion detector
      > Globals should be looked up with the same priority as other defined nodes.
      > fix set.append syntax error
      > Add a few bits to the changelog
      > Autocompletion in comments should at least not fail
      > Fix the last async issue
      > Fix a few numpydocs tests
      > Fix some more await things
      > Fix a yield from test
      > AbstractIterableMixin -> IterableMixin
      > Support generator returns when used with yield from.
      > Show in a test that something doesn't work properly around async analysis
      > A few documentation improvements
      > Try to make the whole Builtin overwriting more abstract
      > Fix a small remaining issue in Python 2
      > Reorder tests to make the async stuff pass on all python versions
      > Fix for all python versions
      > Getting more edget cases work in 3.6 for async
      > Fix an issue with async for
      > Use the await method properly and just use it instead of some crazy things
      > Refactor the way builtins can be overwritten by jedi's own contexts
      > Move all the asynchronous contexts to a separate module
      > Fix the merge issues. Now async stuff should at least partially work
      > Merge the async branch
      > Get rid of an unused import
      > Add the name always to the script module
      > Add the travere_parents function to a utility directory
      > Fix Python 2 old-school relative imports
      > Use the project path as a prefix, because many times it's used as a higher priority than other stuff
      > Move the buildout_project stuff to a separate examples folder
      > Rename of buildout stuff
      > Small rename
      > Use generators instead of complicated return of lists
      > Some more sys path corrections.
      > Generalize the use of smart import paths
      > Better handling of smart sys path
      > Some simplifications
      > Add comments to implicit namespaces and fix some minor things.
      > Merge the implicit namespace improvement (pkgutils.itermodules modification)
      > Relative imports should be working again even when used in more special occasions. Fixes #973
      > parent_module is not needed for loading modules
      > Try to avoid CachedMetaClass for modules
      > DOn't check the parser cache, that's parso's responsibility
      > Better module loading
      > Try to put all module loading in one place including namespace packages
      > Unify load_module access
      > Prepare a test to eventually solve a relative import problem
      > Add a module cache that has a bit more capabilites
      > print_to_stderr needs to be used with one argument
      > Print errors that happen when importing certain objects
      > Use unicode literals, to avoid potential issues
      > Merge branch 'master' of github.com:davidhalter/jedi
      > Fix some more dict.get/dict.values stuff
      > Implememnt dict.values for FakeDict to avoid a recursion error. Fixes #1014.
      > Add better error reporting
      > Use a better string
      > Add better debugging for an assert, see also #1010
      > Make some things clearer about lazy contexts
      > Finding the autocompletion stack is a bit more complicated than I initially thought
      > Move the ahead of time tests to the pep0526 file
      > Fix an issue where a default value was wrongly used
      > Update the ahead of time tests
      > Fix the last remaining issues with ahead of time annotations, see #982
      > Fix a bug related to a wrong parametrization at one point
      > Merge branch 'master' of https://github.com/johannesmik/jedi
      > Force unicode on django paths
      > Forgot to add the examples folder
      > Fix a goto_assignments issue with a better internal API
      > Merge remote-tracking branch 'origin/master' into virtualenv
      > Disable predefined name analysis (if stmts) for all non-analysis tasks
      > Remove something that obviously never happened
      > Reorder some open flags for Python 2
      > inspect.signature throws weird errors sometimes, just make it a bit simpler
      > Fix the implicit namespace test
      > Undo most of the namespace changes and use module again
      > Differentiate between namespace and module as a type
      > Use Scripts for virtualenvs instead of bin for windows
      > Refactor django path support
      > Fix project path finding
      > Add a repr for Project
      > Use the PathFinder, because the FileFinder doesn't work without suffixes
      > Create the importer stuff Python2.7 and 3.3
      > Trying to use the import machinery to import jedi/parso in python3.4+
      > Better reporting of internal errors
      > Better error handling for subprocesses
      > Another merge with master
      > Get rid of a cwd to tmpdir, because with the subprocess it doesn't behave the same depending on which tests you run first
      > Hopefully the last merge with master
      > Merge with master again
      > Merge with master
      > Get rid of some potential issues when using pandas interactively
      > Clarity
      > Remove the get_default_project caching
      > Add a comment about why the project is None in the subprocess
      > evaluate.project doesn't exist anymore. Eliminated code that used it
      > At the moment, don't allow projects as an input to script
      > Remove the old project
      > Make the new project API fully work in tests
      > Try to migrate to the new project API
      > Refactor to make configuratios of sys paths easier
      > Use the evaluate.project sys path stuff for api.project
      > Cache the default project
      > A possible introduction for projects
      > Check for safe and unsafe environments when searching for them
      > Sith still used NotFoundError which doesn't exist anymore in jedi
      > Ignore pypy in travis for now
      > A path to ignore in coveragerc was wrong
      > Allowing the cov tests did not properly work. Trying again.
      > Somehow previously removed the allowed failurs of TOXENV=cov
      > Try to put env variables on one line
      > Coverage was unfortunately excluded
      > Merge with master
      > Add a comment to refactoring that it's not in active development
      > Change coveragerc a bit
      > Use Python3.4 for coverage.
      > Correct the issue about has_zlib
      > Move the zip tests to the environment
      > Only execute the zipimport tests fully if zlib is available for the environment Python.
      > Some tests that involved jedi were actually a bit wrong and only worked in certain environments.
      > Skip some 3.3 tests for travis
      > Skipping was done wrong
      > Try a bit more if modifying the PATH is now possible.
      > A comparison was wrong
      > A new version of the travis install script
      > Try to use the virtual env that was defined in the VIRTUAL_ENV variable, if possible.
      > If a subprocess gets killed by an OOM killer or whatever it should respawn and raise an InternalError
      > Merge Subprocess and CompiledSubprocess
      > Try to recover from errors that are happening in subprocesses
      > Move the default environment around
      > More travis trying
      > Better debugging for travis
      > Forgot to add the executable bit to the travis installer.
      > Experiment with travis and installing packages differently
      > The tags should be annotated if possible
      > Remove 2.6 from travis
      > Correct the travis file
      > Some refactoring to finally get tests working with py27 and 3 environments
      > Use the parser to check for certain namedtuple features
      > Use unicode strings in test to pass some tests in Python 2
      > Use Script everywhere where cwd_at is used, otherwise Python 2.7 is annoying
      > The given sys_path gets converted to unicode now in py2
      > Try to avoid the pth tests not working because of the created virtualenv in tox
      > Test if virtualenvs and pth files work
      > Move the module name searching to the subprocess
      > Move the last test out of test_regressions and delete the file
      > Move most of the regression tests into other test files
      > Cleanup test_regression tests
      > Move test_integration_keywrod to test_api/test_keyword
      > Cleanup the docstring tests
      > More test_evaluate Script fixtures
      > stdlib fixture conversions
      > More Script fixture conversions in test_evaluate
      > Migrate parso integration to script fixture
      > Use Script in more places
      > Use the Script fixture more generally
      > Differentiate between different Python versions in a specific test
      > Start replacing Script calls with a fixture
      > Monkeypatch the Unpickler in Python3.3
      > Try to pass the environment variable for JEDI_TEST_ENVIRONMENT to pytest over tox
      > Correct the two last unicode issues
      > Some repr went crazy
      > Make it more clear for debugging where dynamic search ended
      > Fix pep0484 comments
      > Better display of descriptors
      > Remove some of the last py27 errors that were caused in combination with 3.6
      > Forgot to cast a map to a list
      > Fixing more py27 stuff
      > More unicode literals
      > Use force_unicode for all sys paths
      > Add a print_to_stderr function in compatibility
      > Some more small improvements for Python 2
      > There were a few bugs in the previous commit
      > Use unicode in way more cases
      > Use unicode always for getting special objects
      > Skip the correct tests
      > Always use the parser of the environment
      > Try to test on travis with different jedi test environment variables
      > Try adding more automated tests to travis
      > Fix potential issues with py2 analysis
      > Check for bytes and unicode in dicts for Python 2
      > Eliminate is_py3 usages
      > Don't use python_version directly on evaluator anymore
      > Use unicode always in getattr
      > Fix an issue with the new behavior of special methods
      > Fix some more py36 to py27 issues
      > Refactor some things regarding Python 2 support
      > Also don't cast do a string for other names
      > Casting to str is not necessary
      > Skip tests according to the current environment
      > Remove unused keyword code
      > Do more comparisons in the subprocess
      > Use unicode in compiled access
      > Remove unused code
      > Refactor allowed_getattr_callback a bit to not raise random errors.
      > The default of one function was not actually used
      > The string_name of a Name should always be unicode
      > Refactor a bit and force unicode in some places and use an appropriate function name for it
      > Fix a test fail because of the unicode changes
      > The environment selection had a bug
      > More unicode conversions
      > Don't use getattr, use the abstractions
      > More unicode conversions
      > Avoid execution of Jedi in test setup
      > Start using a lot more unicode literals for Python 2
      > Make it possible to explicitly state the version in pytest for different envs
      > Use unicode sys paths always
      > Don't cast bytes to strings when unpickling
      > By default enable cross Python version tests in tox
      > Skip more tests if it's necessary.
      > Move the import logic to the subprocess
      > Move even more import stuff to a separate function
      > Move some import parts around to refactor it
      > Make ImplicitNamespaceContext a bit cleaner
      > Change two tests that were written in a strange way
      > Add a way to skip typing tests in non default environments
      > Use better error messages for import errors
      > Start using the new virtualenv code
      > Start using the correct parser for each environment
      > Add a way to specify environments in tox
      > Fix sys_path propagation for builtins load_module
      > A small refactoring
      > Merge branch 'master' into virtualenv
      > evaluate/docstrings.py
      > Don't import numpydoc in the beginning
      > Ignore the build directory for pytest
      > Refactor environments a bit
      > Make it possible to get the right version parser for a certain environment
      > api.virtualenv -> api.environment
      > DefaultEnvironment -> get_default_environment
      > Better support for searching python environments
      > Add an optimization around compiled dir()
      > Fix a potential issue in evaluate/stdlib
      > Cache the subprocess results
      > Remove unit test class from speed tests
      > Make get_repr static in access.
      > There was a bug in creating modules in a subprocess
      > Fix the Python 2.7 tests
      > Don't try to pickle ellipsis
      > Ignore __main__ modules
      > Use builtins_module instead of BUILTINS
      > Don't use the pickler modification anymore. That doesn't work in other python versions and was in general a bit hard to do
      > Remove the last test failures.
      > Get the subprocess mostly working
      > Don't use the create function anymore in compiled
      > Use even more subprocess accesses
      > Use the subprocess access to create acceses
      > Use access handles everywhere
      > Create a way of accessing access objects through a subprocess
      > Use a class instead of a dict in get_special_objects
      > Move get_special_object
      > Move load_module a bit around
      > Move another usage of create to builtin_from_name
      > Use sys.modules instead of __import__
      > Remove unused code
      > Start creating access objects in a different way
      > Use create_simple_object for a lot of use cases
      > Move some of the compiled.create calls to compiled.builtin_from_name
      > Move some stuff from compiled to context
      > Remove stuff from CompiledObject that didn't belong there and wasn't used
      > create_from_access -> _create_from_access
      > Refactor a bit more and remove the parent_context parameter from create_from_access
      > Isolate fake stuff a bit more
      > Simplify an if
      > Rewrite bases
      > Use create only for non access objects
      > Some simplification of _create_from_access
      > Remove the old now unused fake code
      > Fake context python code is now not the base for a lot of things anymore. It just gets executed.
      > Rename SelfNameFilter to SelfAttributeFilter
      > Simplify one if statement
      > Refactor LazyInstanceName -> SelfName
      > Fix all tests except fake docstring stuff
      > Fix a slice test with a better helper function
      > Fix a few more tests
      > Creating objects works now a bit better but is a huge mess.
      > Get a lot of tests passing
      > Make params work with access
      > Add an access abstraction (only array tests work, yet)
      > The check if we should add type completions is now a bit more obvious
      > Eliminate CompiledObject.type
      > Make some faked things private
      > Cleanup some compiled stuff.
      > Progress in executing builtin stuff in submodules.
      > Exceptions now also work over the subprocess.
      > Finally got compiled_objects and the access to them working
      > Progress when working with evaluators
      > Make the subprocesses work and return the right sys paths for the different versions
      > Make it possible to connect to a subprocess to get the sys path
      > Subprocess progress
      > Use types instead of special objects (see also #988)
      > Some subprocess progress
      > virtualenv progress
2018-04-17 23:42:11 +02:00
Daniel Hahler
24a0369d0f Update submodule pythonx/parso 2ca629a...579146b
* pythonx/parso 2ca629a...579146b (22):
      > Don't test python 2.6 in tox by default, because the newer pip versions don't support it anymore
      > Set a release date
      > Fix whitespace issues with prefixes
      > Use proper leafs for fstring start/end
      > Fix a Python 2 related issue.
      > Forgot to delete another print. WTF I'm tired
      > Unfortunately forgot to delete a print
      > Start to write a changelog for 0.2.0
      > Merge branch 'fstrings'
      > A comparison was slightly off
      > Ignore the pytest cache
      > Fix an error message change in Python 3.7
      > Fix an issue in the diff parser about endmarker newlines
      > Remove the copyright for good
      > Remove copyright years from documentation. (Closes: #25)
      > Fix typo: containes→contains
      > tox: use older pytest only for py26/py33
      > Merge branch 'master' of github.com:davidhalter/parso
      > Don't use a newer pytest version
      > The tags should be annotated if possible
      > Bump version for the next release
      > Use 3.7-dev not 3.7 for travis
2018-04-17 23:42:11 +02:00
Daniel Hahler
d430570fd0 pythonx/jedi_vim: flake8 fixes 2018-04-17 23:26:22 +02:00
Daniel Hahler
79c6172be7 Update .gitignore
- add build/ (used in Makefile)
- use .pytest-cache instead of .cache for newer pytest
2018-04-17 23:25:48 +02:00
Matthieu Méquignon
48af2afd3e [IMP] README.rst - Add a description for Vundle installation. (#781)
* [IMP] README.rst - Add a description for Vundle installation.

* [FIX] README.rst - Fix typo.
2018-02-16 11:22:10 +01:00
MaximeSauvage1
7b7e6b5859 Readme: fix stackoverflow link (#782) (#783) 2018-02-16 11:14:34 +01:00
Dave Halter
37bd03c3d5 An or is not needed
This comparison is useless, because the case where the module_path is None is already looked at in a previous if
2018-02-01 00:27:42 +01:00
Dave Halter
79ced22a37 Handle the module_path better for namespaces
See also discussion in davidhalter/jedi#1033
2018-01-30 00:16:35 +01:00
Daniel Hahler
510b1c94e4 Improve tests / failure detection (#769) 2018-01-15 08:38:35 +01:00
Daniel Hahler
6d05c25873 Factor out jedi#setup_completion (#768) 2018-01-15 08:37:35 +01:00
naronA
0b9bbc3495 fix: CheckHealth doesn't work in neovim (#765)
Squashed:

* fix: CheckHealth doesn't work in neovim

CheckHealth calls display_debug_info().
However, error occured when loading jedi_vim.jedi.Script('')._evaluator.sys_path,
because Evaluator.sys_path is unavailable variable.

* handle the both the old and new API

Evaluator.project.sys_path is temporary fix, because Evaluator.sys_path is correct API.
So, we handle the both the old and new API in preparation for merging virtualenv branch.
2017-12-30 14:03:54 +01:00
Dave Halter
31ebd30c31 Upgrade jedi and parso 2017-12-14 23:06:18 +01:00
yaegassy
3be8833913 Fix typo in jedi-vim.txt 2017-11-22 20:04:54 +01:00
Dave Halter
77924398bd Add a comment to clarify why we I used longest 2017-10-19 09:20:43 +02:00
Dave Halter
8e0cefc371 The parso sys path was not properly set 2017-10-19 09:20:43 +02:00
Dave Halter
bbd456c016 Update jedi to 0.11.0 2017-10-19 09:20:43 +02:00
Dave Halter
41507bab99 Use single quoted strings 2017-10-19 09:20:43 +02:00
Dave Halter
8b7c4cbad5 In older vim versions, noinsert and noselect didn't work
Use longest instead of them.
2017-10-19 09:20:43 +02:00
Dave Halter
65190a1856 A pyimport test failed sometimes on travis
There are sometimes slight differences in installed Python versions (and also Python versions within VIM versions).
2017-10-19 09:20:43 +02:00
Dave Halter
fb52e32238 Try installing Python3.6 in travis 2017-10-19 09:20:43 +02:00
Dave Halter
109ceeb2f8 Add the tests again to travis 2017-10-19 09:20:43 +02:00
Dave Halter
d189d8aab7 Add the parso submodule 2017-10-19 09:20:43 +02:00
Dave Halter
7e6811cb4b Fix call signature tests
Now all tests should be fixed again. Also removed a deprecated call to call_name.
2017-10-19 09:20:43 +02:00
Dave Halter
24496c1416 Remove param name in description to make call signatures a bit better 2017-10-19 09:20:43 +02:00
Dave Halter
8d547695e2 Fix goto tests 2017-10-19 09:20:43 +02:00
Dave Halter
d42f56bc82 Buffer names seem to be an empty string sometimes and not None 2017-10-19 09:20:43 +02:00
Dave Halter
192e03b335 NotFoundError was deprecated in Jedi a while ago 2017-10-19 09:20:43 +02:00
Dave Halter
1c7c9064b7 test titles don't need underscores 2017-10-19 09:20:43 +02:00
Dave Halter
85020495ef Only use the tagstack if the file actually exists
This caused problems when using jedi-vim without an actual file behind a buffer.
2017-10-19 09:20:43 +02:00
Dave Halter
edde267f6b Fix a pyimport test fail 2017-10-19 09:20:43 +02:00
Dave Halter
641c88111d Fix completion tests. 2017-10-19 09:20:43 +02:00
Dave Halter
5c6531ffae Better names for the test parametrizations 2017-10-19 09:20:43 +02:00
Dave Halter
516189c7e3 call_name was deprecated a few Jedi versions ago 2017-10-19 09:20:43 +02:00
Dave Halter
ce6b60063d Use python3.6 for tests. 2017-10-19 09:20:43 +02:00
Daniel Hahler
72c1a332d2 jedi#show_documentation: do not use quotes around bufname 2017-09-29 18:36:04 +02:00
Alexander Zhukov
c8164fdfda Enhance example installation command (#739) 2017-09-17 21:21:42 +02:00
Daniel Hahler
0c6a2b7737 README: improve FAQ for slowness, add deoplete-jedi
Ref: https://github.com/davidhalter/jedi/issues/910#issuecomment-322731875

[ci skip]
2017-08-16 22:08:59 +02:00
Daniel Hahler
60bdff8eea Move Python code for jedi#debug_info into pythonx
This allows vimlparser to parse the vim file again, and it is more
convenient to have it in a real Python file anyway.

Small refactoring and minor text changes included.
2017-08-09 23:59:52 +02:00
Daniel Hahler
ddaec5652b Lint fixes 2017-08-09 00:13:55 +02:00
Daniel Hahler
163a0b5db1 Use Vim's pythonx mechanism
Move jedi_vim.py and the jedi submodule into pythonx, which gets added
to Vim's internal sys.path.  While jedi cannot be imported directly from
there, it still makes sense for consistency.
2017-08-08 18:58:54 +02:00
Daniel Hahler
cfadac7f22 jedi#debug_info: try/catch failures from s:init_python()
This is relevant for when using `:JediDebuginfo` in a broken setup,
where the call to `jedi#init_python()` in the autoload file throws an
error already (but `jedi#debug_info` is defined/loaded before already).
2017-08-08 17:28:29 +02:00
Daniel Hahler
82661d515b Fix restoring alternate terminal with completeopt redirection
Fixes https://github.com/davidhalter/jedi-vim/issues/721.
2017-08-07 20:34:10 +02:00
Daniel Hahler
a46ea1a1eb Refactor completeopt handling
Temporarily set &completeopt before triggering automatic completion,
instead of handling different settings afterwards.
`g:jedi#popup_select_first` is used to use `noinsert` instead of
`noselect`.

Fixes https://github.com/davidhalter/jedi-vim/issues/516.
Fixes https://github.com/davidhalter/jedi-vim/issues/706.
2017-08-07 19:48:53 +02:00
Daniel Hahler
a2cf2291da Inline Python init script
Fixes https://github.com/davidhalter/jedi-vim/issues/726.
2017-08-06 21:57:10 +02:00
Daniel Hahler
dc7b6228b2 Rename initialize.py to jedi_vim_init.py
Ref: https://github.com/davidhalter/jedi-vim/issues/726#issuecomment-320505021.
2017-08-06 17:04:28 +02:00
Daniel Hahler
20312dcca8 JediDebugInfo: skip newline with no non-default settings 2017-08-06 15:08:11 +02:00
Daniel Hahler
c11b38cb48 s:init_python: use setup_py_version instead of force_py_version 2017-08-06 15:07:12 +02:00
Daniel Hahler
f1d9708f7c jedi#setup_py_version: check if init script is readable
Ref: https://github.com/davidhalter/jedi-vim/issues/726.
2017-08-06 14:48:09 +02:00
Daniel Hahler
6394614017 Define PythonJedi command always (#727)
This is meant to help in case of issues where the Python initialization
fails (https://github.com/davidhalter/jedi-vim/issues/726#issue-248054145),
so that `JediDebuginfo` can still provide some more information.
2017-08-06 01:00:51 +02:00
Daniel Hahler
6411de0cd1 auto_vim_configuration: improve check for changed completeopt setting
The user might want to use the default actually.
2017-06-10 12:38:33 +02:00
Antony Lee
0ee2ed0bc6 help: do not highlight rst indented sections as python (#717)
Fixes https://github.com/davidhalter/jedi-vim/issues/716.
2017-06-06 18:09:14 +02:00
Daniel Hahler
e2d79c6434 popup_on_dot: document that it needs completions_enabled
It would be ignored already with completions_enabled=0.
This documents it and makes the default follow it.
2017-06-03 20:49:14 +02:00
BennyYip
53358dc0fa Fix unwanted fold in __doc__ 2017-06-03 20:39:14 +02:00
David D Lowe
18af876d6b Clarify how to use minimal.vimrc to report issues (#709) 2017-05-25 14:46:44 +02:00
Dawson Botsford
40a02a7fd1 📄 Make Travis badge unpixely 2017-04-27 20:00:55 +02:00
Daniel Hahler
eef60e056a JediDebugInfo: settings: display full name 2017-04-19 23:53:11 +02:00
Daniel Hahler
8e34a59045 initialize.py: handle reloading of the plugin (#659)
Do not keep adding jedi_vim_path to sys.path.
2017-04-13 22:47:31 +02:00
Daniel Hahler
c1e279cab7 Update Jedi to 0.10.2 2017-04-06 20:13:28 +02:00
Daniel Hahler
2ee9ec64d3 Improve GitHub issue template and JediDebugInfo 2017-03-01 23:52:55 +01:00
Daniel Hahler
682f37792d Move Travis targets to Makefile
This allows for calling them easily locally.
2017-02-22 11:36:01 +01:00
Thúlio Costa
0844b14866 rename: use new Jedi interface
Fixes https://github.com/davidhalter/jedi-vim/issues/671.
Closes https://github.com/davidhalter/jedi-vim/pull/684.
2017-02-21 20:06:19 +01:00
Daniel Hahler
ac6756a466 Fix default of jedi#auto_vim_configuration back to 1 (#682)
This was broken in eba90e6.
2017-02-17 22:11:21 +01:00
Daniel Hahler
b885e10e0d Make jedi#debug_info more robust
Fixes https://github.com/davidhalter/jedi-vim/issues/675.
2017-02-15 12:14:47 +01:00
Dave Halter
0dea756fd9 Update the Jedi subrepository to 0.10.0 (#669) 2017-02-03 00:49:42 +01:00
Daniel Hahler
8cf616b088 Correctly fix return value of jedi#complete_opened (#664)
Fixes https://github.com/davidhalter/jedi-vim/issues/663.
Fixes https://github.com/davidhalter/jedi-vim/issues/667.
2017-01-31 11:12:25 +01:00
Daniel Hahler
63ecc1dbd7 Add omnifunc/completeopt to jedi#debug_info 2017-01-31 10:54:33 +01:00
Daniel Hahler
52772e171f Fix return value of jedi#complete_opened (#664)
Fixes https://github.com/davidhalter/jedi-vim/issues/663.
2017-01-31 09:25:43 +01:00
Daniel Hahler
eba90e615d Style fixes (via vint) (#662)
This also adds a augroup for `jedi#add_goto_window`.
2017-01-29 11:55:55 +01:00
Dave Halter
f100ffad4d Merge pull request #661 from blueyed/remove-obsolete-s-jedi_changedtick-and-fix-style
Remove obsolete s:jedi_changedtick and fix style
2017-01-27 19:23:51 +01:00
Daniel Hahler
702da51cbe Remove obsolete s:jedi_changedtick and fix style
It became obsolete in 794af5b, but setting it was not removed then.
2017-01-27 18:47:48 +01:00
Dave Halter
fe30fa485b Merge pull request #660 from blueyed/debuginfo-settings
jedi#debug_info: output non-default settings
2017-01-25 23:31:37 +01:00
Daniel Hahler
3582fa6bc2 jedi#debug_info: output non-default settings 2017-01-25 21:49:39 +01:00
Dave Halter
4a3dc9da84 Merge pull request #658 from blueyed/debug-info-improved
Improve :JediDebugInfo: verify that JediPython works / sys_path
2017-01-23 00:21:06 +01:00
Daniel Hahler
f99d86073b jedi#debug_info: add Jedi's sys_path
Ref: https://github.com/davidhalter/jedi/issues/828
2017-01-14 20:26:11 +01:00
Daniel Hahler
636d393114 jedi#debug_info: check that PythonJedi can be called 2017-01-14 20:25:18 +01:00
Rick van Hattem
4baf4b27f7 Update incorrect documentation url (#657)
Fixes #656.
2017-01-14 15:37:12 +01:00
Francisco Souza
3dc61513af Update jedi (#650)
Picking up support for Python 3.6
2017-01-08 23:21:00 +01:00
Daniel Hahler
80378d857b Use re.escape for the g:jedi#call_signature_escape setting (#646)
Fixes https://github.com/davidhalter/jedi-vim/issues/641.
2016-12-09 00:10:20 +01:00
Dave Halter
671f9f5780 Merge pull request #640 from Aulddays/master
Change default g:jedi#call_signature_escape to avoid collision
2016-12-05 00:52:56 +01:00
Aulddays
b96dad9d50 add to author list 2016-12-04 22:40:50 +08:00
Aulddays
a69e6b8cc0 Change default g:jedi#call_signature_escape to avoid collision
Syntax highlighting on chars in g:jedi#call_signature_escape may
break the funciton parameter hint from jedi-vim. Change its default
value to non python syntax symbols to reduce chance of collision
2016-12-04 22:13:51 +08:00
Dave Halter
f191ccd6fb Merge pull request #635 from blueyed/update-jedi
Update jedi submodule to current master
2016-11-16 18:02:45 +01:00
Daniel Hahler
8243015479 Update jedi submodule to current master
Comparison: 995a653122...2ba78ab725.
2016-11-16 13:42:24 +01:00
Daniel Hahler
01787a9988 Fix typo in README (#634) 2016-11-14 17:15:20 +01:00
Christian Geier
4ed33a8600 Fix typo in README. 2016-11-14 14:30:28 +01:00
Dave Halter
e66c2e12e6 Merge pull request #625 from blueyed/add-JediClearCache
Add JediClearCache command
2016-10-24 10:19:28 +02:00
Dave Halter
d0c3ddb9ff Merge pull request #619 from blueyed/reset-python-init-status-when-autoload-jedi.vim-is-resourced
Reset python init status when autoload/jedi.vim is resourced
2016-10-23 18:47:49 +02:00
Daniel Hahler
12db7ad364 Add JediClearCache command
This can be used to work around issues like
https://github.com/davidhalter/jedi/issues/784.
2016-10-06 19:15:52 +02:00
Dave Halter
9384d464ec Merge pull request #620 from blueyed/check-health
Hook into Neovim's :CheckHealth with jedi#debug_info
2016-09-27 20:23:56 +02:00
Daniel Hahler
d86039ea89 Hook into Neovim's :CheckHealth with jedi#debug_info
See https://github.com/neovim/neovim/blob/master/runtime/doc/pi_health.txt.
2016-09-25 18:11:06 +02:00
Daniel Hahler
b32b731767 Reset python init status when autoload/jedi.vim is resourced 2016-09-25 18:02:44 +02:00
Daniel Hahler
6a6595f5c5 Improve jedi#debug_info / :JediDebugInfo (#618) 2016-09-25 17:47:09 +02:00
Dave Halter
026ae6be03 Merge pull request #613 from otommod/patch-1
Fix doc link
2016-09-06 17:18:09 +02:00
Otto Modinos
b7163d615c Fix doc link
Stars are not correct here.
2016-09-06 17:06:32 +03:00
Dave Halter
443e7fe555 Merge pull request #608 from blueyed/github-issue-template
Add an ISSUE_TEMPLATE file for GitHub
2016-08-17 22:32:12 +02:00
Daniel Hahler
b3f7f3c0b5 fixup! fixup! Add an ISSUE_TEMPLATE file for GitHub 2016-08-17 12:25:38 +02:00
Daniel Hahler
8753bf2e16 fixup! Add an ISSUE_TEMPLATE file for GitHub 2016-08-17 12:24:05 +02:00
Dave Halter
f95ac1e8e0 Merge pull request #606 from blueyed/remove-mark-hack-for-jumplist
Do not set the '`' mark in goto
2016-08-16 23:03:14 +02:00
Daniel Hahler
f0c63f1172 Do not set the '`' mark in goto
This was meant as a hack to make the jumplist work (7520290), but it
works without it.  Maybe the underlying code to go to the definition has
been changed/improved.
Tested both in Vim (7.4.2143) and Neovim.
2016-08-16 00:52:27 +02:00
Daniel Hahler
02c2de1c51 Add an ISSUE_TEMPLATE file for GitHub 2016-08-16 00:52:17 +02:00
Daniel Hahler
99132ec545 Fix Travis: remove --use-mirrors for pip (#609)
* Travis: use sudo: false (container based builds)

* Travis: remove --use-mirrors for pip-install

The option is not valid anymore with pip 8.1.2 apparently
(https://travis-ci.org/davidhalter/jedi-vim/builds/152006664).
2016-08-16 00:51:45 +02:00
Dave Halter
5ea9ee7a63 Merge pull request #602 from blueyed/improve-jedi-load-error
Improve error msg when the jedi submodule fails to load
2016-08-06 18:23:42 +02:00
Daniel Hahler
ba0b44b65d echo_highlight: cast msg to str
This helps to avoid errors with incomplete traceback/exception details
when using it with e.g. `echo_highlight(dir(jedi))`.
2016-08-03 11:19:11 +02:00
Daniel Hahler
369284a6bc README: enhance Installation section 2016-08-03 11:18:41 +02:00
Daniel Hahler
3882c5dd32 Improve error message when the jedi module fails to load
Fixes https://github.com/davidhalter/jedi-vim/issues/560.
2016-08-03 11:08:30 +02:00
Dave Halter
c94a143bfb VIM apparently cannot deal with zero bytes in strings. Fixes #551 2016-07-30 15:59:15 +02:00
Tommy Allen
b7e42e6ad5 Fix preview autocmd being cleared for all buffers (#597)
Fixes https://github.com/davidhalter/jedi-vim/pull/582#issuecomment-235986169.
2016-07-28 23:02:21 +02:00
Dave Halter
2eabe57616 Make the equals available in the completion list, fixes #350. 2016-07-21 23:30:36 +02:00
Dave Halter
d9f92d5b24 Move the vim import to top. 2016-07-21 23:26:04 +02:00
Dave Halter
6b7dfe1c1a Merge pull request #577 from blueyed/more-robust-initialize.py
Make initialize.py more robust
2016-06-16 21:18:44 +02:00
Tommy Allen
70360437cd Prevent duplication of InsertLeave autocmds in buffers (#582) 2016-06-12 00:35:09 +02:00
Daniel Hahler
19ad3063d9 Make initialize.py more robust
Ref: https://github.com/davidhalter/jedi-vim/issues/574
2016-05-28 20:46:02 +02:00
Asher256
8334e505b3 Bug fix: E492: Not an editor command: jedi_vim.clear_call_signatures() (#576)
I got this error after I updated my local copy of jedi-vim to
the commit 'e8b88f0161ef2adabda97d4e083585a3becdcb53':
```
Error detected while processing function jedi#clear_call_signatures:
line    6:
E492: Not an editor command:     jedi_vim.clear_call_signatures()
``
`
The error below happened because 'PythonJedi' was missing before
jedi_vim.clear_call_signatures() in autoload/jedi.vim.

I put back 'PythonJedi' and it solved the issue.
2016-05-27 20:57:22 +02:00
Dave Halter
e8b88f0161 When jedi-vim cannot load jedi, show_call_signatures should not throw errors all the time. One error at the beginning is enough. 2016-05-27 13:22:37 +02:00
Dave Halter
a0c3269420 Merge pull request #557 from blueyed/vim_eval-int
Cast integers with vim_eval
2016-04-08 14:49:24 +02:00
Daniel Hahler
75e9141111 Cast integers with vim_eval
This makes it clearer/more strict altogether and is future-proof in the
sense that `vim.eval` might return integers for numbers in Vim after all.

See #553 for a very noisy discussion of what led to this.
Although it might be a regression in neovim-python after all it is good
to be on the safe side.

The bonus here is that we get "notified" in case of a option that is
expected to be an integer is a string instead.

Fixes https://github.com/davidhalter/jedi-vim/issues/553.
2016-04-08 14:37:44 +02:00
Dave Halter
5ccdd11282 Merge pull request #556 from blueyed/clarify-_catch_exception
Clarify arguments with _catch_exception
2016-04-07 22:30:42 +02:00
Dave Halter
5bcb17a8ad Merge pull request #554 from blueyed/improve-error-with-use_splits_not_buffers
minor: improve error msg with invalid use_splits_not_buffers setting
2016-04-07 22:10:08 +02:00
Daniel Hahler
0f7b743b4e Clarify arguments with _catch_exception
The whole int/string conversion with `vim.eval` is confusing enough, use
a boolean for `is_eval`.
2016-04-06 17:22:47 +02:00
Daniel Hahler
48ad42de86 minor: improve error msg with invalid use_splits_not_buffers setting
Ref: https://github.com/davidhalter/jedi-vim/issues/553
2016-04-06 14:01:03 +02:00
Daniel Hahler
0d613b5cf9 Merge pull request #549 from mozbugbox/rename-fix
Fix renaming: cursor pos and undo tracking (#545, #502)
2016-03-21 22:19:59 +01:00
mozbugbox
794af5b90a Track undo properly in rename(). Fix #502
Use vim changenr() call to track change and undo. This is more
robust than bindly call 'normal! u'
2016-03-21 09:53:57 +08:00
mozbugbox
221d7dbee4 Fix: rename() kept wrong cursor position #545
The cursor would change to something else once in the insert mode. If
the new name was longer than the old one, the Parser couldn't get
the stmt at the wrong cursor position, thus rename failed.

Now save the cursor position before entering the insert mode. Then pass
the saved position to the 2nd call to the rename().
2016-03-20 23:05:15 +08:00
Dave Halter
e7193b5e5f Merge pull request #547 from blueyed/improve-error-on-init
Improve error messages during init
2016-03-20 04:34:08 +01:00
Dave Halter
9ae6da6467 Merge pull request #548 from blueyed/use-m-with-search
jedi#smart_auto_mappings: use `\m` with `search()` for `magic`
2016-03-20 04:33:53 +01:00
Daniel Hahler
f08abefa31 jedi#smart_auto_mappings: use \m with search() for magic
With `nomagic` being set (not recommended, but might happen), the
pattern would not work.
This patch sets `\m` explicitly.
2016-03-18 23:16:07 +01:00
Daniel Hahler
cdfb7a5b4f initialize.py: catch and handle any exception when import jedi_vim
This adds the traceback to it, which then will be displayed with
`v:exception` in the Vim part.
2016-03-18 23:08:49 +01:00
Daniel Hahler
de793216f5 minor: move code out of 'try' block in jedi#setup_py_version 2016-03-18 23:07:43 +01:00
Daniel Hahler
6b8d900b05 Use echoerr in jedi#init_python
This will abort the script, instead of finishing there only.
2016-03-18 23:06:43 +01:00
Daniel Hahler
df39189578 Fix no_jedi_warning: display actual error
Never really worked as intended in 676b378.
Ref: https://github.com/davidhalter/jedi-vim/issues/460
2016-03-18 23:05:07 +01:00
Dave Halter
625c568b12 Merge pull request #527 from prologic/master
Fixes Python 2.6 compatibility issues with `str.format()`
2016-01-14 14:14:44 +01:00
James Mills
8215b220f9 Fixed Python 2.6 str.format() compatibility 2016-01-13 14:00:41 -08:00
36 changed files with 1415 additions and 686 deletions

7
.coveragerc Normal file
View File

@@ -0,0 +1,7 @@
[run]
branch = 1
# Used by/for neovim-python-client.
concurrency = greenlet
[report]
include = pythonx/jedi_*.py,test/*

44
.github/ISSUE_TEMPLATE.md vendored Normal file
View File

@@ -0,0 +1,44 @@
### Issue
<!--
Please describe the issue here.
If you are not using jedi-vim from Git (but e.g. from a distribution's package,
please try it with jedi-vim's Git master, too).
-->
### Steps to reproduce
<!--
Include if relevant.
Please provide steps to reproduce it here, preferably based on a minimal Vim
configuration.
You can use the following template (save it as `minimal.vimrc` in the directory
where jedi-vim is installed, `cd` into that directory, and run Vim with
`vim -u minimal.vimrc`):
```
set nocompatible
let script_dir = fnamemodify(expand('<sfile>'), ':h')
let &runtimepath .= ','.script_dir.','.script_dir.'/after'
" Put your config changes here.
" let g:jedi#show_call_signatures=1
syntax on
filetype plugin indent on
```
Please provide the `minimal.vimrc` you have used here, too.
-->
### Output of “:verbose JediDebugInfo”
<!--
Please execute `:redir @+> | silent verb JediDebugInfo | redir END` in a
Python buffer to copy debug information into your clipboard.
Then paste it here.
-->

4
.gitignore vendored
View File

@@ -3,4 +3,6 @@
*.py[cod]
.ropeproject
doc/tags
.cache
.pytest-cache
build
.coverage*

5
.gitmodules vendored
View File

@@ -1,3 +1,6 @@
[submodule "jedi"]
path = jedi
path = pythonx/jedi
url = https://github.com/davidhalter/jedi.git
[submodule "pythonx/parso"]
path = pythonx/parso
url = https://github.com/davidhalter/parso.git

View File

@@ -1,6 +1,34 @@
dist: xenial
language: python
python: 3.7
env:
matrix:
- ENV=test
- ENV=check
- ENV=test_coverage
matrix:
include:
- env: ENV=test_coverage
python: 2.7
install:
- pip install --quiet --use-mirrors pytest
- |
if [ "$ENV" = "test" ]; then
pip install pytest
elif [ "$ENV" = "test_coverage" ]; then
sudo add-apt-repository ppa:neovim-ppa/stable -y
sudo apt-get update -q
sudo apt-get install neovim -y
pip install pynvim pytest-cov
else
vim --version
fi
script:
- vim --version
- py.test
- make --keep-going "$ENV" BUILD_VIRTUAL_ENV=$VIRTUAL_ENV
after_success:
- |
if [ "$ENV" = "test_coverage" ]; then
coverage xml
bash <(curl -s https://codecov.io/bash) -X gcov -X coveragepy -X fix -X search -X xcode -f coverage.xml -F py${TRAVIS_PYTHON_VERSION//./}
fi

View File

@@ -49,5 +49,9 @@ Daniel Hahler (@blueyed)
Dave Honneffer (@pearofducks)
Bagrat Aznauryan (@n9code)
Tomoyuki Kashiro (@kashiro)
Tommy Allen (@tweekmonster)
Mingliang (@Aulddays)
Brian Mego (@brianmego)
Stevan Milic (@stevanmilic) <stevan.milic@yahoo.com>
@something are github user names.

35
Makefile Normal file
View File

@@ -0,0 +1,35 @@
BUILD_VIRTUAL_ENV:=build/venv
test:
pytest
test_nvim:
VSPEC_VIM=nvim pytest
test_coverage: export PYTEST_ADDOPTS:=--cov pythonx --cov test --cov-report=term-missing:skip-covered
test_coverage: test_nvim
$(dir $(BUILD_VIRTUAL_ENV)):
mkdir -p $@
$(BUILD_VIRTUAL_ENV): | $(dir $(BUILD_VIRTUAL_ENV))
python -m venv $@
$(BUILD_VIRTUAL_ENV)/bin/vint: | $(BUILD_VIRTUAL_ENV)
$|/bin/python -m pip install vim-vint==0.3.19
$(BUILD_VIRTUAL_ENV)/bin/flake8: | $(BUILD_VIRTUAL_ENV)
$|/bin/python -m pip install -q flake8==3.5.0
vint: $(BUILD_VIRTUAL_ENV)/bin/vint
$(BUILD_VIRTUAL_ENV)/bin/vint after autoload ftplugin plugin
flake8: $(BUILD_VIRTUAL_ENV)/bin/flake8
$(BUILD_VIRTUAL_ENV)/bin/flake8 pythonx/jedi_*.py
check: vint flake8
clean:
rm -rf build
.PHONY: test check clean vint flake8

View File

@@ -1,8 +1,10 @@
.. 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.png?branch=master
.. image:: https://travis-ci.org/davidhalter/jedi-vim.svg?branch=master
:target: https://travis-ci.org/davidhalter/jedi-vim
:alt: Travis-CI build status
@@ -34,11 +36,11 @@ 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.jedidjah.ch>`_.
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>`_ and tag your question with ``jedi-vim``.
<https://stackoverflow.com/questions/tagged/jedi-vim>`_ and tag your question with ``jedi-vim``.
Contributing
@@ -68,28 +70,56 @@ Apart from that, jedi-vim supports the following commands
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 in VIM. Also you
need a VIM version that was compiled with ``+python``, which is typical for most
distributions on Linux. The Python version compiled into VIM must be 2.6 or later
(you can check this from within VIM using ``:python import sys; print sys.version`` )
`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. You can
either get it via ``pip install jedi`` or with ``git submodule update --init``
in your jedi-vim repository.
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:
Example installation command using Pathogen:
.. code-block:: sh
cd ~/.vim/bundle/ && git clone --recursive https://github.com/davidhalter/jedi-vim.git
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.
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>`__.
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
@@ -202,16 +232,30 @@ Don't even think about changing the Jedi command to ``<Tab>``,
use `supertab <https://github.com/ervandew/supertab>`_!
The completion is waaay too slow!
---------------------------------
The completion is too slow!
---------------------------
Completion of complex libraries (like Numpy) should only be slow the first time
you complete it. After that, the results should be cached and very fast.
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.
If it's still slow, in case you've installed the python-mode VIM plugin, disable
it. It seems to conflict with jedi-vim. See issue `#163
<https://github.com/davidhalter/jedi-vim/issues/163>`__.
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
=======

View File

@@ -1,23 +1,3 @@
if !jedi#init_python()
finish
endif
if g:jedi#auto_initialization
if g:jedi#completions_enabled
" We need our own omnifunc, so this overrides the omnifunc set by
" $VIMRUNTIME/ftplugin/python.vim.
setlocal omnifunc=jedi#completions
" map ctrl+space for autocompletion
if g:jedi#completions_command == "<C-Space>"
" In terminals, <C-Space> sometimes equals <Nul>.
imap <buffer> <Nul> <C-Space>
smap <buffer> <Nul> <C-Space>
endif
if g:jedi#completions_command != ""
execute "inoremap <expr> <buffer> ".g:jedi#completions_command." jedi#complete_string(0)"
" A separate mapping for select mode: deletes and completes.
execute "snoremap <expr> <buffer> ".g:jedi#completions_command." '\<C-g>c'.jedi#complete_string(0)"
endif
endif
if jedi#init_python() && g:jedi#auto_initialization && g:jedi#completions_enabled
call jedi#setup_completion()
endif

View File

@@ -26,7 +26,9 @@ if g:jedi#show_call_signatures > 0 && has('conceal')
hi def link jediFunction CursorLine
hi def link jediFat TabLine
else
hi jediFunction term=NONE cterm=NONE ctermfg=6 guifg=Black gui=NONE ctermbg=0 guibg=Grey
hi jediFat term=bold,underline cterm=bold,underline gui=bold,underline ctermbg=0 guibg=#555555
hi def jediFunction term=NONE cterm=NONE ctermfg=6 guifg=Black gui=NONE ctermbg=0 guibg=Grey
hi def jediFat term=bold,underline cterm=bold,underline gui=bold,underline ctermbg=0 guibg=#555555
endif
endif
hi def jediUsage cterm=reverse gui=standout

4
autoload/health/jedi.vim Normal file
View File

@@ -0,0 +1,4 @@
function! health#jedi#check() abort
call health#report_start('jedi')
silent call jedi#debug_info()
endfunction

View File

@@ -19,22 +19,23 @@ let s:default_settings = {
\ 'goto_command': "'<leader>d'",
\ 'goto_assignments_command': "'<leader>g'",
\ 'goto_definitions_command': "''",
\ 'goto_stubs_command': "'<leader>s'",
\ 'completions_command': "'<C-Space>'",
\ 'call_signatures_command': "'<leader>n'",
\ 'usages_command': "'<leader>n'",
\ 'rename_command': "'<leader>r'",
\ 'popup_on_dot': 1,
\ 'completions_enabled': 1,
\ 'popup_on_dot': 'g:jedi#completions_enabled',
\ 'documentation_command': "'K'",
\ 'show_call_signatures': 1,
\ 'show_call_signatures_delay': 500,
\ 'call_signature_escape': "'=`='",
\ 'call_signature_escape': "'?!?'",
\ 'auto_close_doc': 1,
\ 'max_doc_height': 30,
\ 'popup_select_first': 1,
\ 'quickfix_window_height': 10,
\ 'completions_enabled': 1,
\ 'force_py_version': "'auto'",
\ 'smart_auto_mappings': 1,
\ 'smart_auto_mappings': 0,
\ 'use_tag_stack': 1
\ }
@@ -57,81 +58,83 @@ endfor
" ------------------------------------------------------------------------
let s:script_path = fnameescape(expand('<sfile>:p:h:h'))
function! s:init_python()
if g:jedi#force_py_version != 'auto'
" Always use the user supplied version.
try
return jedi#force_py_version(g:jedi#force_py_version)
catch
throw "Could not setup g:jedi#force_py_version: ".v:exception
endtry
endif
" Handle "auto" version.
if has('nvim') || (has('python') && has('python3'))
" Neovim usually has both python providers. Skipping the `has` check
" avoids starting both of them.
" Get default python version from interpreter in $PATH.
let s:def_py = system('python -c '.shellescape('import sys; sys.stdout.write(str(sys.version_info[0]))'))
if v:shell_error != 0 || !len(s:def_py)
if !exists("g:jedi#squelch_py_warning")
echohl WarningMsg
echom "Warning: jedi-vim failed to get Python version from sys.version_info: " . s:def_py
echom "Falling back to version 2."
echohl None
endif
let s:def_py = 2
elseif &verbose
echom "jedi-vim: auto-detected Python: ".s:def_py
endif
" Make sure that the auto-detected version is available in Vim.
if !has('nvim') || has('python'.(s:def_py == 2 ? '' : s:def_py))
return jedi#force_py_version(s:def_py)
endif
" Add a warning in case the auto-detected version is not available,
" usually because of a missing neovim module in a VIRTUAL_ENV.
if has('nvim')
echohl WarningMsg
echom "jedi-vim: the detected Python version (".s:def_py.")"
\ "is not functional."
\ "Is the 'neovim' module installed?"
\ "While jedi-vim will work, it might not use the"
\ "expected Python path."
echohl None
endif
endif
if has('python')
call jedi#setup_py_version(2)
elseif has('python3')
call jedi#setup_py_version(3)
" Initialize Python (PythonJedi command).
function! s:init_python() abort
" Use g:jedi#force_py_version for loading Jedi, or fall back to using
" `has()` - preferring Python 3.
let loader_version = get(g:, 'jedi#loader_py_version', g:jedi#force_py_version)
if loader_version ==# 'auto'
if has('python3')
let loader_version = 3
elseif has('python')
let loader_version = 2
else
throw "jedi-vim requires Vim with support for Python 2 or 3."
throw 'jedi-vim requires Vim with support for Python 2 or 3.'
endif
else
if loader_version =~# '^3'
let loader_version = 3
elseif loader_version =~# '^2'
let loader_version = 2
else
if !exists('g:jedi#squelch_py_warning')
echohl WarningMsg
echom printf("jedi-vim: could not determine Python loader version from 'g:jedi#loader_py_version/g:jedi#force_py_version' (%s), using 3.",
\ loader_version)
echohl None
endif
let loader_version = 3
endif
endif
call jedi#setup_python_imports(loader_version)
return 1
endfunction
function! jedi#reinit_python()
unlet! s:_init_python
function! jedi#reinit_python() abort
let s:_init_python = -1
call jedi#init_python()
endfunction
function! jedi#init_python()
if !exists('s:_init_python')
" This is meant to be called with `:unsilent` (for &shortmess+=F).
function! s:display_exception() abort
let error_lines = split(v:exception, '\n')
let msg = 'Error: jedi-vim failed to initialize Python: '
\ .error_lines[0].' (in '.v:throwpoint.')'
if len(error_lines) > 1
echohl ErrorMsg
echom 'jedi-vim error: '.error_lines[0]
for line in error_lines[1:]
echom line
endfor
echohl None
let help_cmd = ':JediDebugInfo'
if exists(':checkhealth') == 2
let help_cmd .= ' / :checkhealth'
endif
let msg .= printf('. See :messages and/or %s for more information.',
\ help_cmd)
endif
redraw " Redraw to only have the main message by default.
echoerr msg
endfunction
let s:_init_python = -1
function! jedi#init_python() abort
if s:_init_python == -1
let s:_init_python = 0
try
let s:_init_python = s:init_python()
catch
if !exists("g:jedi#squelch_py_warning")
echohl WarningMsg
echom "Error: jedi-vim failed to initialize Python: ".v:exception." (in ".v:throwpoint.")"
echohl None
let s:_init_python = 1
catch /^jedi/
" Only catch errors from jedi-vim itself here, so that for
" unexpected Python exceptions the traceback will be shown
" (e.g. with NameError in jedi#setup_python_imports's code).
if !exists('g:jedi#squelch_py_warning')
unsilent call s:display_exception()
endif
let s:_init_python = 0
endtry
endif
return s:_init_python
@@ -139,54 +142,120 @@ endfunction
let s:python_version = 'null'
function! jedi#setup_py_version(py_version)
function! jedi#setup_python_imports(py_version) abort
if a:py_version == 2
let cmd_init = 'pyfile'
let cmd_exec = 'python'
let s:python_version = 2
elseif a:py_version == 3
let cmd_init = 'py3file'
let cmd_exec = 'python3'
let s:python_version = 3
else
throw "jedi#setup_py_version: invalid py_version: ".a:py_version
throw 'jedi#setup_python_imports: invalid py_version: '.a:py_version
endif
try
execute cmd_init.' '.s:script_path.'/initialize.py'
execute 'command! -nargs=1 PythonJedi '.cmd_exec.' <args>'
let g:_jedi_init_error = 0
let init_lines = [
\ 'import vim',
\ 'try:',
\ ' import jedi_vim',
\ ' if hasattr(jedi_vim, "jedi_import_error"):',
\ ' from jedi_vim_debug import format_exc_info',
\ ' vim.vars["_jedi_init_error"] = format_exc_info(jedi_vim.jedi_import_error)',
\ 'except Exception as exc:',
\ ' from jedi_vim_debug import format_exc_info',
\ ' vim.vars["_jedi_init_error"] = format_exc_info()',
\ ]
exe 'PythonJedi exec('''.escape(join(init_lines, '\n'), "'").''')'
if g:_jedi_init_error isnot 0
throw printf('jedi#setup_python_imports: %s', g:_jedi_init_error)
endif
return 1
catch
throw "jedi#setup_py_version: ".v:exception
endtry
endfunction
function! jedi#debug_info()
echom "Using Python version:" s:python_version
endfunction
function! jedi#force_py_version(py_version)
let g:jedi#force_py_version = a:py_version
return jedi#setup_py_version(a:py_version)
endfunction
function! jedi#force_py_version_switch()
if g:jedi#force_py_version == 2
call jedi#force_py_version(3)
elseif g:jedi#force_py_version == 3
call jedi#force_py_version(2)
function! jedi#debug_info() abort
if &verbose
if &filetype !=# 'python'
echohl WarningMsg | echo 'You should run this in a buffer with filetype "python".' | echohl None
endif
endif
echo '#### Jedi-vim debug information'
echo "\n"
echo '##### jedi-vim version'
echo "\n"
echo ' - jedi-vim git version: '
echon substitute(system('git -C '.s:script_path.' describe --tags --always --dirty'), '\v\n$', '', '')
echo ' - jedi git submodule status: '
echon substitute(system('git -C '.s:script_path.' submodule status pythonx/jedi'), '\v\n$', '', '')
echo ' - parso git submodule status: '
echon substitute(system('git -C '.s:script_path.' submodule status pythonx/parso'), '\v\n$', '', '')
echo "\n"
echo '##### Global Python'
echo "\n"
echo 'Using Python version '.s:python_version.' to access Jedi.'
let pyeval = s:python_version == 3 ? 'py3eval' : 'pyeval'
let s:pythonjedi_called = 0
PythonJedi import vim; vim.command('let s:pythonjedi_called = 1')
if !s:pythonjedi_called
echohl WarningMsg
echom 'PythonJedi failed to run, likely a Python config issue.'
if exists(':checkhealth') == 2
echom 'Try :checkhealth for more information.'
endif
echohl None
else
throw "Don't know how to switch from ".g:jedi#force_py_version."!"
PythonJedi from jedi_vim_debug import display_debug_info
PythonJedi display_debug_info()
endif
echo "\n"
echo '##### Settings'
echo "\n"
echo '```'
let jedi_settings = items(filter(copy(g:), "v:key =~# '\\v^jedi#'"))
let has_nondefault_settings = 0
for [k, V] in jedi_settings
exe 'let default = '.get(s:default_settings,
\ substitute(k, '\v^jedi#', '', ''), "'-'")
" vint: -ProhibitUsingUndeclaredVariable
if default !=# V
echo printf('g:%s = %s (default: %s)', k, string(V), string(default))
unlet! V " Fix variable type mismatch with Vim 7.3.
let has_nondefault_settings = 1
endif
" vint: +ProhibitUsingUndeclaredVariable
endfor
if has_nondefault_settings
echo "\n"
endif
verb set omnifunc? completeopt?
echo '```'
if &verbose
echo "\n"
echo '#### :version'
echo '```'
version
echo '```'
echo "\n"
echo '#### :messages'
echo '```'
messages
echo '```'
echo "\n"
echo '<details><summary>:scriptnames</summary>'
echo "\n"
echo '```'
scriptnames
echo '```'
echo '</details>'
endif
endfunction
" Helper function instead of `python vim.eval()`, and `.command()` because
" these also return error definitions.
function! jedi#_vim_exceptions(str, is_eval)
function! jedi#_vim_exceptions(str, is_eval) abort
let l:result = {}
try
if a:is_eval
@@ -202,82 +271,98 @@ function! jedi#_vim_exceptions(str, is_eval)
return l:result
endfunction
if !jedi#init_python()
" Do not define any functions when Python initialization failed.
finish
endif
call jedi#init_python() " Might throw an error.
" ------------------------------------------------------------------------
" functions that call python code
" ------------------------------------------------------------------------
function! jedi#goto()
function! jedi#goto() abort
PythonJedi jedi_vim.goto(mode="goto")
endfunction
function! jedi#goto_assignments()
function! jedi#goto_assignments() abort
PythonJedi jedi_vim.goto(mode="assignment")
endfunction
function! jedi#goto_definitions()
function! jedi#goto_definitions() abort
PythonJedi jedi_vim.goto(mode="definition")
endfunction
function! jedi#usages()
PythonJedi jedi_vim.goto(mode="related_name")
function! jedi#goto_stubs() abort
PythonJedi jedi_vim.goto(mode="stubs")
endfunction
function! jedi#rename(...)
function! jedi#usages() abort
call jedi#remove_usages()
PythonJedi jedi_vim.usages()
endfunction
function! jedi#remove_usages() abort
for match in getmatches()
if stridx(match['group'], 'jediUsage') == 0
call matchdelete(match['id'])
endif
endfor
endfunction
function! jedi#rename(...) abort
PythonJedi jedi_vim.rename()
endfunction
function! jedi#rename_visual(...)
function! jedi#rename_visual(...) abort
PythonJedi jedi_vim.rename_visual()
endfunction
function! jedi#completions(findstart, base)
function! jedi#completions(findstart, base) abort
PythonJedi jedi_vim.completions()
endfunction
function! jedi#enable_speed_debugging()
function! jedi#enable_speed_debugging() abort
PythonJedi jedi_vim.jedi.set_debug_function(jedi_vim.print_to_stdout, speed=True, warnings=False, notices=False)
endfunction
function! jedi#enable_debugging()
function! jedi#enable_debugging() abort
PythonJedi jedi_vim.jedi.set_debug_function(jedi_vim.print_to_stdout)
endfunction
function! jedi#disable_debugging()
function! jedi#disable_debugging() abort
PythonJedi jedi_vim.jedi.set_debug_function(None)
endfunction
function! jedi#py_import(args)
function! jedi#py_import(args) abort
PythonJedi jedi_vim.py_import()
endfun
function! jedi#py_import_completions(argl, cmdl, pos)
function! jedi#py_import_completions(argl, cmdl, pos) abort
PythonJedi jedi_vim.py_import_completions()
endfun
function! jedi#clear_cache(bang) abort
if a:bang
PythonJedi jedi_vim.jedi.cache.clear_time_caches(True)
else
PythonJedi jedi_vim.jedi.cache.clear_time_caches(False)
endif
endfunction
" ------------------------------------------------------------------------
" show_documentation
" ------------------------------------------------------------------------
function! jedi#show_documentation()
function! jedi#show_documentation() abort
PythonJedi if jedi_vim.show_documentation() is None: vim.command('return')
let bn = bufnr("__doc__")
let bn = bufnr('__doc__')
if bn > 0
let wi=index(tabpagebuflist(tabpagenr()), bn)
if wi >= 0
" If the __doc__ buffer is open in the current tab, jump to it
silent execute (wi+1).'wincmd w'
else
silent execute "sbuffer ".bn
silent execute 'sbuffer '.bn
endif
else
split '__doc__'
split __doc__
endif
setlocal modifiable
@@ -289,31 +374,25 @@ function! jedi#show_documentation()
setlocal nomodifiable
setlocal nomodified
setlocal filetype=rst
setlocal foldlevel=200 " do not fold in __doc__
if l:doc_lines > g:jedi#max_doc_height " max lines for plugin
let l:doc_lines = g:jedi#max_doc_height
endif
execute "resize ".l:doc_lines
execute 'resize '.l:doc_lines
" quit comands
nnoremap <buffer> q ZQ
execute "nnoremap <buffer> ".g:jedi#documentation_command." ZQ"
" highlight python code within rst
unlet! b:current_syntax
syn include @rstPythonScript syntax/python.vim
" 4 spaces
syn region rstPythonRegion start=/^\v {4}/ end=/\v^( {4}|\n)@!/ contains=@rstPythonScript
" >>> python code -> (doctests)
syn region rstPythonRegion matchgroup=pythonDoctest start=/^>>>\s*/ end=/\n/ contains=@rstPythonScript
let b:current_syntax = "rst"
if len(g:jedi#documentation_command)
execute 'nnoremap <buffer> '.g:jedi#documentation_command.' ZQ'
endif
endfunction
" ------------------------------------------------------------------------
" helper functions
" ------------------------------------------------------------------------
function! jedi#add_goto_window(len)
function! jedi#add_goto_window(len) abort
set lazyredraw
cclose
let height = min([a:len, g:jedi#quickfix_window_height])
@@ -322,37 +401,40 @@ function! jedi#add_goto_window(len)
if g:jedi#use_tabs_not_buffers == 1
noremap <buffer> <CR> :call jedi#goto_window_on_enter()<CR>
endif
augroup jedi_goto_window
au!
au WinLeave <buffer> q " automatically leave, if an option is chosen
augroup END
redraw!
endfunction
function! jedi#goto_window_on_enter()
function! jedi#goto_window_on_enter() abort
let l:list = getqflist()
let l:data = l:list[line('.') - 1]
if l:data.bufnr
" close goto_window buffer
normal ZQ
normal! ZQ
PythonJedi jedi_vim.new_buffer(vim.eval('bufname(l:data.bufnr)'))
call cursor(l:data.lnum, l:data.col)
else
echohl WarningMsg | echo "Builtin module cannot be opened." | echohl None
echohl WarningMsg | echo 'Builtin module cannot be opened.' | echohl None
endif
endfunction
function! s:syn_stack()
if !exists("*synstack")
function! s:syn_stack() abort
if !exists('*synstack')
return []
endif
return map(synstack(line('.'), col('.') - 1), 'synIDattr(v:val, "name")')
return map(synstack(line('.'), col('.') - 1), "synIDattr(v:val, 'name')")
endfunc
function! jedi#do_popup_on_dot_in_highlight()
function! jedi#do_popup_on_dot_in_highlight() abort
let highlight_groups = s:syn_stack()
for a in highlight_groups
if a == 'pythonDoctest'
if a ==# 'pythonDoctest'
return 1
endif
endfor
@@ -369,7 +451,10 @@ endfunc
let s:show_call_signatures_last = [0, 0, '']
function! jedi#show_call_signatures()
function! jedi#show_call_signatures() abort
if s:_init_python == 0
return 1
endif
let [line, col] = [line('.'), col('.')]
let curline = getline(line)
let reload_signatures = 1
@@ -396,13 +481,17 @@ function! jedi#show_call_signatures()
endfunction
function! jedi#clear_call_signatures()
function! jedi#clear_call_signatures() abort
if s:_init_python == 0
return 1
endif
let s:show_call_signatures_last = [0, 0, '']
PythonJedi jedi_vim.clear_call_signatures()
endfunction
function! jedi#configure_call_signatures()
function! jedi#configure_call_signatures() abort
augroup jedi_call_signatures
autocmd! * <buffer>
if g:jedi#show_call_signatures == 2 " Command line call signatures
@@ -427,7 +516,7 @@ endfunction
" Determine where the current window is on the screen for displaying call
" signatures in the correct column.
function! s:save_first_col()
function! s:save_first_col() abort
if bufname('%') ==# '[Command Line]' || winnr('$') == 1
return 0
endif
@@ -469,48 +558,80 @@ function! s:save_first_col()
endfunction
function! jedi#complete_string(is_popup_on_dot)
if a:is_popup_on_dot && !(g:jedi#popup_on_dot && jedi#do_popup_on_dot_in_highlight())
function! jedi#complete_string(autocomplete) abort
if a:autocomplete
if !(g:jedi#popup_on_dot && jedi#do_popup_on_dot_in_highlight())
return ''
endif
endif
if pumvisible() && !a:is_popup_on_dot
return "\<C-n>"
let s:saved_completeopt = &completeopt
set completeopt-=longest
set completeopt+=menuone
set completeopt-=menu
if &completeopt !~# 'noinsert\|noselect'
" Patch 775 introduced noinsert and noselect, previously these
" options didn't exist. Setting them in earlier versions results in
" errors (E474).
if has('patch-7.4-775')
if g:jedi#popup_select_first
set completeopt+=noinsert
else
return "\<C-x>\<C-o>\<C-r>=jedi#complete_opened(".a:is_popup_on_dot.")\<CR>"
set completeopt+=noselect
endif
else
" To pass the tests we use this, it seems to get the closest to
" the other options. I'm really not sure if this properly
" works, but VIM 7.4-775 is already pretty old, so it might not
" be a problem anymore in a few years.
set completeopt+=longest
endif
endif
elseif pumvisible()
return "\<C-n>"
endif
return "\<C-x>\<C-o>\<C-r>=jedi#complete_opened(".a:autocomplete.")\<CR>"
endfunction
function! jedi#complete_opened(is_popup_on_dot)
if pumvisible()
" Only go down if it is visible, user-enabled and the longest
" option is set.
if g:jedi#popup_select_first && stridx(&completeopt, 'longest') > -1
function! jedi#complete_opened(autocomplete) abort
if a:autocomplete
let &completeopt = s:saved_completeopt
unlet s:saved_completeopt
elseif pumvisible() && g:jedi#popup_select_first && stridx(&completeopt, 'longest') > -1
return "\<Down>"
endif
if a:is_popup_on_dot
if &completeopt !~ '\(noinsert\|noselect\)'
" Prevent completion of the first entry with dot completion.
return "\<C-p>"
endif
endif
endif
return ""
return ''
endfunction
function! jedi#smart_auto_mappings()
function! jedi#smart_auto_mappings() abort
" Auto put import statement after from module.name<space> and complete
if search('^\s*from\s\+[A-Za-z0-9._]\{1,50}\%#\s*$', 'bcn', line('.'))
if search('\m^\s*from\s\+[A-Za-z0-9._]\{1,50}\%#\s*$', 'bcn', line('.'))
" Enter character and start completion.
return "\<space>import \<C-x>\<C-o>\<C-r>=jedi#complete_opened(1)\<CR>"
return "\<space>import \<C-r>=jedi#complete_string(1)\<CR>"
endif
return "\<space>"
endfunction
function! jedi#setup_completion() abort
" We need our own omnifunc, so this overrides the omnifunc set by
" $VIMRUNTIME/ftplugin/python.vim.
setlocal omnifunc=jedi#completions
" map ctrl+space for autocompletion
if g:jedi#completions_command ==# '<C-Space>'
" In terminals, <C-Space> sometimes equals <Nul>.
imap <buffer> <Nul> <C-Space>
smap <buffer> <Nul> <C-Space>
endif
if len(g:jedi#completions_command)
execute 'inoremap <expr> <buffer> '.g:jedi#completions_command.' jedi#complete_string(0)'
" A separate mapping for select mode: deletes and completes.
execute 'snoremap <expr> <buffer> '.g:jedi#completions_command." '\<C-g>c'.jedi#complete_string(0)"
endif
endfunction
"PythonJedi jedi_vim.jedi.set_debug_function(jedi_vim.print_to_stdout, speed=True, warnings=False, notices=False)
"PythonJedi jedi_vim.jedi.set_debug_function(jedi_vim.print_to_stdout)

View File

@@ -1,60 +0,0 @@
import os
import subprocess
import urllib
import zipfile
import pytest
VSPEC_URL = 'https://github.com/kana/vim-vspec/archive/1.4.1.zip'
CACHE_FOLDER = '.cache'
VSPEC_FOLDER = os.path.join(CACHE_FOLDER, 'vim-vspec-1.4.1')
VSPEC_RUNNER = os.path.join(VSPEC_FOLDER, 'bin/vspec')
TEST_DIR = 'test'
class IntegrationTestFile(object):
def __init__(self, path):
self.path = path
def run(self):
output = subprocess.check_output(
[VSPEC_RUNNER, '.', VSPEC_FOLDER, self.path])
for line in output.splitlines():
if line.startswith(b'not ok') or line.startswith(b'Error'):
pytest.fail("{} failed:\n{}".format(
self.path, output.decode('utf-8')), pytrace=False)
def __repr__(self):
return "<%s: %s>" % (type(self), self.path)
def pytest_configure(config):
if not os.path.isdir(CACHE_FOLDER):
os.mkdir(CACHE_FOLDER)
if not os.path.exists(VSPEC_FOLDER):
name, hdrs = urllib.urlretrieve(VSPEC_URL)
z = zipfile.ZipFile(name)
for n in z.namelist():
dest = os.path.join(CACHE_FOLDER, n)
destdir = os.path.dirname(dest)
if not os.path.isdir(destdir):
os.makedirs(destdir)
data = z.read(n)
if not os.path.isdir(dest):
with open(dest, 'w') as f:
f.write(data)
z.close()
os.chmod(VSPEC_RUNNER, 0o777)
def pytest_generate_tests(metafunc):
"""
:type metafunc: _pytest.python.Metafunc
"""
def collect_tests():
for f in os.listdir(TEST_DIR):
if f.endswith('.vim'):
yield IntegrationTestFile(os.path.join(TEST_DIR, f))
metafunc.parametrize('case', list(collect_tests()))

View File

@@ -60,7 +60,7 @@ Jedi-vim is a Vim binding to the awesome Python autocompletion library
- Infers function arguments from Sphinx/Epydoc strings
- Doesn't execute Python code
- Supports Virtualenv
- Supports Python 2.5+ and 3.2+
- Supports Python 2.7 and 3.4+
By leveraging this library, jedi-vim adds the following capabilities to Vim:
@@ -78,15 +78,6 @@ By leveraging this library, jedi-vim adds the following capabilities to Vim:
First of all, jedi-vim requires Vim to be compiled with the `+python` option.
The jedi library has to be installed for jedi-vim to work properly. You can
install it first, by using e.g. your distribution's package manager, or by
using pip: >
pip install jedi
However, you can also install it as a git submodule if you don't want to use
jedi for anything but this plugin. How to do this is detailed below.
It is best if you have VIM >= 7.3, compiled with the `+conceal` option. With
older versions, you will probably not see the parameter recommendation list
for functions after typing the open bracket. Some platforms (including OS X
@@ -107,11 +98,7 @@ feature (such as MacVim on OS X, which also contains a console binary).
------------------------------------------------------------------------------
2.1. Installing manually *jedi-vim-installation-manually*
1a. Get the latest repository from Github: >
git clone http://github.com/davidhalter/jedi-vim path/to/bundles/jedi-vim
1b. If you want to install jedi as a submodule instead, issue this command: >
1. If you want to install jedi as a submodule instead, issue this command: >
git clone --recursive http://github.com/davidhalter/jedi-vim
@@ -123,7 +110,7 @@ feature (such as MacVim on OS X, which also contains a console binary).
:helptags <path/to/vimruntime>/doc
------------------------------------------------------------------------------
2.1. Installing using Pathogen *jedi-vim-installation-pathogen*
2.2. Installing using Pathogen *jedi-vim-installation-pathogen*
Pathogen simplifies installation considerably.
@@ -161,8 +148,8 @@ repositories. On Arch Linux, install vim-jedi. On Debian (8+) or Ubuntu
==============================================================================
3. Supported Python features *jedi-vim-support*
The Jedi library does all the hard work behind the scenes. It supports
completion of a large number of Python features, among them:
The Jedi library does all the hard work behind the scenes. It understands most
Python features, among them:
- Builtins
- Multiple `return`s or `yield`s
@@ -185,10 +172,12 @@ completion of a large number of Python features, among them:
- Simple/usual `sys.path` modifications
- `isinstance` checks for `if`/`while`/`assert` case, that doesnt work with
Jedi
- Stubs
- And more...
Note: This list is not necessarily up to date. For a complete list of
features, please refer to the Jedi documentation at http://jedi.jedidjah.ch.
features, please refer to the Jedi documentation at
http://jedi.readthedocs.io.
==============================================================================
4. Usage *jedi-vim-usage*
@@ -308,7 +297,7 @@ Default: <leader>r Rename variables
Jedi-vim deletes the word currently under the cursor and puts Vim in insert
mode, where the user is expected to enter the new variable name. Upon leaving
insert mode, jedi-vim then renames all occurences of the old variable name
insert mode, jedi-vim then renames all occurrences of the old variable name
with the new one. The number of performed renames is displayed in the command
line.
@@ -373,6 +362,7 @@ However, when working with large modules, this can slow down your typing flow
since you have to wait for jedi to parse the module and show the completion
menu. By disabling this setting, completion is only started when you manually
press the completion key.
You need to also have `g:jedi#completions_enabled` enabled for this.
Options: 0 or 1
Default: 1 (Start completion on typing a period)
@@ -438,10 +428,10 @@ Default: 500
You can make jedi-vim open a new tab if you use the "go to", "show
definition", or "related names" commands. When you leave this at the default
(0), they open in the current buffer instead.
(0), they open in the current window instead.
Options: 0 or 1
Default: 0 (Command output is put in a new tab)
Default: 0 (Command output reuses current window)
------------------------------------------------------------------------------
6.9. `g:jedi#squelch_py_warning` *g:jedi#squelch_py_warning*
@@ -479,38 +469,37 @@ small a horizontal split happens.
------------------------------------------------------------------------------
6.12. `g:jedi#force_py_version` *g:jedi#force_py_version*
If you have installed both python 2 and python 3, you can force which one jedi
should use by setting this variable. It forces the internal Vim command, which
will be used for every jedi call to the respective python interpreter.
The variable can be set in the .vimrc like this to force python 3:
If you have installed multiple Python versions, you can force the Python
version that is going to be used.
You don't have to compile VIM with multiple Python versions.
The variable can be set in the .vimrc like this to force python 2:
let g:jedi#force_py_version = 3
let g:jedi#force_py_version = 2
This variable can be switched during runtime using the following function:
Function: `jedi#force_py_version_switch()`
By default jedi loads the latest Python version installed on your system that
can be found.
or set directly using this function, which has the same name as the variable:
Function: `jedi#force_py_version(py_version)`
This variable can be changed during runtime.
Options: 2 or 3
Default: "auto" (will use sys.version_info from "python" in your $PATH)
Options: 2, 2.7, 3, 3.5, 3.6, ...
Default: "auto"
------------------------------------------------------------------------------
6.13. `g:jedi#smart_auto_mappings` *g:jedi#smart_auto_mappings*
When you start typing `from module.name<space>` jedi-vim automatically
adds the "import" statement and displays the autocomplete popup.
can add the "import" statement and trigger the autocompletion popup.
This option can be disabled in the .vimrc:
`let g:jedi#smart_auto_mappings = 0`
You can enable this using: >
let g:jedi#smart_auto_mappings = 1
<
Options: 0 or 1
Default: 1 (enabled by default)
Default: 0 (disabled by default)
------------------------------------------------------------------------------
6.14. `g:jedi#use_tag_stack` *g:jedi#use_tag_stack*
Write results of |jedi#goto| to a temporary file and use the *:tjump* command
Write results of |jedi#goto| to a temporary file and use the |:tjump| command
to enable full |tagstack| functionality. Use of the tag stack allows
returning to the usage of a function with CTRL-T after exploring the
definition with arbitrary changes to the |jumplist|.

140
doc/logotype-a.svg Normal file
View File

@@ -0,0 +1,140 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_2" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="897.845px" height="247.51px" viewBox="0 0 897.845 247.51" enable-background="new 0 0 897.845 247.51"
xml:space="preserve">
<g>
<g>
<linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="287.3965" y1="65.2686" x2="287.3965" y2="106.4546">
<stop offset="0" style="stop-color:#E27817"/>
<stop offset="0.3906" style="stop-color:#E47519"/>
<stop offset="0.7116" style="stop-color:#E96B1F"/>
<stop offset="1" style="stop-color:#F15A29"/>
</linearGradient>
<polygon fill="url(#SVGID_1_)" points="285.068,66.556 272.054,95.664 302.739,95.664 302.739,66.556 "/>
<linearGradient id="SVGID_2_" gradientUnits="userSpaceOnUse" x1="216.8877" y1="65.2686" x2="216.8877" y2="106.4546">
<stop offset="0" style="stop-color:#E27817"/>
<stop offset="0.3906" style="stop-color:#E47519"/>
<stop offset="0.7116" style="stop-color:#E96B1F"/>
<stop offset="1" style="stop-color:#F15A29"/>
</linearGradient>
<polygon fill="url(#SVGID_2_)" points="180.483,95.664 193.893,95.664 240.172,95.664 253.292,66.556 180.483,66.556 "/>
<g>
<polygon fill="#019733" points="256.464,59.293 253.603,65.696 253.593,65.696 253.197,66.592 240.172,95.7 215.738,150.321
199.788,185.978 231.676,185.978 231.676,185.969 272.071,95.7 275.634,87.737 285.089,66.592 288.355,59.293 "/>
</g>
<g>
<polygon fill="#019733" points="215.738,150.321 194.605,95.7 180.483,95.7 180.483,135.118 199.788,185.969 199.788,185.978
"/>
</g>
<path fill="#019733" d="M151.355,59.294v100.005h-28.989h-11.292v-7.972c3.644-4.232,6.749-9.936,6.749-16.218
c0-2.846-0.456-5.578-1.294-8.104h0.011l-4.274-12.151c-0.238-1.16-0.633-2.257-1.15-3.281v-0.032l-5.878-11.59
c-1.201-2.808-3.975-4.897-7.34-5.362c0.281-4.969,2.837-8.87,5.932-8.87l-3.137-1.004l3.137-3.033
c-5.01,0-9.098,5.775-9.388,13.021c-3.116,0.609-5.672,2.598-6.79,5.258l-5.723,11.271c-0.052,0.104-0.104,0.197-0.155,0.3v0.01
c-0.528,1.057-0.932,2.174-1.169,3.344l-4.232,12.079c-0.012,0.02-0.012,0.03-0.021,0.042c-0.828,2.525-1.294,5.258-1.294,8.104
c0,6.282,3.25,11.985,6.904,16.218v35.616h29.112h11.294h58.105V59.294H151.355z M86.554,117.834
c-0.673,2.019-2.442,3.252-3.954,2.744c-1.51-0.508-2.194-2.547-1.521-4.565c0.673-2.017,2.443-3.25,3.953-2.742
C86.544,113.777,87.228,115.817,86.554,117.834z M110.163,120.578c-1.51,0.508-3.27-0.726-3.954-2.744
c-0.672-2.017,0.011-4.057,1.521-4.563c1.512-0.508,3.282,0.726,3.955,2.742C112.357,118.031,111.674,120.07,110.163,120.578z"/>
<linearGradient id="SVGID_3_" gradientUnits="userSpaceOnUse" x1="134.6348" y1="65.2686" x2="134.6348" y2="106.4546">
<stop offset="0" style="stop-color:#E27817"/>
<stop offset="0.3906" style="stop-color:#E47519"/>
<stop offset="0.7116" style="stop-color:#E96B1F"/>
<stop offset="1" style="stop-color:#F15A29"/>
</linearGradient>
<polygon fill="url(#SVGID_3_)" points="151.292,66.556 117.914,66.556 117.914,95.664 145.981,95.664 151.292,95.664
151.355,95.664 151.355,66.592 151.292,66.592 "/>
<g opacity="0.5">
<linearGradient id="SVGID_4_" gradientUnits="userSpaceOnUse" x1="244.0713" y1="198.6924" x2="244.0713" y2="111.1674">
<stop offset="0" style="stop-color:#019733"/>
<stop offset="0.1363" style="stop-color:#0B732D;stop-opacity:0.8637"/>
<stop offset="0.2826" style="stop-color:#145529;stop-opacity:0.7174"/>
<stop offset="0.4366" style="stop-color:#1A3D25;stop-opacity:0.5634"/>
<stop offset="0.5997" style="stop-color:#1F2C22;stop-opacity:0.4003"/>
<stop offset="0.778" style="stop-color:#222221;stop-opacity:0.222"/>
<stop offset="1" style="stop-color:#231F20;stop-opacity:0"/>
</linearGradient>
<polygon fill="url(#SVGID_4_)" points="256.464,59.293 253.603,65.696 253.593,65.696 253.197,66.592 240.172,95.7
215.738,150.321 199.788,185.978 231.676,185.978 231.676,185.969 272.071,95.7 275.634,87.737 285.089,66.592 288.355,59.293
"/>
</g>
<linearGradient id="SVGID_5_" gradientUnits="userSpaceOnUse" x1="165.9131" y1="41.1123" x2="165.9131" y2="128.6277">
<stop offset="0" style="stop-color:#019733"/>
<stop offset="0.1363" style="stop-color:#0B732D;stop-opacity:0.8637"/>
<stop offset="0.2826" style="stop-color:#145529;stop-opacity:0.7174"/>
<stop offset="0.4366" style="stop-color:#1A3D25;stop-opacity:0.5634"/>
<stop offset="0.5997" style="stop-color:#1F2C22;stop-opacity:0.4003"/>
<stop offset="0.778" style="stop-color:#222221;stop-opacity:0.222"/>
<stop offset="1" style="stop-color:#231F20;stop-opacity:0"/>
</linearGradient>
<rect x="151.355" y="59.294" opacity="0.5" fill="url(#SVGID_5_)" width="29.116" height="127.649"/>
<g opacity="0.58">
<linearGradient id="SVGID_6_" gradientUnits="userSpaceOnUse" x1="198.1104" y1="83.4141" x2="198.1104" y2="154.2879">
<stop offset="0" style="stop-color:#019733"/>
<stop offset="0.0409" style="stop-color:#038E32;stop-opacity:0.9591"/>
<stop offset="0.2465" style="stop-color:#0F662B;stop-opacity:0.7535"/>
<stop offset="0.4491" style="stop-color:#184726;stop-opacity:0.5509"/>
<stop offset="0.6453" style="stop-color:#1E3123;stop-opacity:0.3547"/>
<stop offset="0.8322" style="stop-color:#222421;stop-opacity:0.1678"/>
<stop offset="1" style="stop-color:#231F20;stop-opacity:0"/>
</linearGradient>
<polygon fill="url(#SVGID_6_)" points="215.738,150.321 194.605,95.7 180.483,95.7 180.483,135.118 199.788,185.969
199.788,185.978 "/>
</g>
<linearGradient id="SVGID_7_" gradientUnits="userSpaceOnUse" x1="127.7627" y1="192.1367" x2="127.7627" y2="137.5901">
<stop offset="0" style="stop-color:#019733"/>
<stop offset="0.0409" style="stop-color:#038E32;stop-opacity:0.9591"/>
<stop offset="0.2465" style="stop-color:#0F662B;stop-opacity:0.7535"/>
<stop offset="0.4491" style="stop-color:#184726;stop-opacity:0.5509"/>
<stop offset="0.6453" style="stop-color:#1E3123;stop-opacity:0.3547"/>
<stop offset="0.8322" style="stop-color:#222421;stop-opacity:0.1678"/>
<stop offset="1" style="stop-color:#231F20;stop-opacity:0"/>
</linearGradient>
<path opacity="0.6" fill="url(#SVGID_7_)" d="M151.355,59.294v100.005h-28.989h-11.292v-7.972
c3.644-4.232,6.749-9.936,6.749-16.218c0-2.846-0.456-5.578-1.294-8.104h0.011l-4.274-12.151c-0.238-1.16-0.633-2.257-1.15-3.281
v-0.032l-5.878-11.59c-1.201-2.808-3.975-4.897-7.34-5.362c0.281-4.969,2.837-8.87,5.932-8.87l-3.137-1.004l3.137-3.033
c-5.01,0-9.098,5.775-9.388,13.021c-3.116,0.609-5.672,2.598-6.79,5.258l-5.723,11.271c-0.052,0.104-0.104,0.197-0.155,0.3v0.01
c-0.528,1.057-0.932,2.174-1.169,3.344l-4.232,12.079c-0.012,0.02-0.012,0.03-0.021,0.042c-0.828,2.525-1.294,5.258-1.294,8.104
c0,6.282,3.25,11.985,6.904,16.218v35.616h29.112h11.294h58.105V59.294H151.355z M86.554,117.834
c-0.673,2.019-2.442,3.252-3.954,2.744c-1.51-0.508-2.194-2.547-1.521-4.565c0.673-2.017,2.443-3.25,3.953-2.742
C86.544,113.777,87.228,115.817,86.554,117.834z M110.163,120.578c-1.51,0.508-3.27-0.726-3.954-2.744
c-0.672-2.017,0.011-4.057,1.521-4.563c1.512-0.508,3.282,0.726,3.955,2.742C112.357,118.031,111.674,120.07,110.163,120.578z"/>
<g opacity="0.5">
<linearGradient id="SVGID_8_" gradientUnits="userSpaceOnUse" x1="244.0713" y1="53.3584" x2="244.0713" y2="78.0277">
<stop offset="0" style="stop-color:#019733"/>
<stop offset="0.1363" style="stop-color:#0B732D;stop-opacity:0.8637"/>
<stop offset="0.2826" style="stop-color:#145529;stop-opacity:0.7174"/>
<stop offset="0.4366" style="stop-color:#1A3D25;stop-opacity:0.5634"/>
<stop offset="0.5997" style="stop-color:#1F2C22;stop-opacity:0.4003"/>
<stop offset="0.778" style="stop-color:#222221;stop-opacity:0.222"/>
<stop offset="1" style="stop-color:#231F20;stop-opacity:0"/>
</linearGradient>
<polygon fill="url(#SVGID_8_)" points="256.464,59.293 253.603,65.696 253.593,65.696 253.197,66.592 240.172,95.7
215.738,150.321 199.788,185.978 231.676,185.978 231.676,185.969 272.071,95.7 275.634,87.737 285.089,66.592 288.355,59.293
"/>
</g>
<polygon fill="#019733" points="180.483,59.198 183.329,66.556 180.471,66.556 "/>
<polygon fill="#019733" points="180.483,59.198 183.329,66.556 180.471,66.556 "/>
<g>
<polygon fill="#019733" points="290.713,66.592 285.054,66.592 288.32,59.293 "/>
<polygon fill="#019733" points="308.417,120.554 283.562,95.7 300.261,95.7 "/>
<polygon opacity="0.6" fill="#019733" points="308.417,120.554 283.562,95.7 300.261,95.7 "/>
<polygon fill="#019733" points="290.713,66.592 285.054,66.592 288.32,59.293 "/>
</g>
</g>
<g>
<path fill="#666666" d="M358.849,130.077v23.827h28.81V77.887h16.547v91.732h-62.987v-39.542H358.849z"/>
<path fill="#666666" d="M434.61,93.602v22.677h45.356v14.949H434.61v22.677h45.356v15.715h-62.987V77.887h62.987v15.715H434.61z"
/>
<path fill="#666666" d="M492.744,169.619V77.887h56.342l6.643,8.05v75.634l-6.579,8.049H492.744z M539.184,93.602h-28.811v60.303
h28.811V93.602z"/>
<path fill="#666666" d="M586.136,169.619h-17.632V77.887h17.632V169.619z"/>
<path fill="#666666" d="M598.913,116.278h33.281v14.949h-33.281V116.278z"/>
<path fill="#666666" d="M691.412,77.887h16.544l-19.995,91.732h-21.462l-21.527-91.732h17.63l13.798,70.588L691.412,77.887z"/>
<path fill="#666666" d="M738.364,169.619h-17.631V77.887h17.631V169.619z"/>
<path fill="#666666" d="M768.77,169.619h-17.632V77.887h17.632l17.886,50.273l18.59-50.273h16.545v91.732h-16.545v-38.392
l-12.84,38.392h-10.35l-13.286-38.392V169.619z"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 9.8 KiB

View File

@@ -7,26 +7,29 @@ endif
if g:jedi#auto_initialization
" goto / get_definition / usages
if g:jedi#goto_command != ''
execute "nnoremap <buffer> ".g:jedi#goto_command." :call jedi#goto()<CR>"
if len(g:jedi#goto_command)
execute 'nnoremap <buffer> '.g:jedi#goto_command.' :call jedi#goto()<CR>'
endif
if g:jedi#goto_assignments_command != ''
execute "nnoremap <buffer> ".g:jedi#goto_assignments_command." :call jedi#goto_assignments()<CR>"
if len(g:jedi#goto_assignments_command)
execute 'nnoremap <buffer> '.g:jedi#goto_assignments_command.' :call jedi#goto_assignments()<CR>'
endif
if g:jedi#goto_definitions_command != ''
execute "nnoremap <buffer> ".g:jedi#goto_definitions_command." :call jedi#goto_definitions()<CR>"
if len(g:jedi#goto_definitions_command)
execute 'nnoremap <buffer> '.g:jedi#goto_definitions_command.' :call jedi#goto_definitions()<CR>'
endif
if g:jedi#usages_command != ''
execute "nnoremap <buffer> ".g:jedi#usages_command." :call jedi#usages()<CR>"
if len(g:jedi#goto_stubs_command)
execute 'nnoremap <buffer> '.g:jedi#goto_stubs_command.' :call jedi#goto_stubs()<CR>'
endif
if len(g:jedi#usages_command)
execute 'nnoremap <buffer> '.g:jedi#usages_command.' :call jedi#usages()<CR>'
endif
" rename
if g:jedi#rename_command != ''
execute "nnoremap <buffer> ".g:jedi#rename_command." :call jedi#rename()<CR>"
execute "vnoremap <buffer> ".g:jedi#rename_command." :call jedi#rename_visual()<CR>"
if len(g:jedi#rename_command)
execute 'nnoremap <buffer> '.g:jedi#rename_command.' :call jedi#rename()<CR>'
execute 'vnoremap <buffer> '.g:jedi#rename_command.' :call jedi#rename_visual()<CR>'
endif
" documentation/pydoc
if g:jedi#documentation_command != ''
execute "nnoremap <silent> <buffer>".g:jedi#documentation_command." :call jedi#show_documentation()<CR>"
if len(g:jedi#documentation_command)
execute 'nnoremap <silent> <buffer>'.g:jedi#documentation_command.' :call jedi#show_documentation()<CR>'
endif
if g:jedi#show_call_signatures > 0 && has('conceal')
@@ -43,6 +46,12 @@ if g:jedi#auto_initialization
if g:jedi#auto_close_doc
" close preview if its still open after insert
autocmd InsertLeave <buffer> if pumvisible() == 0|pclose|endif
augroup jedi_preview
autocmd! InsertLeave <buffer> if pumvisible() == 0|pclose|endif
augroup END
endif
augroup jedi_usages
autocmd! TextChanged <buffer> call jedi#remove_usages()
autocmd! InsertEnter <buffer> call jedi#remove_usages()
augroup END
endif

View File

@@ -1,22 +0,0 @@
''' ------------------------------------------------------------------------
Python initialization
---------------------------------------------------------------------------
here we initialize the jedi stuff '''
import vim
# update the system path, to include the jedi path
import sys
import os
# vim.command('echom expand("<sfile>:p:h:h")') # broken, <sfile> inside function
# sys.path.insert(0, os.path.join(vim.eval('expand("<sfile>:p:h:h")'), 'jedi'))
sys.path.insert(0, os.path.join(vim.eval('expand(s:script_path)'), 'jedi'))
# to display errors correctly
import traceback
# update the sys path to include the jedi_vim script
sys.path.insert(0, vim.eval('expand(s:script_path)'))
import jedi_vim
sys.path.pop(1)

1
jedi

Submodule jedi deleted from 995a653122

View File

@@ -4,23 +4,46 @@
" This part of the software is just the vim interface. The really big deal is
" the Jedi Python library.
if !exists("g:jedi#auto_vim_configuration") || g:jedi#auto_vim_configuration
if get(g:, 'jedi#auto_vim_configuration', 1)
" jedi-vim doesn't work in compatible mode (vim script syntax problems)
if &compatible
" vint: -ProhibitSetNoCompatible
set nocompatible
" vint: +ProhibitSetNoCompatible
endif
" jedi-vim really needs, otherwise jedi-vim cannot start.
filetype plugin on
" Change completeopt, but only if it has Vim's default value.
let s:save_completeopt=&completeopt
set completeopt&
let s:default_completeopt=&completeopt
let &completeopt=s:save_completeopt
if s:default_completeopt == &completeopt
augroup jedi_pyi
au!
autocmd BufNewFile,BufRead *.pyi set filetype=python
augroup END
" Change completeopt, but only if it was not set already.
" This gets done on VimEnter, since otherwise Vim fails to restore the
" screen. Neovim is not affected, this is likely caused by using
" :redir/execute() before the (alternate) terminal is configured.
function! s:setup_completeopt()
if exists('*execute')
let completeopt = execute('silent verb set completeopt?')
else
redir => completeopt
silent verb set completeopt?
redir END
endif
if len(split(completeopt, '\n')) == 1
set completeopt=menuone,longest,preview
endif
endfunction
if has('nvim')
call s:setup_completeopt()
else
augroup jedi_startup
au!
autocmd VimEnter * call s:setup_completeopt()
augroup END
endif
if len(mapcheck('<C-c>', 'i')) == 0
inoremap <C-c> <ESC>
@@ -30,6 +53,21 @@ endif
" Pyimport command
command! -nargs=1 -complete=custom,jedi#py_import_completions Pyimport :call jedi#py_import(<q-args>)
command! -nargs=0 JediDebugInfo call jedi#debug_info()
function! s:jedi_debug_info()
" Ensure the autoload file has been loaded (and ignore any errors, which
" will be displayed with the debug info).
let unset = {}
let saved_squelch_py_warning = get(g:, 'jedi#squelch_py_warning', unset)
let g:jedi#squelch_py_warning = 1
call jedi#init_python()
if saved_squelch_py_warning is unset
unlet g:jedi#squelch_py_warning
else
let g:jedi#squelch_py_warning = saved_squelch_py_warning
endif
call jedi#debug_info()
endfunction
command! -nargs=0 -bar JediDebugInfo call s:jedi_debug_info()
command! -nargs=0 -bang JediClearCache call jedi#clear_cache(<bang>0)
" vim: set et ts=4:

View File

@@ -1,3 +0,0 @@
[pytest]
# Ignore all files
norecursedirs = *

1
pythonx/jedi Submodule

Submodule pythonx/jedi added at 60415033b4

View File

@@ -15,6 +15,7 @@ try:
except ImportError:
from itertools import izip_longest as zip_longest # Python 2
import vim
is_py3 = sys.version_info[0] >= 3
if is_py3:
@@ -24,15 +25,27 @@ else:
ELLIPSIS = u""
try:
# Somehow sys.prefix is set in combination with VIM and virtualenvs.
# However the sys path is not affected. Just reset it to the normal value.
sys.prefix = sys.base_prefix
sys.exec_prefix = sys.base_exec_prefix
except AttributeError:
# If we're not in a virtualenv we don't care. Everything is fine.
pass
class PythonToVimStr(unicode):
""" Vim has a different string implementation of single quotes """
__slots__ = []
def __new__(cls, obj, encoding='UTF-8'):
if is_py3 or isinstance(obj, unicode):
if not (is_py3 or isinstance(obj, unicode)):
obj = unicode.__new__(cls, obj, encoding)
# Vim cannot deal with zero bytes:
obj = obj.replace('\0', '\\0')
return unicode.__new__(cls, obj)
else:
return unicode.__new__(cls, obj, encoding)
def __repr__(self):
# this is totally stupid and makes no sense but vim/python unicode
@@ -62,46 +75,52 @@ def _catch_exception(string, is_eval):
Interface between vim and python calls back to it.
Necessary, because the exact error message is not given by `vim.error`.
"""
e = 'jedi#_vim_exceptions(%s, %s)'
result = vim.eval(e % (repr(PythonToVimStr(string, 'UTF-8')), is_eval))
result = vim.eval('jedi#_vim_exceptions({0}, {1})'.format(
repr(PythonToVimStr(string, 'UTF-8')), int(is_eval)))
if 'exception' in result:
raise VimError(result['exception'], result['throwpoint'], string)
return result['result']
def vim_command(string):
_catch_exception(string, 0)
_catch_exception(string, is_eval=False)
def vim_eval(string):
return _catch_exception(string, 1)
return _catch_exception(string, is_eval=True)
def no_jedi_warning(error=None):
msg = "Please install Jedi if you want to use jedi-vim."
vim.command('echohl WarningMsg')
vim.command('echom "Please install Jedi if you want to use jedi-vim."')
if error:
msg = '{} The error was: {}'.format(msg, error)
vim.command('echohl WarningMsg'
'| echom "Please install Jedi if you want to use jedi-vim."'
'| echohl None')
vim.command('echom "The error was: {0}"'.format(error))
vim.command('echohl None')
def echo_highlight(msg):
vim_command('echohl WarningMsg | echom "{}" | echohl None'.format(
msg.replace('"', '\\"')))
vim_command('echohl WarningMsg | echom "jedi-vim: {0}" | echohl None'.format(
str(msg).replace('"', '\\"')))
import vim
jedi_path = os.path.join(os.path.dirname(__file__), 'jedi')
sys.path.insert(0, jedi_path)
parso_path = os.path.join(os.path.dirname(__file__), 'parso')
sys.path.insert(0, parso_path)
try:
import jedi
except ImportError as e:
no_jedi_warning(str(e))
except ImportError:
jedi = None
jedi_import_error = sys.exc_info()
else:
try:
version = jedi.__version__
except Exception as e: # e.g. AttributeError
echo_highlight("Could not load jedi python module: {}".format(e))
echo_highlight(
"Error when loading the jedi python module ({0}). "
"Please ensure that Jedi is installed correctly (see Installation "
"in the README.".format(e))
jedi = None
else:
if isinstance(version, str):
@@ -110,6 +129,9 @@ else:
version = utils.version_info()
if version < (0, 7):
echo_highlight('Please update your Jedi version, it is too old.')
finally:
sys.path.remove(jedi_path)
sys.path.remove(parso_path)
def catch_and_print_exceptions(func):
@@ -135,18 +157,68 @@ def _check_jedi_availability(show_error=False):
return func_receiver
current_environment = (None, None)
def get_environment(use_cache=True):
global current_environment
vim_force_python_version = vim_eval("g:jedi#force_py_version")
if use_cache and vim_force_python_version == current_environment[0]:
return current_environment[1]
environment = None
if vim_force_python_version == "auto":
environment = jedi.api.environment.get_cached_default_environment()
else:
force_python_version = vim_force_python_version
if '0000' in force_python_version or '9999' in force_python_version:
# It's probably a float that wasn't shortened.
try:
force_python_version = "{:.1f}".format(float(force_python_version))
except ValueError:
pass
elif isinstance(force_python_version, float):
force_python_version = "{:.1f}".format(force_python_version)
try:
environment = jedi.get_system_environment(force_python_version)
except jedi.InvalidPythonEnvironment as exc:
environment = jedi.api.environment.get_cached_default_environment()
echo_highlight(
"force_python_version=%s is not supported: %s - using %s." % (
vim_force_python_version, str(exc), str(environment)))
current_environment = (vim_force_python_version, environment)
return environment
def get_known_environments():
"""Get known Jedi environments."""
envs = list(jedi.api.environment.find_virtualenvs())
envs.extend(jedi.api.environment.find_system_environments())
return envs
@catch_and_print_exceptions
def get_script(source=None, column=None):
jedi.settings.additional_dynamic_modules = \
[b.name for b in vim.buffers if b.name is not None and b.name.endswith('.py')]
jedi.settings.additional_dynamic_modules = [
b.name for b in vim.buffers if (
b.name is not None and
b.name.endswith('.py') and
b.options['buflisted'])]
if source is None:
source = '\n'.join(vim.current.buffer)
row = vim.current.window.cursor[0]
if column is None:
column = vim.current.window.cursor[1]
buf_path = vim.current.buffer.name
encoding = vim_eval('&encoding') or 'latin1'
return jedi.Script(source, row, column, buf_path, encoding)
return jedi.Script(
source, row, column, buf_path,
encoding=vim_eval('&encoding') or 'latin1',
environment=get_environment(),
)
@_check_jedi_availability(show_error=False)
@@ -155,12 +227,12 @@ def completions():
row, column = vim.current.window.cursor
# Clear call signatures in the buffer so they aren't seen by the completer.
# Call signatures in the command line can stay.
if vim_eval("g:jedi#show_call_signatures") == '1':
if int(vim_eval("g:jedi#show_call_signatures")) == 1:
clear_call_signatures()
if vim.eval('a:findstart') == '1':
count = 0
for char in reversed(vim.current.line[:column]):
if not re.match('[\w\d]', char):
if not re.match(r'[\w\d]', char):
break
count += 1
vim.command('return %i' % (column - count))
@@ -184,7 +256,7 @@ def completions():
out = []
for c in completions:
d = dict(word=PythonToVimStr(c.name[:len(base)] + c.complete),
abbr=PythonToVimStr(c.name),
abbr=PythonToVimStr(c.name_with_symbols),
# stuff directly behind the completion
menu=PythonToVimStr(c.description),
info=PythonToVimStr(c.docstring()), # docstr
@@ -216,59 +288,48 @@ def tempfile(content):
finally:
os.unlink(f.name)
@_check_jedi_availability(show_error=True)
@catch_and_print_exceptions
def goto(mode="goto", no_output=False):
def goto(mode="goto"):
"""
:param str mode: "related_name", "definition", "assignment", "auto"
:param str mode: "definition", "assignment", "goto"
:return: list of definitions/assignments
:rtype: list
"""
script = get_script()
try:
if mode == "goto":
definitions = [x for x in script.goto_definitions()
if not x.in_builtin_module()]
if not definitions:
definitions = script.goto_assignments()
elif mode == "related_name":
definitions = script.usages()
definitions = script.goto_assignments(follow_imports=True)
elif mode == "definition":
definitions = script.goto_definitions()
elif mode == "assignment":
definitions = script.goto_assignments()
except jedi.NotFoundError:
echo_highlight("Cannot follow nothing. Put your cursor on a valid name.")
definitions = []
else:
if no_output:
return definitions
elif mode == "stubs":
definitions = script.goto_assignments(follow_imports=True, only_stubs=True)
if not definitions:
echo_highlight("Couldn't find any definitions for this.")
elif len(definitions) == 1 and mode != "related_name":
# just add some mark to add the current position to the jumplist.
# this is ugly, because it overrides the mark for '`', so if anyone
# has a better idea, let me know.
vim_command('normal! m`')
d = list(definitions)[0]
if d.in_builtin_module():
if d.column is None:
if d.is_keyword:
echo_highlight("Cannot get the definition of Python keywords.")
else:
echo_highlight("Builtin modules cannot be displayed (%s)."
% d.desc_with_module)
else:
using_tagstack = vim_eval('g:jedi#use_tag_stack') == '1'
if d.module_path != vim.current.buffer.name:
using_tagstack = int(vim_eval('g:jedi#use_tag_stack')) == 1
if (d.module_path or '') != vim.current.buffer.name:
result = new_buffer(d.module_path,
using_tagstack=using_tagstack)
if not result:
return []
if d.module_path and using_tagstack:
if (using_tagstack and d.module_path and
os.path.exists(d.module_path)):
tagname = d.name
with tempfile('{0}\t{1}\t{2}'.format(tagname, d.module_path,
'call cursor({0}, {1})'.format(d.line, d.column + 1))) as f:
with tempfile('{0}\t{1}\t{2}'.format(
tagname, d.module_path, 'call cursor({0}, {1})'.format(
d.line, d.column + 1))) as f:
old_tags = vim.eval('&tags')
old_wildignore = vim.eval('&wildignore')
try:
@@ -284,19 +345,74 @@ def goto(mode="goto", no_output=False):
repr(PythonToVimStr(old_wildignore)))
vim.current.window.cursor = d.line, d.column
else:
# multiple solutions
show_goto_multi_results(definitions)
return definitions
def relpath(path):
"""Make path relative to cwd if it is below."""
abspath = os.path.abspath(path)
if abspath.startswith(os.getcwd()):
return os.path.relpath(path)
return path
def annotate_description(d):
code = d.get_line_code().strip()
if d.type == 'statement':
return code
if d.type == 'function':
if code.startswith('def'):
return code
typ = 'def'
else:
typ = d.type
return '[%s] %s' % (typ, code)
def show_goto_multi_results(definitions):
"""Create a quickfix list for multiple definitions."""
lst = []
for d in definitions:
if d.in_builtin_module():
lst.append(dict(text=PythonToVimStr('Builtin ' + d.description)))
if d.column is None:
# Typically a namespace, in the future maybe other things as
# well.
lst.append(dict(text=PythonToVimStr(d.description)))
else:
lst.append(dict(filename=PythonToVimStr(d.module_path),
text = annotate_description(d)
lst.append(dict(filename=PythonToVimStr(relpath(d.module_path)),
lnum=d.line, col=d.column + 1,
text=PythonToVimStr(d.description)))
text=PythonToVimStr(text)))
vim_eval('setqflist(%s)' % repr(lst))
vim_eval('jedi#add_goto_window(' + str(len(lst)) + ')')
@catch_and_print_exceptions
def usages(visuals=True):
script = get_script()
definitions = script.usages()
if not definitions:
echo_highlight("No usages found here.")
return definitions
if visuals:
highlight_usages(definitions)
show_goto_multi_results(definitions)
return definitions
def highlight_usages(definitions, length=None):
for definition in definitions:
# Only color the current module/buffer.
if (definition.module_path or '') == vim.current.buffer.name:
# mathaddpos needs a list of positions where a position is a list
# of (line, column, length).
# The column starts with 1 and not 0.
positions = [
[definition.line, definition.column + 1, length or len(definition.name)]
]
vim_eval("matchaddpos('jediUsage', %s)" % repr(positions))
@_check_jedi_availability(show_error=True)
@catch_and_print_exceptions
@@ -304,8 +420,6 @@ def show_documentation():
script = get_script()
try:
definitions = script.goto_definitions()
except jedi.NotFoundError:
definitions = []
except Exception:
# print to stdout, will be in :messages
definitions = []
@@ -327,7 +441,7 @@ def show_documentation():
@catch_and_print_exceptions
def clear_call_signatures():
# Check if using command line call signatures
if vim_eval("g:jedi#show_call_signatures") == '2':
if int(vim_eval("g:jedi#show_call_signatures")) == 2:
vim_command('echo ""')
return
cursor = vim.current.window.cursor
@@ -336,7 +450,8 @@ def clear_call_signatures():
# 1. Search for a line with a call signature and save the appended
# characters
# 2. Actually replace the line and redo the status quo.
py_regex = r'%sjedi=([0-9]+), (.*?)%s.*?%sjedi%s'.replace('%s', e)
py_regex = r'%sjedi=([0-9]+), (.*?)%s.*?%sjedi%s'.replace(
'%s', re.escape(e))
for i, line in enumerate(vim.current.buffer):
match = re.search(py_regex, line)
if match is not None:
@@ -352,7 +467,7 @@ def clear_call_signatures():
@_check_jedi_availability(show_error=False)
@catch_and_print_exceptions
def show_call_signatures(signatures=()):
if vim_eval("has('conceal') && g:jedi#show_call_signatures") == '0':
if int(vim_eval("has('conceal') && g:jedi#show_call_signatures")) == 0:
return
if signatures == ():
@@ -362,9 +477,10 @@ def show_call_signatures(signatures=()):
if not signatures:
return
if vim_eval("g:jedi#show_call_signatures") == '2':
if int(vim_eval("g:jedi#show_call_signatures")) == 2:
return cmdline_call_signatures(signatures)
seen_sigs = []
for i, signature in enumerate(signatures):
line, column = signature.bracket_start
# signatures are listed above each other
@@ -378,13 +494,20 @@ def show_call_signatures(signatures=()):
# TODO check if completion menu is above or below
line = vim_eval("getline(%s)" % line_to_replace)
params = [p.description.replace('\n', '') for p in signature.params]
# Descriptions are usually looking like `param name`, remove the param.
params = [p.description.replace('\n', '').replace('param ', '', 1)
for p in signature.params]
try:
# *_*PLACEHOLDER*_* makes something fat. See after/syntax file.
params[signature.index] = '*_*%s*_*' % params[signature.index]
except (IndexError, TypeError):
pass
# Skip duplicates.
if params in seen_sigs:
continue
seen_sigs.append(params)
# This stuff is reaaaaally a hack! I cannot stress enough, that
# this is a stupid solution. But there is really no other yet.
# There is no possibility in VIM to draw on the screen, but there
@@ -424,7 +547,7 @@ def show_call_signatures(signatures=()):
@catch_and_print_exceptions
def cmdline_call_signatures(signatures):
def get_params(s):
return [p.description.replace('\n', '') for p in s.params]
return [p.description.replace('\n', '').replace('param ', '', 1) for p in s.params]
def escape(string):
return string.replace('"', '\\"').replace(r'\n', r'\\n')
@@ -448,7 +571,7 @@ def cmdline_call_signatures(signatures):
max_msg_len = int(vim_eval('&columns')) - 12
if int(vim_eval('&ruler')):
max_msg_len -= 18
max_msg_len -= len(signatures[0].call_name) + 2 # call name + parentheses
max_msg_len -= len(signatures[0].name) + 2 # call name + parentheses
if max_msg_len < (1 if params else 0):
return
@@ -483,7 +606,7 @@ def cmdline_call_signatures(signatures):
_, column = signatures[0].bracket_start
spaces = min(int(vim_eval('g:jedi#first_col +'
'wincol() - col(".")')) +
column - len(signatures[0].call_name),
column - len(signatures[0].name),
max_num_spaces) * ' '
if index is not None:
@@ -494,33 +617,46 @@ def cmdline_call_signatures(signatures):
'echohl jediFat | echon "%s" | '
'echohl jediFunction | echon "%s" | '
'echohl None | echon ")"'
% (spaces, signatures[0].call_name,
% (spaces, signatures[0].name,
left + ', ' if left else '',
center, ', ' + right if right else ''))
else:
vim_command(' echon "%s" | '
'echohl Function | echon "%s" | '
'echohl None | echon "(%s)"'
% (spaces, signatures[0].call_name, text))
% (spaces, signatures[0].name, text))
@_check_jedi_availability(show_error=True)
@catch_and_print_exceptions
def rename():
if not int(vim.eval('a:0')):
# Need to save the cursor position before insert mode
cursor = vim.current.window.cursor
changenr = vim.eval('changenr()') # track undo tree
vim_command('augroup jedi_rename')
vim_command('autocmd InsertLeave <buffer> call jedi#rename(1)')
vim_command('autocmd InsertLeave <buffer> call jedi#rename'
'({}, {}, {})'.format(cursor[0], cursor[1], changenr))
vim_command('augroup END')
vim_command("let s:jedi_replace_orig = expand('<cword>')")
line = vim_eval('getline(".")')
vim_command('normal! diw')
vim_command("let s:jedi_changedtick = b:changedtick")
if re.match(r'\w+$', line[cursor[1]:]):
# In case the deleted word is at the end of the line we need to
# move the cursor to the end.
vim_command('startinsert!')
else:
vim_command('startinsert')
else:
# Remove autocommand.
vim_command('autocmd! jedi_rename InsertLeave')
args = vim.eval('a:000')
cursor = tuple(int(x) for x in args[:2])
changenr = args[2]
# Get replacement, if there is something on the cursor.
# This won't be the case when the user ends insert mode right away,
# and `<cword>` would pick up the nearest word instead.
@@ -529,13 +665,7 @@ def rename():
else:
replace = None
cursor = vim.current.window.cursor
# Undo new word, but only if something was changed, which is not the
# case when ending insert mode right away.
if vim_eval('b:changedtick != s:jedi_changedtick') == '1':
vim_command('normal! u') # Undo new word.
vim_command('normal! u') # Undo diw.
vim_command('undo {}'.format(changenr))
vim.current.window.cursor = cursor
@@ -561,43 +691,40 @@ def do_rename(replace, orig=None):
saved_tab = int(vim_eval('tabpagenr()'))
saved_win = int(vim_eval('winnr()'))
temp_rename = goto(mode="related_name", no_output=True)
temp_rename = usages(visuals=False)
# Sort the whole thing reverse (positions at the end of the line
# must be first, because they move the stuff before the position).
temp_rename = sorted(temp_rename, reverse=True,
key=lambda x: (x.module_path, x.start_pos))
key=lambda x: (x.module_path, x.line, x.column))
buffers = set()
for r in temp_rename:
if r.in_builtin_module():
continue
if os.path.abspath(vim.current.buffer.name) != r.module_path:
assert r.module_path is not None
result = new_buffer(r.module_path)
if not result:
echo_highlight("Jedi-vim: failed to create buffer window for {}!".format(r.module_path))
echo_highlight('Failed to create buffer window for %s!' % (
r.module_path))
continue
buffers.add(vim.current.buffer.name)
# Save view.
saved_view = vim_eval('string(winsaveview())')
# Replace original word.
vim.current.window.cursor = r.start_pos
vim_command('normal! c{:d}l{}'.format(len(orig), replace))
# Restore view.
vim_command('call winrestview(%s)' % saved_view)
r_line = vim.current.buffer[r.line - 1]
vim.current.buffer[r.line - 1] = (r_line[:r.column] + replace +
r_line[r.column + len(orig):])
# Restore previous tab and window.
vim_command('tabnext {:d}'.format(saved_tab))
vim_command('{:d}wincmd w'.format(saved_win))
vim_command('tabnext {0:d}'.format(saved_tab))
vim_command('{0:d}wincmd w'.format(saved_win))
if len(buffers) > 1:
echo_highlight('Jedi did {:d} renames in {:d} buffers!'.format(
echo_highlight('Jedi did {0:d} renames in {1:d} buffers!'.format(
len(temp_rename), len(buffers)))
else:
echo_highlight('Jedi did {:d} renames!'.format(len(temp_rename)))
echo_highlight('Jedi did {0:d} renames!'.format(len(temp_rename)))
@_check_jedi_availability(show_error=True)
@@ -607,13 +734,13 @@ def py_import():
args = shsplit(vim.eval('a:args'))
import_path = args.pop()
text = 'import %s' % import_path
scr = jedi.Script(text, 1, len(text), '')
scr = jedi.Script(text, 1, len(text), '', environment=get_environment())
try:
completion = scr.goto_assignments()[0]
except IndexError:
echo_highlight('Cannot find %s in sys.path!' % import_path)
else:
if completion.in_builtin_module():
if completion.column is None: # Python modules always have a line number.
echo_highlight('%s is a builtin module.' % import_path)
else:
cmd_args = ' '.join([a.replace(' ', '\\ ') for a in args])
@@ -630,7 +757,7 @@ def py_import_completions():
comps = []
else:
text = 'import %s' % argl
script = jedi.Script(text, 1, len(text), '')
script = jedi.Script(text, 1, len(text), '', environment=get_environment())
comps = ['%s%s' % (argl, c.complete) for c in script.completions()]
vim.command("return '%s'" % '\n'.join(comps))
@@ -638,9 +765,9 @@ def py_import_completions():
@catch_and_print_exceptions
def new_buffer(path, options='', using_tagstack=False):
# options are what you can to edit the edit options
if vim_eval('g:jedi#use_tabs_not_buffers') == '1':
if int(vim_eval('g:jedi#use_tabs_not_buffers')) == 1:
_tabnew(path, options)
elif not vim_eval('g:jedi#use_splits_not_buffers') == '1':
elif not vim_eval('g:jedi#use_splits_not_buffers') in [1, '1']:
user_split_option = vim_eval('g:jedi#use_splits_not_buffers')
split_options = {
'top': 'topleft split',
@@ -649,15 +776,19 @@ def new_buffer(path, options='', using_tagstack=False):
'bottom': 'botright split',
'winwidth': 'vs'
}
if user_split_option == 'winwidth' and vim.current.window.width <= 2 * int(vim_eval("&textwidth ? &textwidth : 80")):
if (user_split_option == 'winwidth' and
vim.current.window.width <= 2 * int(vim_eval(
"&textwidth ? &textwidth : 80"))):
split_options['winwidth'] = 'sp'
if user_split_option not in split_options:
print('g:jedi#use_splits_not_buffers value is not correct, valid options are: %s' % ','.join(split_options.keys()))
print('Unsupported value for g:jedi#use_splits_not_buffers: {0}. '
'Valid options are: {1}.'.format(
user_split_option, ', '.join(split_options.keys())))
else:
vim_command(split_options[user_split_option] + " %s" % escape_file_path(path))
else:
if vim_eval("!&hidden && &modified") == '1':
if vim_eval("bufname('%')") is None:
if int(vim_eval("!&hidden && &modified")) == 1:
if not vim_eval("bufname('%')"):
echo_highlight('Cannot open a new buffer, use `:set hidden` or save your buffer')
return False
else:
@@ -666,9 +797,9 @@ def new_buffer(path, options='', using_tagstack=False):
return True
vim_command('edit %s %s' % (options, escape_file_path(path)))
# sometimes syntax is being disabled and the filetype not set.
if vim_eval('!exists("g:syntax_on")') == '1':
if int(vim_eval('!exists("g:syntax_on")')) == 1:
vim_command('syntax enable')
if vim_eval("&filetype != 'python'") == '1':
if int(vim_eval("&filetype != 'python'")) == 1:
vim_command('set filetype=python')
return True
@@ -681,7 +812,7 @@ def _tabnew(path, options=''):
:param options: `:tabnew` options, read vim help.
"""
path = os.path.abspath(path)
if vim_eval('has("gui")') == '1':
if int(vim_eval('has("gui")')) == 1:
vim_command('tab drop %s %s' % (options, escape_file_path(path)))
return

87
pythonx/jedi_vim_debug.py Normal file
View File

@@ -0,0 +1,87 @@
"""Used in jedi-vim's jedi#debug_info()"""
import sys
import vim
from jedi_vim import PythonToVimStr
def echo(msg):
vim.command('echo %r' % PythonToVimStr(msg))
def echo_error(msg):
vim.command('echohl ErrorMsg')
echo(msg)
vim.command('echohl None')
def format_exc_info(exc_info=None, tb_indent=2):
import traceback
if exc_info is None:
exc_info = sys.exc_info()
exc_msg = traceback.format_exception_only(exc_info[0], exc_info[1])
lines = ''.join(exc_msg).rstrip('\n').split('\n')
lines.append('Traceback (most recent call last):')
tb = traceback.format_tb(exc_info[2])
lines.extend(''.join(tb).rstrip('\n').split('\n'))
indent = ' ' * tb_indent
return '{0}'.format(('\n' + indent).join(lines))
def display_debug_info():
echo(' - global sys.version: `{0}`'.format(
', '.join([x.strip()
for x in sys.version.split('\n')])))
echo(' - global site module: `{0}`'.format(__import__('site').__file__))
try:
import jedi_vim
except Exception:
echo_error('ERROR: could not import jedi_vim: {0}'.format(
format_exc_info()))
return
if jedi_vim.jedi is None:
if hasattr(jedi_vim, 'jedi_import_error'):
error_msg = format_exc_info(jedi_vim.jedi_import_error)
else:
error_msg = 'unknown error'
echo_error('ERROR: could not import the "jedi" Python module: {0}'.format(
error_msg))
else:
echo('\n##### Jedi\n\n - path: `{0}`'.format(jedi_vim.jedi.__file__))
echo(' - version: {0}'.format(jedi_vim.jedi.__version__))
try:
environment = jedi_vim.get_environment(use_cache=False)
except AttributeError:
script_evaluator = jedi_vim.jedi.Script('')._evaluator
try:
sys_path = script_evaluator.project.sys_path
except AttributeError:
sys_path = script_evaluator.sys_path
else:
echo('\n##### Jedi environment: {0}\n\n'.format(environment))
echo(' - executable: {0}'.format(environment.executable))
try:
sys_path = environment.get_sys_path()
except Exception:
echo_error('ERROR: failed to get sys path from environment: {0}'.format(
format_exc_info()))
return
echo(' - sys_path:')
for p in sys_path:
echo(' - `{0}`'.format(p))
if environment:
echo('\n##### Known environments\n\n')
for environment in jedi_vim.get_known_environments():
echo(' - {0} ({1})\n'.format(
environment,
environment.executable,
))

1
pythonx/parso Submodule

Submodule pythonx/parso added at c0ace63a69

5
setup.cfg Normal file
View File

@@ -0,0 +1,5 @@
[tool:pytest]
testpaths = test
[flake8]
max-line-length = 100

View File

@@ -1,63 +0,0 @@
let g:jedi#completions_command = 'X'
source plugin/jedi.vim
describe 'completions'
before
new
set filetype=python
end
after
bd!
end
it 'smart import'
exec "normal ifrom os "
Expect getline('.') == 'from os import '
end
it 'no smart import after space'
exec "normal! ifrom os "
exec "normal a "
Expect getline('.') == 'from os '
end
it 'import'
" X is the completion command
normal oimporX
Expect getline('.') == 'import'
normal a subproX
Expect getline('.') == 'import subprocess'
end
it 'exception'
normal oIndentationErrX
Expect getline('.') == 'IndentationError'
normal a().filenaX
Expect getline('.') == 'IndentationError().filename'
end
it 'dot_open'
normal oraisX ImpXErrX()
Expect getline('.') == 'raise ImportError()'
end
it 'cycling through entries'
" testing select_first doesn't seem to work in ex mode
execute "normal oraise impX\<C-n>\<C-n>\<C-n>"
Expect getline('.') == 'raise ImportWarning'
let g:jedi#popup_select_first = 0
execute "normal oraise impX\<C-n>\<C-n>\<C-n>"
Expect getline('.') == 'raise ImportWarning'
let g:jedi#popup_select_first = 1
" -longest completes the first one
set completeopt -=longest
execute "normal oraise baseX"
Expect getline('.') == 'raise BaseException'
set completeopt +=longest
end
end
" vim: et:ts=4:sw=4

65
test/test_integration.py Normal file
View File

@@ -0,0 +1,65 @@
"""Runs tests from ./vspec in vim-vspec."""
import os
import subprocess
try:
from urllib.request import urlretrieve
except ImportError:
from urllib import urlretrieve
import zipfile
import pytest
vspec_version = '1.8.1'
VSPEC_URL = 'https://github.com/kana/vim-vspec/archive/%s.zip' % vspec_version
root = os.path.dirname(os.path.dirname(__file__))
CACHE_FOLDER = os.path.join(root, 'build')
VSPEC_FOLDER = os.path.join(CACHE_FOLDER, 'vim-vspec-%s' % vspec_version)
VSPEC_RUNNER = os.path.join(VSPEC_FOLDER, 'bin/vspec')
TEST_DIR = os.path.join(root, 'test', 'vspec')
@pytest.fixture(scope='session')
def install_vspec(request):
if not os.path.isdir(CACHE_FOLDER):
os.mkdir(CACHE_FOLDER)
if not os.path.exists(VSPEC_FOLDER):
name, hdrs = urlretrieve(VSPEC_URL)
z = zipfile.ZipFile(name)
for n in z.namelist():
dest = os.path.join(CACHE_FOLDER, n)
destdir = os.path.dirname(dest)
if not os.path.isdir(destdir):
os.makedirs(destdir)
data = z.read(n)
if not os.path.isdir(dest):
with open(dest, 'wb') as f:
f.write(data)
z.close()
os.chmod(VSPEC_RUNNER, 0o777)
def get_vspec_tests():
for f in os.listdir(TEST_DIR):
yield os.path.relpath(os.path.join(TEST_DIR, f))
@pytest.mark.parametrize('path', get_vspec_tests())
def test_integration(install_vspec, path):
output = subprocess.check_output(
[VSPEC_RUNNER, '.', VSPEC_FOLDER, os.path.relpath(path, root)],
cwd=root,
)
had_ok = False
for line in output.splitlines():
if (line.startswith(b'not ok') or
line.startswith(b'Error') or
line.startswith(b'Bail out!')):
pytest.fail(u"{0} failed:\n{1}".format(
path, output.decode('utf-8')), pytrace=False)
if not had_ok and line.startswith(b'ok'):
had_ok = True
if not had_ok:
pytest.fail(u"{0} failed: no 'ok' found:\n{1}".format(
path, output.decode('utf-8')), pytrace=False)

8
test/vimrc Normal file
View File

@@ -0,0 +1,8 @@
" Minimal vimrc to use jedi-vim.
"
" Not used anywhere yet, but allows for easy testing.
let script_dir = fnamemodify(expand('<sfile>'), ':h:h')
let &runtimepath = script_dir.','.&runtimepath.','.script_dir.'/after'
syntax on
filetype plugin indent on

131
test/vspec/completions.vim Normal file
View File

@@ -0,0 +1,131 @@
let g:jedi#completions_command = 'X'
source plugin/jedi.vim
describe 'completions'
before
new
set filetype=python
end
after
" default
let g:jedi#popup_select_first = 1
bd!
end
it 'longest in completeopt'
" This gets set up with Vim only on VimEnter.
if has('nvim')
Expect stridx(&completeopt, 'longest') > -1
else
Expect stridx(&completeopt, 'longest') == -1
doautocmd VimEnter
Expect stridx(&completeopt, 'longest') > -1
endif
" Do not use it for following tests.
set completeopt-=longest
end
it 'no smart import by default'
exec "normal ifrom os "
Expect getline('.') == 'from os '
end
it 'import'
" X is the completion command
normal oimporX
Expect getline('.') == 'import'
normal a subproX
Expect getline('.') == 'import subprocess'
end
it 'exception'
normal oIndentationErrX
Expect getline('.') == 'IndentationError'
" Do not remap keys (".") here, otherwise this triggers completion in
" Neovim already.
normal! a().filena
normal aX
Expect getline('.') == 'IndentationError().filename'
end
it 'multi complete'
" NOTE: nvim results in "importErr()" here with completeopt+=longest,
" but Vim is fine.
" This is due to `pumvisible()` in jedi#complete_opened being true
" with nvim still, but it is 0 with Vim, i.e. Vim appears to close
" the pum already (with the tests).
"
" This might be a misunderstanding though, since the test might not
" expect the "import" keyword to be offered for completion?!
normal oImpXErrX()
Expect getline('.') == 'ImportError()'
end
it 'cycling through entries popup_select_first=0'
set completeopt+=longest
let g:jedi#popup_select_first = 0
execute "normal oraise impX\<C-n>"
Expect getline('.') == 'raise ImportError'
set completeopt-=longest
end
it 'cycling through entries popup_select_first=1'
execute "normal oraise impX\<C-n>"
Expect getline('.') == 'raise ImportWarning'
end
it 'cycling through entries popup_select_first=1 and longest'
set completeopt+=longest
execute "normal oraise impX"
Expect getline('.') == 'raise Import'
" With Neovim pumvisible() is 1 in jedi#complete_opened, which then
" triggers the <Down>. This is not the case with Vim.
if has('nvim')
execute "normal oraise impX\<C-n>"
Expect getline('.') == 'raise ImportWarning'
execute "normal oraise impX\<C-n>\<C-n>"
Expect getline('.') == 'raise imp'
else
execute "normal oraise impX\<C-n>"
Expect getline('.') == 'raise ImportError'
execute "normal oraise impX\<C-n>\<C-n>"
Expect getline('.') == 'raise ImportWarning'
endif
set completeopt-=longest
end
end
describe 'smart completions'
before
new
let g:jedi#smart_auto_mappings = 1
set filetype=python
end
after
" default
let g:jedi#smart_auto_mappings = 0
bd!
end
it 'smart import'
exec "normal ifrom os "
Expect getline('.') == 'from os import '
end
it 'no smart import after space'
exec "normal! ifrom os "
exec "normal a "
Expect getline('.') == 'from os '
end
end
" vim: et:ts=4:sw=4

View File

@@ -4,12 +4,11 @@ source plugin/jedi.vim
describe 'completions_disabled'
before
new
set filetype=python
end
after
bd!
try | %bwipeout! | catch | endtry
end
it 'typing'

View File

@@ -6,14 +6,14 @@ describe 'documentation docstrings'
end
after
bd!
bd!
try | %bwipeout! | catch | endtry
end
it 'simple'
Expect maparg('K') == ':call jedi#show_documentation()<CR>'
put = 'ImportError'
normal GK
Expect bufname('%') == "'__doc__'"
Expect bufname('%') == "__doc__"
Expect &filetype == 'rst'
let content = join(getline(1,'$'), "\n")
Expect stridx(content, "Import can't find module") > 0

View File

@@ -1,10 +1,10 @@
let mapleader = '\'
source plugin/jedi.vim
source test/utils.vim
source test/_utils.vim
describe 'goto_simple'
describe 'goto simple:'
before
new " open a new split
new
set filetype=python
put =[
\ 'def a(): pass',
@@ -20,99 +20,99 @@ describe 'goto_simple'
bd!
end
it 'goto_definitions'
silent normal \d
Expect line('.') == 1
"Expect col('.') == 5 " not working yet.
it 'goto definitions'
normal \d
Expect line('.') == 2
Expect col('.') == 1
end
it 'goto_assignments'
silent normal \g
it 'goto assignments'
normal \g
Expect line('.') == 2
Expect col('.') == 1
" cursor before `=` means that it stays there.
silent normal \g
normal \g
Expect line('.') == 2
Expect col('.') == 1
" going to the last line changes it.
normal! $
silent normal \g
normal \g
Expect line('.') == 1
Expect col('.') == 5
end
end
describe 'goto_with_tabs'
describe 'goto with tabs:'
before
set filetype=python
let g:jedi#use_tabs_not_buffers = 1
end
after
bd!
bd!
try | %bwipeout! | catch | endtry
end
it 'follow_import'
it 'follow import'
put = ['import subprocess', 'subprocess']
silent normal G\g
normal G\g
Expect getline('.') == 'import subprocess'
Expect line('.') == 2
Expect col('.') == 8
silent normal G\d
normal G\d
Expect CurrentBufferIsModule('subprocess') == 1
Expect line('.') == 1
Expect col('.') == 1
Expect tabpagenr('$') == 2
Expect winnr('$') == 1
tabprevious
bwipe
Expect tabpagenr('$') == 1
Expect bufname('%') == ''
end
it 'multi_definitions'
" This used to behave differently. Now we don't have any real multi
" definitions.
" put = ['import tokenize']
" silent normal G$\d
" Expect CurrentBufferIsModule('tokenize') == 1
" Expect CurrentBufferIsModule('token') == 0
" execute "normal \<CR>"
" Expect tabpagenr('$') == 2
" Expect winnr('$') == 1
" Expect CurrentBufferIsModule('token') == 1
" bd
" silent normal G$\d
" execute "normal j\<CR>"
" Expect tabpagenr('$') == 2
" Expect winnr('$') == 1
" Expect CurrentBufferIsModule('tokenize') == 1
end
" it 'multi definitions'
" " This used to behave differently. Now we don't have any real multi
" " definitions.
"
" " put = ['import tokenize']
" " normal G$\d
" " Expect CurrentBufferIsModule('tokenize') == 1
" " Expect CurrentBufferIsModule('token') == 0
" " execute "normal \<CR>"
" " Expect tabpagenr('$') == 2
" " Expect winnr('$') == 1
" " Expect CurrentBufferIsModule('token') == 1
"
" " bd
" " normal G$\d
" " execute "normal j\<CR>"
" " Expect tabpagenr('$') == 2
" " Expect winnr('$') == 1
" " Expect CurrentBufferIsModule('tokenize') == 1
" end
end
describe 'goto_with_buffers'
describe 'goto with buffers'
before
set filetype=python
let g:jedi#use_tabs_not_buffers = 0
end
after
bd!
bd!
try | %bwipeout! | catch | endtry
set nohidden
end
it 'no_new_tabs'
it 'no new tabs'
put = ['import os']
normal G$
call jedi#goto_assignments()
python jedi_vim.goto()
PythonJedi jedi_vim.goto()
Expect CurrentBufferIsModule('os') == 0
" Without hidden, it's not possible to open a new buffer, when the old
" one is not saved.
@@ -125,47 +125,47 @@ describe 'goto_with_buffers'
Expect col('.') == 1
end
it 'multi_definitions'
" set hidden
" put = ['import tokenize']
" silent normal G$\d
" Expect CurrentBufferIsModule('tokenize') == 0
" Expect CurrentBufferIsModule('token') == 0
" execute "normal \<CR>"
" Expect tabpagenr('$') == 1
" Expect winnr('$') == 1
" Expect CurrentBufferIsModule('token') == 1
" bd
" silent normal G$\d
" execute "normal j\<CR>"
" Expect tabpagenr('$') == 1
" Expect winnr('$') == 1
" Expect CurrentBufferIsModule('tokenize') == 1
end
" it 'multi definitions'
" " set hidden
" " put = ['import tokenize']
" " normal G$\d
" " Expect CurrentBufferIsModule('tokenize') == 0
" " Expect CurrentBufferIsModule('token') == 0
" " execute "normal \<CR>"
" " Expect tabpagenr('$') == 1
" " Expect winnr('$') == 1
" " Expect CurrentBufferIsModule('token') == 1
"
" " bd
" " normal G$\d
" " execute "normal j\<CR>"
" " Expect tabpagenr('$') == 1
" " Expect winnr('$') == 1
" " Expect CurrentBufferIsModule('tokenize') == 1
" end
end
describe 'goto_with_splits'
describe 'goto with splits'
before
enew!
set filetype=python
let g:jedi#use_splits_not_buffers = 'left'
end
after
bd!
bd!
try | %bwipeout! | catch | endtry
end
it 'follow_import'
it 'follow import'
put = ['import subprocess', 'subprocess']
silent normal G\g
normal G\g
Expect getline('.') == 'import subprocess'
Expect line('.') == 2
Expect col('.') == 8
silent normal G\d
normal G\d
Expect CurrentBufferIsModule('subprocess') == 1
Expect line('.') == 1
Expect col('.') == 1
@@ -177,8 +177,9 @@ describe 'goto_with_splits'
end
describe 'goto_wildignore'
describe 'goto wildignore'
before
enew!
set filetype=python
set wildignore=*,with\ spaces,*.pyc
set hidden
@@ -189,23 +190,22 @@ describe 'goto_wildignore'
put = ['from subprocess import Popen', 'Popen']
Expect CurrentBufferIsModule('subprocess') == 0
silent normal G
normal G
end
after
bd!
bd!
try | %bwipeout! | catch | endtry
set wildignore&vim
end
it 'restores_wildignore'
it 'restores wildignore'
let before = &wildignore
call jedi#goto()
Expect getline('.') =~ 'Popen'
Expect &wildignore == before
end
it 'not_using_tagstack'
it 'not using tagstack'
let g:jedi#use_tag_stack = 0
call jedi#goto()
Expect CurrentBufferIsModule('subprocess') == 1

View File

@@ -1,5 +1,5 @@
source plugin/jedi.vim
source test/utils.vim
source test/_utils.vim
describe 'pyimport'
before
@@ -7,8 +7,7 @@ describe 'pyimport'
end
after
bd!
bd!
try | %bwipeout! | catch | endtry
end
it 'open_tab'
@@ -27,6 +26,10 @@ describe 'pyimport'
Expect jedi#py_import_completions('subproc', 0, 0) == 'subprocess'
Expect jedi#py_import_completions('subprocess', 0, 0) == 'subprocess'
Expect jedi#py_import_completions('zip', 0, 0) == "zipfile\nzipimport"
let g:comp = jedi#py_import_completions('zip', 0, 0)
" Sometimes zipapp is in there sometimes not, depends on Python
" version.
let g:comp = substitute(g:comp, '^zipapp\n', '', '')
Expect g:comp == "zipfile\nzipimport"
end
end

View File

@@ -2,23 +2,23 @@ source plugin/jedi.vim
describe 'signatures'
before
enew
set filetype=python
end
after
bd!
bd!
try | %bwipeout! | catch | endtry
end
it 'simple'
normal oabs(
" equals doautocmd CursorMovedI
Python jedi_vim.show_call_signatures()
Expect getline(1) == '=`=jedi=0, =`= (*_*number*_*) =`=jedi=`='
normal odef xyz(number): return
normal o
normal oxyz()
doautocmd CursorHoldI
Expect getline(3) == '?!?jedi=0, ?!? (*_*number*_*) ?!?jedi?!?'
doautocmd InsertLeave
Expect getline(1) == ''
Expect getline(3) == ''
end
it 'multiple buffers'
@@ -34,19 +34,18 @@ describe 'signatures'
autocmd jedi_call_signatures * <buffer>
redir END
Expect autocmds =~# 'jedi_call_signatures'
bd!
end
it 'simple after CursorHoldI with only parenthesis'
noautocmd normal o
doautocmd CursorHoldI
noautocmd normal iabs(
noautocmd normal istaticmethod()
doautocmd CursorHoldI
Expect getline(1) == '=`=jedi=0, =`= (*_*number*_*) =`=jedi=`='
Expect getline(1) == '?!?jedi=0, ?!? (*_*f: Callable*_*) ?!?jedi?!?'
end
it 'no signature'
normal ostr
exe 'normal ostr '
Python jedi_vim.show_call_signatures()
Expect getline(1, '$') == ['', 'str ']
end
@@ -54,7 +53,7 @@ describe 'signatures'
it 'signatures disabled'
let g:jedi#show_call_signatures = 0
normal ostr(
exe 'normal ostr( '
Python jedi_vim.show_call_signatures()
Expect getline(1, '$') == ['', 'str( ']
@@ -65,11 +64,11 @@ describe 'signatures'
let g:jedi#show_call_signatures = 2
call jedi#configure_call_signatures()
normal oabs(
exe 'normal ostaticmethod( '
redir => msg
Python jedi_vim.show_call_signatures()
redir END
Expect msg == "\nabs(number)"
Expect msg == "\nstaticmethod(f: Callable)"
redir => msg
doautocmd InsertLeave
@@ -77,7 +76,7 @@ describe 'signatures'
Expect msg == "\n"
normal Sdef foo(a, b): pass
normal ofoo(a, b, c,
exe 'normal ofoo(a, b, c, '
redir => msg
Python jedi_vim.show_call_signatures()
redir END
@@ -95,25 +94,25 @@ describe 'signatures'
return msg
endfunction
let funcname = repeat('a', &columns - 30)
let funcname = repeat('a', &columns - (30 + (&ruler ? 18 : 0)))
put = 'def '.funcname.'(arg1, arg2, arg3, a, b, c):'
put = ' pass'
execute "normal o".funcname."( "
execute "normal o\<BS>".funcname."( "
Expect Signature() == "\n".funcname."(arg1, …)"
normal sarg1,
exe 'normal sarg1, '
Expect Signature() == "\n".funcname."(…, arg2, …)"
normal sarg2, arg3,
exe 'normal sarg2, arg3, '
Expect Signature() == "\n".funcname."(…, a, b, c)"
normal sa, b,
exe 'normal sa, b, '
Expect Signature() == "\n".funcname."(…, c)"
g/^/d
put = 'def '.funcname.'('.repeat('b', 20).', arg2):'
put = ' pass'
execute "normal o".funcname."( "
execute "normal o\<BS>".funcname."( "
Expect Signature() == "\n".funcname."(…)"
end
@@ -121,7 +120,7 @@ describe 'signatures'
let g:jedi#show_call_signatures = 2
call jedi#configure_call_signatures()
normal ostr
exe 'normal ostr '
redir => msg
Python jedi_vim.show_call_signatures()
redir END

View File

@@ -1,2 +0,0 @@
def test_integration(case, monkeypatch, pytestconfig):
case.run()