128 Commits
0.8.0 ... 0.9.0

Author SHA1 Message Date
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
24 changed files with 690 additions and 378 deletions

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.
-->

5
.gitmodules vendored
View File

@@ -1,3 +1,6 @@
[submodule "jedi"] [submodule "jedi"]
path = jedi path = pythonx/jedi
url = https://github.com/davidhalter/jedi.git 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,15 @@
sudo: false
language: python language: python
python: 3.6
env:
matrix:
- ENV=test
- ENV=check
install: install:
- pip install --quiet --use-mirrors pytest - |
if [ "$ENV" = "test" ]; then
python3.6 -m pip install pytest
fi
script: script:
- vim --version - vim --version
- py.test - make "$ENV"

View File

@@ -49,5 +49,7 @@ Daniel Hahler (@blueyed)
Dave Honneffer (@pearofducks) Dave Honneffer (@pearofducks)
Bagrat Aznauryan (@n9code) Bagrat Aznauryan (@n9code)
Tomoyuki Kashiro (@kashiro) Tomoyuki Kashiro (@kashiro)
Tommy Allen (@tweekmonster)
Mingliang (@Aulddays)
@something are github user names. @something are github user names.

16
Makefile Normal file
View File

@@ -0,0 +1,16 @@
test:
py.test
build:
mkdir $@
build/vint: | build
virtualenv $@
$@/bin/pip install vim-vint
check: LINT_FILES:=after autoload ftplugin plugin
check: build/vint
build/vint/bin/vint $(LINT_FILES)
clean:
rm -rf .cache build
.PHONY: test check clean

View File

@@ -2,7 +2,7 @@
jedi-vim - awesome Python autocompletion with VIM 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 :target: https://travis-ci.org/davidhalter/jedi-vim
:alt: Travis-CI build status :alt: Travis-CI build status
@@ -34,11 +34,11 @@ Documentation
Documentation is available in your vim: ``:help jedi-vim``. You can also look 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>`_. 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 If you want to report issues, just use the github issue tracker. In case of
questions about the software, please use `stackoverflow 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 Contributing
@@ -68,28 +68,55 @@ Apart from that, jedi-vim supports the following commands
Installation Installation
============ ============
Requirements
------------
You need a VIM version that was compiled with Python 2.6 or later
(``+python`` or ``+python3``), which is typical for most distributions on
Linux. 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 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 `Vundle <https://github.com/gmarik/vundle>`_ to install jedi-vim.
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`` )
The first thing you need after that is an up-to-date version of Jedi. You can 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`` either install it via ``pip install jedi`` or with
in your jedi-vim repository. ``git submodule update --init`` in your jedi-vim repository.
Example Installation Command using Pathogen: Example installation command using Pathogen:
.. code-block:: sh .. 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'
On Arch Linux, you can also install jedi-vim from official repositories as `vim-jedi Installation with your distribution
<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, On Arch Linux, you can also install jedi-vim from official repositories as
it is available as `vim-jedi <https://apps.fedoraproject.org/packages/vim-jedi>`__. `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 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 to conflict with jedi-vim, therefore you should disable it before enabling
@@ -202,16 +229,30 @@ Don't even think about changing the Jedi command to ``<Tab>``,
use `supertab <https://github.com/ervandew/supertab>`_! 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 1. Completion of complex libraries (like Numpy) should only be slow the first
you complete it. After that, the results should be cached and very fast. 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 2. If it is still slow after the initial completion and you have installed the
it. It seems to conflict with jedi-vim. See issue `#163 python-mode Vim plugin, try disabling its rope mode:
<https://github.com/davidhalter/jedi-vim/issues/163>`__.
.. 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 Testing
======= =======

View File

@@ -1,23 +1,3 @@
if !jedi#init_python() if jedi#init_python() && g:jedi#auto_initialization && g:jedi#completions_enabled
finish call jedi#setup_completion()
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
endif endif

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

@@ -23,16 +23,16 @@ let s:default_settings = {
\ 'call_signatures_command': "'<leader>n'", \ 'call_signatures_command': "'<leader>n'",
\ 'usages_command': "'<leader>n'", \ 'usages_command': "'<leader>n'",
\ 'rename_command': "'<leader>r'", \ 'rename_command': "'<leader>r'",
\ 'popup_on_dot': 1, \ 'completions_enabled': 1,
\ 'popup_on_dot': 'g:jedi#completions_enabled',
\ 'documentation_command': "'K'", \ 'documentation_command': "'K'",
\ 'show_call_signatures': 1, \ 'show_call_signatures': 1,
\ 'show_call_signatures_delay': 500, \ 'show_call_signatures_delay': 500,
\ 'call_signature_escape': "'=`='", \ 'call_signature_escape': "'?!?'",
\ 'auto_close_doc': 1, \ 'auto_close_doc': 1,
\ 'max_doc_height': 30, \ 'max_doc_height': 30,
\ 'popup_select_first': 1, \ 'popup_select_first': 1,
\ 'quickfix_window_height': 10, \ 'quickfix_window_height': 10,
\ 'completions_enabled': 1,
\ 'force_py_version': "'auto'", \ 'force_py_version': "'auto'",
\ 'smart_auto_mappings': 1, \ 'smart_auto_mappings': 1,
\ 'use_tag_stack': 1 \ 'use_tag_stack': 1
@@ -57,13 +57,13 @@ endfor
" ------------------------------------------------------------------------ " ------------------------------------------------------------------------
let s:script_path = fnameescape(expand('<sfile>:p:h:h')) let s:script_path = fnameescape(expand('<sfile>:p:h:h'))
function! s:init_python() function! s:init_python() abort
if g:jedi#force_py_version != 'auto' if g:jedi#force_py_version !=# 'auto'
" Always use the user supplied version. " Always use the user supplied version.
try try
return jedi#force_py_version(g:jedi#force_py_version) return jedi#setup_py_version(g:jedi#force_py_version)
catch catch
throw "Could not setup g:jedi#force_py_version: ".v:exception throw 'Could not setup g:jedi#force_py_version: '.v:exception
endtry endtry
endif endif
@@ -75,31 +75,31 @@ function! s:init_python()
" Get default python version from interpreter in $PATH. " 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]))')) 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 v:shell_error != 0 || !len(s:def_py)
if !exists("g:jedi#squelch_py_warning") if !exists('g:jedi#squelch_py_warning')
echohl WarningMsg echohl WarningMsg
echom "Warning: jedi-vim failed to get Python version from sys.version_info: " . s:def_py echom 'Warning: jedi-vim failed to get Python version from sys.version_info: ' . s:def_py
echom "Falling back to version 2." echom 'Falling back to version 2.'
echohl None echohl None
endif endif
let s:def_py = 2 let s:def_py = 2
elseif &verbose elseif &verbose
echom "jedi-vim: auto-detected Python: ".s:def_py echom 'jedi-vim: auto-detected Python: '.s:def_py
endif endif
" Make sure that the auto-detected version is available in Vim. " Make sure that the auto-detected version is available in Vim.
if !has('nvim') || has('python'.(s:def_py == 2 ? '' : s:def_py)) if !has('nvim') || has('python'.(s:def_py == 2 ? '' : s:def_py))
return jedi#force_py_version(s:def_py) return jedi#setup_py_version(s:def_py)
endif endif
" Add a warning in case the auto-detected version is not available, " Add a warning in case the auto-detected version is not available,
" usually because of a missing neovim module in a VIRTUAL_ENV. " usually because of a missing neovim module in a VIRTUAL_ENV.
if has('nvim') if has('nvim')
echohl WarningMsg echohl WarningMsg
echom "jedi-vim: the detected Python version (".s:def_py.")" echom 'jedi-vim: the detected Python version ('.s:def_py.')'
\ "is not functional." \ 'is not functional.'
\ "Is the 'neovim' module installed?" \ 'Is the "neovim" module installed?'
\ "While jedi-vim will work, it might not use the" \ 'While jedi-vim will work, it might not use the'
\ "expected Python path." \ 'expected Python path.'
echohl None echohl None
endif endif
endif endif
@@ -109,29 +109,29 @@ function! s:init_python()
elseif has('python3') elseif has('python3')
call jedi#setup_py_version(3) call jedi#setup_py_version(3)
else 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 endif
return 1 return 1
endfunction endfunction
function! jedi#reinit_python() function! jedi#reinit_python() abort
unlet! s:_init_python unlet! s:_init_python
call jedi#init_python() call jedi#init_python()
endfunction endfunction
function! jedi#init_python() let s:_init_python = -1
if !exists('s:_init_python') function! jedi#init_python() abort
if s:_init_python == -1
try try
let s:_init_python = s:init_python() let s:_init_python = s:init_python()
catch 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
endif
let s:_init_python = 0 let s:_init_python = 0
if !exists('g:jedi#squelch_py_warning')
echoerr 'Error: jedi-vim failed to initialize Python: '
\ .v:exception.' (in '.v:throwpoint.')'
endif
endtry endtry
endif endif
return s:_init_python return s:_init_python
@@ -139,54 +139,139 @@ endfunction
let s:python_version = 'null' let s:python_version = 'null'
function! jedi#setup_py_version(py_version) function! jedi#setup_py_version(py_version) abort
if a:py_version == 2 if a:py_version == 2
let cmd_init = 'pyfile'
let cmd_exec = 'python' let cmd_exec = 'python'
let s:python_version = 2 let s:python_version = 2
elseif a:py_version == 3 elseif a:py_version == 3
let cmd_init = 'py3file'
let cmd_exec = 'python3' let cmd_exec = 'python3'
let s:python_version = 3 let s:python_version = 3
else else
throw "jedi#setup_py_version: invalid py_version: ".a:py_version throw 'jedi#setup_py_version: invalid py_version: '.a:py_version
endif endif
execute 'command! -nargs=1 PythonJedi '.cmd_exec.' <args>'
let s:init_outcome = 0
let init_lines = [
\ 'import vim',
\ 'try:',
\ ' import jedi_vim',
\ 'except Exception as exc:',
\ ' vim.command(''let s:init_outcome = "could not import jedi_vim: {0}: {1}"''.format(exc.__class__.__name__, exc))',
\ 'else:',
\ ' vim.command(''let s:init_outcome = 1'')']
try try
execute cmd_init.' '.s:script_path.'/initialize.py' exe 'PythonJedi exec('''.escape(join(init_lines, '\n'), "'").''')'
execute 'command! -nargs=1 PythonJedi '.cmd_exec.' <args>'
return 1
catch catch
throw "jedi#setup_py_version: ".v:exception throw printf('jedi#setup_py_version: failed to run Python for initialization: %s.', v:exception)
endtry endtry
if s:init_outcome is 0
throw 'jedi#setup_py_version: failed to run Python for initialization.'
elseif s:init_outcome isnot 1
throw printf('jedi#setup_py_version: %s.', s:init_outcome)
endif
return 1
endfunction endfunction
function! jedi#debug_info() function! jedi#debug_info() abort
echom "Using Python version:" s:python_version if s:python_version ==# 'null'
try
call s:init_python()
catch
echohl WarningMsg | echom v:exception | echohl None
return
endtry
endif
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 'Using Python version:' s:python_version
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
PythonJedi from jedi_vim_debug import display_debug_info
PythonJedi display_debug_info()
endif
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'), '\v\n$', '', '')
echo "\n"
echo '##### Settings'
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 endfunction
function! jedi#force_py_version(py_version) abort
function! jedi#force_py_version(py_version)
let g:jedi#force_py_version = a:py_version let g:jedi#force_py_version = a:py_version
return jedi#setup_py_version(a:py_version) return jedi#setup_py_version(a:py_version)
endfunction endfunction
function! jedi#force_py_version_switch() function! jedi#force_py_version_switch() abort
if g:jedi#force_py_version == 2 if g:jedi#force_py_version == 2
call jedi#force_py_version(3) call jedi#force_py_version(3)
elseif g:jedi#force_py_version == 3 elseif g:jedi#force_py_version == 3
call jedi#force_py_version(2) call jedi#force_py_version(2)
else else
throw "Don't know how to switch from ".g:jedi#force_py_version."!" throw "Don't know how to switch from ".g:jedi#force_py_version.'!'
endif endif
endfunction endfunction
" Helper function instead of `python vim.eval()`, and `.command()` because " Helper function instead of `python vim.eval()`, and `.command()` because
" these also return error definitions. " these also return error definitions.
function! jedi#_vim_exceptions(str, is_eval) function! jedi#_vim_exceptions(str, is_eval) abort
let l:result = {} let l:result = {}
try try
if a:is_eval if a:is_eval
@@ -202,82 +287,84 @@ function! jedi#_vim_exceptions(str, is_eval)
return l:result return l:result
endfunction endfunction
call jedi#init_python() " Might throw an error.
if !jedi#init_python()
" Do not define any functions when Python initialization failed.
finish
endif
" ------------------------------------------------------------------------ " ------------------------------------------------------------------------
" functions that call python code " functions that call python code
" ------------------------------------------------------------------------ " ------------------------------------------------------------------------
function! jedi#goto() function! jedi#goto() abort
PythonJedi jedi_vim.goto(mode="goto") PythonJedi jedi_vim.goto(mode="goto")
endfunction endfunction
function! jedi#goto_assignments() function! jedi#goto_assignments() abort
PythonJedi jedi_vim.goto(mode="assignment") PythonJedi jedi_vim.goto(mode="assignment")
endfunction endfunction
function! jedi#goto_definitions() function! jedi#goto_definitions() abort
PythonJedi jedi_vim.goto(mode="definition") PythonJedi jedi_vim.goto(mode="definition")
endfunction endfunction
function! jedi#usages() function! jedi#usages() abort
PythonJedi jedi_vim.goto(mode="related_name") PythonJedi jedi_vim.goto(mode="related_name")
endfunction endfunction
function! jedi#rename(...) function! jedi#rename(...) abort
PythonJedi jedi_vim.rename() PythonJedi jedi_vim.rename()
endfunction endfunction
function! jedi#rename_visual(...) function! jedi#rename_visual(...) abort
PythonJedi jedi_vim.rename_visual() PythonJedi jedi_vim.rename_visual()
endfunction endfunction
function! jedi#completions(findstart, base) function! jedi#completions(findstart, base) abort
PythonJedi jedi_vim.completions() PythonJedi jedi_vim.completions()
endfunction 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) PythonJedi jedi_vim.jedi.set_debug_function(jedi_vim.print_to_stdout, speed=True, warnings=False, notices=False)
endfunction endfunction
function! jedi#enable_debugging() function! jedi#enable_debugging() abort
PythonJedi jedi_vim.jedi.set_debug_function(jedi_vim.print_to_stdout) PythonJedi jedi_vim.jedi.set_debug_function(jedi_vim.print_to_stdout)
endfunction endfunction
function! jedi#disable_debugging() function! jedi#disable_debugging() abort
PythonJedi jedi_vim.jedi.set_debug_function(None) PythonJedi jedi_vim.jedi.set_debug_function(None)
endfunction endfunction
function! jedi#py_import(args) function! jedi#py_import(args) abort
PythonJedi jedi_vim.py_import() PythonJedi jedi_vim.py_import()
endfun endfun
function! jedi#py_import_completions(argl, cmdl, pos) function! jedi#py_import_completions(argl, cmdl, pos) abort
PythonJedi jedi_vim.py_import_completions() PythonJedi jedi_vim.py_import_completions()
endfun endfun
function! jedi#clear_cache(bang) abort
PythonJedi jedi_vim.jedi.cache.clear_time_caches(True)
if a:bang
PythonJedi jedi_vim.jedi.parser.utils.ParserPickling.clear_cache()
endif
endfunction
" ------------------------------------------------------------------------ " ------------------------------------------------------------------------
" show_documentation " show_documentation
" ------------------------------------------------------------------------ " ------------------------------------------------------------------------
function! jedi#show_documentation() function! jedi#show_documentation() abort
PythonJedi if jedi_vim.show_documentation() is None: vim.command('return') PythonJedi if jedi_vim.show_documentation() is None: vim.command('return')
let bn = bufnr("__doc__") let bn = bufnr('__doc__')
if bn > 0 if bn > 0
let wi=index(tabpagebuflist(tabpagenr()), bn) let wi=index(tabpagebuflist(tabpagenr()), bn)
if wi >= 0 if wi >= 0
" If the __doc__ buffer is open in the current tab, jump to it " If the __doc__ buffer is open in the current tab, jump to it
silent execute (wi+1).'wincmd w' silent execute (wi+1).'wincmd w'
else else
silent execute "sbuffer ".bn silent execute 'sbuffer '.bn
endif endif
else else
split '__doc__' split __doc__
endif endif
setlocal modifiable setlocal modifiable
@@ -289,31 +376,23 @@ function! jedi#show_documentation()
setlocal nomodifiable setlocal nomodifiable
setlocal nomodified setlocal nomodified
setlocal filetype=rst setlocal filetype=rst
setlocal foldlevel=200 " do not fold in __doc__
if l:doc_lines > g:jedi#max_doc_height " max lines for plugin if l:doc_lines > g:jedi#max_doc_height " max lines for plugin
let l:doc_lines = g:jedi#max_doc_height let l:doc_lines = g:jedi#max_doc_height
endif endif
execute "resize ".l:doc_lines execute 'resize '.l:doc_lines
" quit comands " quit comands
nnoremap <buffer> q ZQ nnoremap <buffer> q ZQ
execute "nnoremap <buffer> ".g:jedi#documentation_command." 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"
endfunction endfunction
" ------------------------------------------------------------------------ " ------------------------------------------------------------------------
" helper functions " helper functions
" ------------------------------------------------------------------------ " ------------------------------------------------------------------------
function! jedi#add_goto_window(len) function! jedi#add_goto_window(len) abort
set lazyredraw set lazyredraw
cclose cclose
let height = min([a:len, g:jedi#quickfix_window_height]) 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 if g:jedi#use_tabs_not_buffers == 1
noremap <buffer> <CR> :call jedi#goto_window_on_enter()<CR> noremap <buffer> <CR> :call jedi#goto_window_on_enter()<CR>
endif endif
au WinLeave <buffer> q " automatically leave, if an option is chosen augroup jedi_goto_window
au!
au WinLeave <buffer> q " automatically leave, if an option is chosen
augroup END
redraw! redraw!
endfunction endfunction
function! jedi#goto_window_on_enter() function! jedi#goto_window_on_enter() abort
let l:list = getqflist() let l:list = getqflist()
let l:data = l:list[line('.') - 1] let l:data = l:list[line('.') - 1]
if l:data.bufnr if l:data.bufnr
" close goto_window buffer " close goto_window buffer
normal ZQ normal! ZQ
PythonJedi jedi_vim.new_buffer(vim.eval('bufname(l:data.bufnr)')) PythonJedi jedi_vim.new_buffer(vim.eval('bufname(l:data.bufnr)'))
call cursor(l:data.lnum, l:data.col) call cursor(l:data.lnum, l:data.col)
else else
echohl WarningMsg | echo "Builtin module cannot be opened." | echohl None echohl WarningMsg | echo 'Builtin module cannot be opened.' | echohl None
endif endif
endfunction endfunction
function! s:syn_stack() function! s:syn_stack() abort
if !exists("*synstack") if !exists('*synstack')
return [] return []
endif endif
return map(synstack(line('.'), col('.') - 1), 'synIDattr(v:val, "name")') return map(synstack(line('.'), col('.') - 1), "synIDattr(v:val, 'name')")
endfunc endfunc
function! jedi#do_popup_on_dot_in_highlight() function! jedi#do_popup_on_dot_in_highlight() abort
let highlight_groups = s:syn_stack() let highlight_groups = s:syn_stack()
for a in highlight_groups for a in highlight_groups
if a == 'pythonDoctest' if a ==# 'pythonDoctest'
return 1 return 1
endif endif
endfor endfor
@@ -360,7 +442,7 @@ function! jedi#do_popup_on_dot_in_highlight()
for a in highlight_groups for a in highlight_groups
for b in ['pythonString', 'pythonComment', 'pythonNumber'] for b in ['pythonString', 'pythonComment', 'pythonNumber']
if a == b if a == b
return 0 return 0
endif endif
endfor endfor
endfor endfor
@@ -369,7 +451,10 @@ endfunc
let s:show_call_signatures_last = [0, 0, ''] 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 [line, col] = [line('.'), col('.')]
let curline = getline(line) let curline = getline(line)
let reload_signatures = 1 let reload_signatures = 1
@@ -396,13 +481,17 @@ function! jedi#show_call_signatures()
endfunction 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, ''] let s:show_call_signatures_last = [0, 0, '']
PythonJedi jedi_vim.clear_call_signatures() PythonJedi jedi_vim.clear_call_signatures()
endfunction endfunction
function! jedi#configure_call_signatures() function! jedi#configure_call_signatures() abort
augroup jedi_call_signatures augroup jedi_call_signatures
autocmd! * <buffer> autocmd! * <buffer>
if g:jedi#show_call_signatures == 2 " Command line call signatures 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 " Determine where the current window is on the screen for displaying call
" signatures in the correct column. " signatures in the correct column.
function! s:save_first_col() function! s:save_first_col() abort
if bufname('%') ==# '[Command Line]' || winnr('$') == 1 if bufname('%') ==# '[Command Line]' || winnr('$') == 1
return 0 return 0
endif endif
@@ -469,48 +558,80 @@ function! s:save_first_col()
endfunction endfunction
function! jedi#complete_string(is_popup_on_dot) function! jedi#complete_string(autocomplete) abort
if a:autocomplete
if a:is_popup_on_dot && !(g:jedi#popup_on_dot && jedi#do_popup_on_dot_in_highlight()) if !(g:jedi#popup_on_dot && jedi#do_popup_on_dot_in_highlight())
return '' return ''
endif
if pumvisible() && !a:is_popup_on_dot
return "\<C-n>"
else
return "\<C-x>\<C-o>\<C-r>=jedi#complete_opened(".a:is_popup_on_dot.")\<CR>"
endif
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
return "\<Down>"
endif endif
if a:is_popup_on_dot
if &completeopt !~ '\(noinsert\|noselect\)' let s:saved_completeopt = &completeopt
" Prevent completion of the first entry with dot completion. set completeopt-=longest
return "\<C-p>" 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
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
endif endif
elseif pumvisible()
return "\<C-n>"
endif endif
return "" return "\<C-x>\<C-o>\<C-r>=jedi#complete_opened(".a:autocomplete.")\<CR>"
endfunction endfunction
function! jedi#smart_auto_mappings() 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
return ''
endfunction
function! jedi#smart_auto_mappings() abort
" Auto put import statement after from module.name<space> and complete " 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. " 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 endif
return "\<space>" return "\<space>"
endfunction 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, speed=True, warnings=False, notices=False)
"PythonJedi jedi_vim.jedi.set_debug_function(jedi_vim.print_to_stdout) "PythonJedi jedi_vim.jedi.set_debug_function(jedi_vim.print_to_stdout)

View File

@@ -1,6 +1,6 @@
import os import os
import subprocess import subprocess
import urllib import urllib.request
import zipfile import zipfile
import pytest import pytest
@@ -19,10 +19,24 @@ class IntegrationTestFile(object):
def run(self): def run(self):
output = subprocess.check_output( output = subprocess.check_output(
[VSPEC_RUNNER, '.', VSPEC_FOLDER, self.path]) [VSPEC_RUNNER, '.', VSPEC_FOLDER, self.path])
had_ok = False
for line in output.splitlines(): for line in output.splitlines():
if line.startswith(b'not ok') or line.startswith(b'Error'): if (line.startswith(b'not ok') or
pytest.fail("{} failed:\n{}".format( line.startswith(b'Error') or
line.startswith(b'Bail out!')):
pytest.fail("{0} failed:\n{1}".format(
self.path, output.decode('utf-8')), pytrace=False) self.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("{0} failed: no 'ok' found:\n{1}".format(
self.path, output.decode('utf-8')), pytrace=False)
@property
def name(self):
name = os.path.basename(self.path)
name, _, _ = name.rpartition('.')
return name
def __repr__(self): def __repr__(self):
return "<%s: %s>" % (type(self), self.path) return "<%s: %s>" % (type(self), self.path)
@@ -33,7 +47,7 @@ def pytest_configure(config):
os.mkdir(CACHE_FOLDER) os.mkdir(CACHE_FOLDER)
if not os.path.exists(VSPEC_FOLDER): if not os.path.exists(VSPEC_FOLDER):
name, hdrs = urllib.urlretrieve(VSPEC_URL) name, hdrs = urllib.request.urlretrieve(VSPEC_URL)
z = zipfile.ZipFile(name) z = zipfile.ZipFile(name)
for n in z.namelist(): for n in z.namelist():
dest = os.path.join(CACHE_FOLDER, n) dest = os.path.join(CACHE_FOLDER, n)
@@ -42,7 +56,7 @@ def pytest_configure(config):
os.makedirs(destdir) os.makedirs(destdir)
data = z.read(n) data = z.read(n)
if not os.path.isdir(dest): if not os.path.isdir(dest):
with open(dest, 'w') as f: with open(dest, 'wb') as f:
f.write(data) f.write(data)
z.close() z.close()
os.chmod(VSPEC_RUNNER, 0o777) os.chmod(VSPEC_RUNNER, 0o777)
@@ -54,7 +68,8 @@ def pytest_generate_tests(metafunc):
""" """
def collect_tests(): def collect_tests():
for f in os.listdir(TEST_DIR): for f in os.listdir(TEST_DIR):
if f.endswith('.vim'): if f.endswith('.vim') and f != 'utils.vim':
yield IntegrationTestFile(os.path.join(TEST_DIR, f)) yield IntegrationTestFile(os.path.join(TEST_DIR, f))
metafunc.parametrize('case', list(collect_tests())) tests = list(collect_tests())
metafunc.parametrize('case', tests, ids=[test.name for test in tests])

View File

@@ -123,7 +123,7 @@ feature (such as MacVim on OS X, which also contains a console binary).
:helptags <path/to/vimruntime>/doc :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. Pathogen simplifies installation considerably.
@@ -373,6 +373,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 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 menu. By disabling this setting, completion is only started when you manually
press the completion key. press the completion key.
You need to also have `g:jedi#completions_enabled` enabled for this.
Options: 0 or 1 Options: 0 or 1
Default: 1 (Start completion on typing a period) Default: 1 (Start completion on typing a period)
@@ -510,7 +511,7 @@ Default: 1 (enabled by default)
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
6.14. `g:jedi#use_tag_stack` *g:jedi#use_tag_stack* 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 to enable full |tagstack| functionality. Use of the tag stack allows
returning to the usage of a function with CTRL-T after exploring the returning to the usage of a function with CTRL-T after exploring the
definition with arbitrary changes to the |jumplist|. definition with arbitrary changes to the |jumplist|.

View File

@@ -7,26 +7,26 @@ endif
if g:jedi#auto_initialization if g:jedi#auto_initialization
" goto / get_definition / usages " goto / get_definition / usages
if g:jedi#goto_command != '' if len(g:jedi#goto_command)
execute "nnoremap <buffer> ".g:jedi#goto_command." :call jedi#goto()<CR>" execute 'nnoremap <buffer> '.g:jedi#goto_command.' :call jedi#goto()<CR>'
endif endif
if g:jedi#goto_assignments_command != '' if len(g:jedi#goto_assignments_command)
execute "nnoremap <buffer> ".g:jedi#goto_assignments_command." :call jedi#goto_assignments()<CR>" execute 'nnoremap <buffer> '.g:jedi#goto_assignments_command.' :call jedi#goto_assignments()<CR>'
endif endif
if g:jedi#goto_definitions_command != '' if len(g:jedi#goto_definitions_command)
execute "nnoremap <buffer> ".g:jedi#goto_definitions_command." :call jedi#goto_definitions()<CR>" execute 'nnoremap <buffer> '.g:jedi#goto_definitions_command.' :call jedi#goto_definitions()<CR>'
endif endif
if g:jedi#usages_command != '' if len(g:jedi#usages_command)
execute "nnoremap <buffer> ".g:jedi#usages_command." :call jedi#usages()<CR>" execute 'nnoremap <buffer> '.g:jedi#usages_command.' :call jedi#usages()<CR>'
endif endif
" rename " rename
if g:jedi#rename_command != '' if len(g:jedi#rename_command)
execute "nnoremap <buffer> ".g:jedi#rename_command." :call jedi#rename()<CR>" execute 'nnoremap <buffer> '.g:jedi#rename_command.' :call jedi#rename()<CR>'
execute "vnoremap <buffer> ".g:jedi#rename_command." :call jedi#rename_visual()<CR>" execute 'vnoremap <buffer> '.g:jedi#rename_command.' :call jedi#rename_visual()<CR>'
endif endif
" documentation/pydoc " documentation/pydoc
if g:jedi#documentation_command != '' if len(g:jedi#documentation_command)
execute "nnoremap <silent> <buffer>".g:jedi#documentation_command." :call jedi#show_documentation()<CR>" execute 'nnoremap <silent> <buffer>'.g:jedi#documentation_command.' :call jedi#show_documentation()<CR>'
endif endif
if g:jedi#show_call_signatures > 0 && has('conceal') if g:jedi#show_call_signatures > 0 && has('conceal')
@@ -43,6 +43,8 @@ if g:jedi#auto_initialization
if g:jedi#auto_close_doc if g:jedi#auto_close_doc
" close preview if its still open after insert " 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 endif
endif 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,22 +4,40 @@
" This part of the software is just the vim interface. The really big deal is " This part of the software is just the vim interface. The really big deal is
" the Jedi Python library. " 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) " jedi-vim doesn't work in compatible mode (vim script syntax problems)
if &compatible if &compatible
" vint: -ProhibitSetNoCompatible
set nocompatible set nocompatible
" vint: +ProhibitSetNoCompatible
endif endif
" jedi-vim really needs, otherwise jedi-vim cannot start. " jedi-vim really needs, otherwise jedi-vim cannot start.
filetype plugin on filetype plugin on
" Change completeopt, but only if it has Vim's default value. " Change completeopt, but only if it was not set already.
let s:save_completeopt=&completeopt " This gets done on VimEnter, since otherwise Vim fails to restore the
set completeopt& " screen. Neovim is not affected, this is likely caused by using
let s:default_completeopt=&completeopt " :redir/execute() before the (alternate) terminal is configured.
let &completeopt=s:save_completeopt function! s:setup_completeopt()
if s:default_completeopt == &completeopt if exists('*execute')
set completeopt=menuone,longest,preview 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 endif
if len(mapcheck('<C-c>', 'i')) == 0 if len(mapcheck('<C-c>', 'i')) == 0
@@ -30,6 +48,7 @@ endif
" Pyimport command " Pyimport command
command! -nargs=1 -complete=custom,jedi#py_import_completions Pyimport :call jedi#py_import(<q-args>) command! -nargs=1 -complete=custom,jedi#py_import_completions Pyimport :call jedi#py_import(<q-args>)
command! -nargs=0 JediDebugInfo call jedi#debug_info() command! -nargs=0 -bar JediDebugInfo call jedi#debug_info()
command! -nargs=0 -bang JediClearCache call jedi#clear_cache(<bang>0)
" vim: set et ts=4: " vim: set et ts=4:

1
pythonx/jedi Submodule

Submodule pythonx/jedi added at 02f238ce08

View File

@@ -15,6 +15,7 @@ try:
except ImportError: except ImportError:
from itertools import izip_longest as zip_longest # Python 2 from itertools import izip_longest as zip_longest # Python 2
import vim
is_py3 = sys.version_info[0] >= 3 is_py3 = sys.version_info[0] >= 3
if is_py3: if is_py3:
@@ -29,10 +30,12 @@ class PythonToVimStr(unicode):
__slots__ = [] __slots__ = []
def __new__(cls, obj, encoding='UTF-8'): def __new__(cls, obj, encoding='UTF-8'):
if is_py3 or isinstance(obj, unicode): if not (is_py3 or isinstance(obj, unicode)):
return unicode.__new__(cls, obj) obj = unicode.__new__(cls, obj, encoding)
else:
return unicode.__new__(cls, obj, encoding) # Vim cannot deal with zero bytes:
obj = obj.replace('\0', '\\0')
return unicode.__new__(cls, obj)
def __repr__(self): def __repr__(self):
# this is totally stupid and makes no sense but vim/python unicode # this is totally stupid and makes no sense but vim/python unicode
@@ -62,46 +65,53 @@ def _catch_exception(string, is_eval):
Interface between vim and python calls back to it. Interface between vim and python calls back to it.
Necessary, because the exact error message is not given by `vim.error`. Necessary, because the exact error message is not given by `vim.error`.
""" """
e = 'jedi#_vim_exceptions(%s, %s)' result = vim.eval('jedi#_vim_exceptions({0}, {1})'.format(
result = vim.eval(e % (repr(PythonToVimStr(string, 'UTF-8')), is_eval)) repr(PythonToVimStr(string, 'UTF-8')), int(is_eval)))
if 'exception' in result: if 'exception' in result:
raise VimError(result['exception'], result['throwpoint'], string) raise VimError(result['exception'], result['throwpoint'], string)
return result['result'] return result['result']
def vim_command(string): def vim_command(string):
_catch_exception(string, 0) _catch_exception(string, False)
def vim_eval(string): def vim_eval(string):
return _catch_exception(string, 1) return _catch_exception(string, True)
def no_jedi_warning(error=None): 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: if error:
msg = '{} The error was: {}'.format(msg, error) vim.command('echom "The error was: {0}"'.format(error))
vim.command('echohl WarningMsg' vim.command('echohl None')
'| echom "Please install Jedi if you want to use jedi-vim."'
'| echohl None')
def echo_highlight(msg): def echo_highlight(msg):
vim_command('echohl WarningMsg | echom "{}" | echohl None'.format( vim_command('echohl WarningMsg | echom "jedi-vim: {0}" | echohl None'.format(
msg.replace('"', '\\"'))) 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: try:
import jedi import jedi
except ImportError as e: except ImportError as e:
no_jedi_warning(str(e)) no_jedi_warning(str(e))
jedi = None jedi = None
jedi_import_error = str(e)
else: else:
try: try:
version = jedi.__version__ version = jedi.__version__
except Exception as e: # e.g. AttributeError 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 jedi = None
else: else:
if isinstance(version, str): if isinstance(version, str):
@@ -110,6 +120,9 @@ else:
version = utils.version_info() version = utils.version_info()
if version < (0, 7): if version < (0, 7):
echo_highlight('Please update your Jedi version, it is too old.') 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): def catch_and_print_exceptions(func):
@@ -155,7 +168,7 @@ def completions():
row, column = vim.current.window.cursor row, column = vim.current.window.cursor
# Clear call signatures in the buffer so they aren't seen by the completer. # Clear call signatures in the buffer so they aren't seen by the completer.
# Call signatures in the command line can stay. # 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() clear_call_signatures()
if vim.eval('a:findstart') == '1': if vim.eval('a:findstart') == '1':
count = 0 count = 0
@@ -184,7 +197,7 @@ def completions():
out = [] out = []
for c in completions: for c in completions:
d = dict(word=PythonToVimStr(c.name[:len(base)] + c.complete), 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 # stuff directly behind the completion
menu=PythonToVimStr(c.description), menu=PythonToVimStr(c.description),
info=PythonToVimStr(c.docstring()), # docstr info=PythonToVimStr(c.docstring()), # docstr
@@ -225,76 +238,72 @@ def goto(mode="goto", no_output=False):
:rtype: list :rtype: list
""" """
script = get_script() script = get_script()
try: if mode == "goto":
if mode == "goto": definitions = [x for x in script.goto_definitions()
definitions = [x for x in script.goto_definitions() if not x.in_builtin_module()]
if not x.in_builtin_module()]
if not definitions:
definitions = script.goto_assignments()
elif mode == "related_name":
definitions = script.usages()
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
if not definitions: if not definitions:
echo_highlight("Couldn't find any definitions for this.") definitions = script.goto_assignments()
elif len(definitions) == 1 and mode != "related_name": elif mode == "related_name":
# just add some mark to add the current position to the jumplist. definitions = script.usages()
# this is ugly, because it overrides the mark for '`', so if anyone elif mode == "definition":
# has a better idea, let me know. definitions = script.goto_definitions()
vim_command('normal! m`') elif mode == "assignment":
definitions = script.goto_assignments()
d = list(definitions)[0]
if d.in_builtin_module(): if no_output:
if d.is_keyword: return definitions
echo_highlight("Cannot get the definition of Python keywords.") if not definitions:
else: echo_highlight("Couldn't find any definitions for this.")
echo_highlight("Builtin modules cannot be displayed (%s)." elif len(definitions) == 1 and mode != "related_name":
% d.desc_with_module) d = list(definitions)[0]
if d.in_builtin_module():
if d.is_keyword:
echo_highlight("Cannot get the definition of Python keywords.")
else: else:
using_tagstack = vim_eval('g:jedi#use_tag_stack') == '1' echo_highlight("Builtin modules cannot be displayed (%s)."
if d.module_path != vim.current.buffer.name: % d.desc_with_module)
result = new_buffer(d.module_path,
using_tagstack=using_tagstack)
if not result:
return []
if d.module_path and using_tagstack:
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:
old_tags = vim.eval('&tags')
old_wildignore = vim.eval('&wildignore')
try:
# Clear wildignore to ensure tag file isn't ignored
vim.command('set wildignore=')
vim.command('let &tags = %s' %
repr(PythonToVimStr(f.name)))
vim.command('tjump %s' % tagname)
finally:
vim.command('let &tags = %s' %
repr(PythonToVimStr(old_tags)))
vim.command('let &wildignore = %s' %
repr(PythonToVimStr(old_wildignore)))
vim.current.window.cursor = d.line, d.column
else: else:
# multiple solutions using_tagstack = int(vim_eval('g:jedi#use_tag_stack')) == 1
lst = [] if (d.module_path or '') != vim.current.buffer.name:
for d in definitions: result = new_buffer(d.module_path,
if d.in_builtin_module(): using_tagstack=using_tagstack)
lst.append(dict(text=PythonToVimStr('Builtin ' + d.description))) if not result:
else: return []
lst.append(dict(filename=PythonToVimStr(d.module_path), if d.module_path and os.path.exists(d.module_path) and using_tagstack:
lnum=d.line, col=d.column + 1, tagname = d.name
text=PythonToVimStr(d.description))) with tempfile('{0}\t{1}\t{2}'.format(tagname, d.module_path,
vim_eval('setqflist(%s)' % repr(lst)) 'call cursor({0}, {1})'.format(d.line, d.column + 1))) as f:
vim_eval('jedi#add_goto_window(' + str(len(lst)) + ')') old_tags = vim.eval('&tags')
old_wildignore = vim.eval('&wildignore')
try:
# Clear wildignore to ensure tag file isn't ignored
vim.command('set wildignore=')
vim.command('let &tags = %s' %
repr(PythonToVimStr(f.name)))
vim.command('tjump %s' % tagname)
finally:
vim.command('let &tags = %s' %
repr(PythonToVimStr(old_tags)))
vim.command('let &wildignore = %s' %
repr(PythonToVimStr(old_wildignore)))
vim.current.window.cursor = d.line, d.column
else:
# multiple solutions
lst = []
for d in definitions:
if d.in_builtin_module():
lst.append(dict(text=PythonToVimStr('Builtin ' + d.description)))
elif d.module_path 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),
lnum=d.line, col=d.column + 1,
text=PythonToVimStr(d.description)))
vim_eval('setqflist(%s)' % repr(lst))
vim_eval('jedi#add_goto_window(' + str(len(lst)) + ')')
return definitions return definitions
@@ -327,7 +336,7 @@ def show_documentation():
@catch_and_print_exceptions @catch_and_print_exceptions
def clear_call_signatures(): def clear_call_signatures():
# Check if using command line 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 ""') vim_command('echo ""')
return return
cursor = vim.current.window.cursor cursor = vim.current.window.cursor
@@ -336,7 +345,8 @@ def clear_call_signatures():
# 1. Search for a line with a call signature and save the appended # 1. Search for a line with a call signature and save the appended
# characters # characters
# 2. Actually replace the line and redo the status quo. # 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): for i, line in enumerate(vim.current.buffer):
match = re.search(py_regex, line) match = re.search(py_regex, line)
if match is not None: if match is not None:
@@ -352,7 +362,7 @@ def clear_call_signatures():
@_check_jedi_availability(show_error=False) @_check_jedi_availability(show_error=False)
@catch_and_print_exceptions @catch_and_print_exceptions
def show_call_signatures(signatures=()): 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 return
if signatures == (): if signatures == ():
@@ -362,7 +372,7 @@ def show_call_signatures(signatures=()):
if not signatures: if not signatures:
return 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) return cmdline_call_signatures(signatures)
for i, signature in enumerate(signatures): for i, signature in enumerate(signatures):
@@ -378,7 +388,8 @@ def show_call_signatures(signatures=()):
# TODO check if completion menu is above or below # TODO check if completion menu is above or below
line = vim_eval("getline(%s)" % line_to_replace) 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: try:
# *_*PLACEHOLDER*_* makes something fat. See after/syntax file. # *_*PLACEHOLDER*_* makes something fat. See after/syntax file.
params[signature.index] = '*_*%s*_*' % params[signature.index] params[signature.index] = '*_*%s*_*' % params[signature.index]
@@ -424,7 +435,7 @@ def show_call_signatures(signatures=()):
@catch_and_print_exceptions @catch_and_print_exceptions
def cmdline_call_signatures(signatures): def cmdline_call_signatures(signatures):
def get_params(s): 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): def escape(string):
return string.replace('"', '\\"').replace(r'\n', r'\\n') return string.replace('"', '\\"').replace(r'\n', r'\\n')
@@ -448,7 +459,7 @@ def cmdline_call_signatures(signatures):
max_msg_len = int(vim_eval('&columns')) - 12 max_msg_len = int(vim_eval('&columns')) - 12
if int(vim_eval('&ruler')): if int(vim_eval('&ruler')):
max_msg_len -= 18 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): if max_msg_len < (1 if params else 0):
return return
@@ -483,7 +494,7 @@ def cmdline_call_signatures(signatures):
_, column = signatures[0].bracket_start _, column = signatures[0].bracket_start
spaces = min(int(vim_eval('g:jedi#first_col +' spaces = min(int(vim_eval('g:jedi#first_col +'
'wincol() - col(".")')) + 'wincol() - col(".")')) +
column - len(signatures[0].call_name), column - len(signatures[0].name),
max_num_spaces) * ' ' max_num_spaces) * ' '
if index is not None: if index is not None:
@@ -494,33 +505,40 @@ def cmdline_call_signatures(signatures):
'echohl jediFat | echon "%s" | ' 'echohl jediFat | echon "%s" | '
'echohl jediFunction | echon "%s" | ' 'echohl jediFunction | echon "%s" | '
'echohl None | echon ")"' 'echohl None | echon ")"'
% (spaces, signatures[0].call_name, % (spaces, signatures[0].name,
left + ', ' if left else '', left + ', ' if left else '',
center, ', ' + right if right else '')) center, ', ' + right if right else ''))
else: else:
vim_command(' echon "%s" | ' vim_command(' echon "%s" | '
'echohl Function | echon "%s" | ' 'echohl Function | echon "%s" | '
'echohl None | echon "(%s)"' 'echohl None | echon "(%s)"'
% (spaces, signatures[0].call_name, text)) % (spaces, signatures[0].name, text))
@_check_jedi_availability(show_error=True) @_check_jedi_availability(show_error=True)
@catch_and_print_exceptions @catch_and_print_exceptions
def rename(): def rename():
if not int(vim.eval('a:0')): 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('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('augroup END')
vim_command("let s:jedi_replace_orig = expand('<cword>')") vim_command("let s:jedi_replace_orig = expand('<cword>')")
vim_command('normal! diw') vim_command('normal! diw')
vim_command("let s:jedi_changedtick = b:changedtick")
vim_command('startinsert') vim_command('startinsert')
else: else:
# Remove autocommand. # Remove autocommand.
vim_command('autocmd! jedi_rename InsertLeave') 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. # Get replacement, if there is something on the cursor.
# This won't be the case when the user ends insert mode right away, # This won't be the case when the user ends insert mode right away,
# and `<cword>` would pick up the nearest word instead. # and `<cword>` would pick up the nearest word instead.
@@ -529,13 +547,7 @@ def rename():
else: else:
replace = None replace = None
cursor = vim.current.window.cursor vim_command('undo {}'.format(changenr))
# 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.current.window.cursor = cursor vim.current.window.cursor = cursor
@@ -565,16 +577,17 @@ def do_rename(replace, orig=None):
# Sort the whole thing reverse (positions at the end of the line # Sort the whole thing reverse (positions at the end of the line
# must be first, because they move the stuff before the position). # must be first, because they move the stuff before the position).
temp_rename = sorted(temp_rename, reverse=True, 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() buffers = set()
for r in temp_rename: for r in temp_rename:
if r.in_builtin_module(): if r.in_builtin_module():
continue continue
if os.path.abspath(vim.current.buffer.name) != r.module_path: if os.path.abspath(vim.current.buffer.name) != r.module_path:
assert r.module_path is not None
result = new_buffer(r.module_path) result = new_buffer(r.module_path)
if not result: if not result:
echo_highlight("Jedi-vim: failed to create buffer window for {}!".format(r.module_path)) echo_highlight("Jedi-vim: failed to create buffer window for {0}!".format(r.module_path))
continue continue
buffers.add(vim.current.buffer.name) buffers.add(vim.current.buffer.name)
@@ -583,21 +596,21 @@ def do_rename(replace, orig=None):
saved_view = vim_eval('string(winsaveview())') saved_view = vim_eval('string(winsaveview())')
# Replace original word. # Replace original word.
vim.current.window.cursor = r.start_pos vim.current.window.cursor = (r.line, r.column)
vim_command('normal! c{:d}l{}'.format(len(orig), replace)) vim_command('normal! c{0:d}l{1}'.format(len(orig), replace))
# Restore view. # Restore view.
vim_command('call winrestview(%s)' % saved_view) vim_command('call winrestview(%s)' % saved_view)
# Restore previous tab and window. # Restore previous tab and window.
vim_command('tabnext {:d}'.format(saved_tab)) vim_command('tabnext {0:d}'.format(saved_tab))
vim_command('{:d}wincmd w'.format(saved_win)) vim_command('{0:d}wincmd w'.format(saved_win))
if len(buffers) > 1: 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))) len(temp_rename), len(buffers)))
else: 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) @_check_jedi_availability(show_error=True)
@@ -638,9 +651,9 @@ def py_import_completions():
@catch_and_print_exceptions @catch_and_print_exceptions
def new_buffer(path, options='', using_tagstack=False): def new_buffer(path, options='', using_tagstack=False):
# options are what you can to edit the edit options # 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) _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') user_split_option = vim_eval('g:jedi#use_splits_not_buffers')
split_options = { split_options = {
'top': 'topleft split', 'top': 'topleft split',
@@ -649,15 +662,19 @@ def new_buffer(path, options='', using_tagstack=False):
'bottom': 'botright split', 'bottom': 'botright split',
'winwidth': 'vs' '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' split_options['winwidth'] = 'sp'
if user_split_option not in split_options: 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: else:
vim_command(split_options[user_split_option] + " %s" % escape_file_path(path)) vim_command(split_options[user_split_option] + " %s" % escape_file_path(path))
else: else:
if vim_eval("!&hidden && &modified") == '1': if int(vim_eval("!&hidden && &modified")) == 1:
if vim_eval("bufname('%')") is None: if not vim_eval("bufname('%')"):
echo_highlight('Cannot open a new buffer, use `:set hidden` or save your buffer') echo_highlight('Cannot open a new buffer, use `:set hidden` or save your buffer')
return False return False
else: else:
@@ -666,9 +683,9 @@ def new_buffer(path, options='', using_tagstack=False):
return True return True
vim_command('edit %s %s' % (options, escape_file_path(path))) vim_command('edit %s %s' % (options, escape_file_path(path)))
# sometimes syntax is being disabled and the filetype not set. # 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') vim_command('syntax enable')
if vim_eval("&filetype != 'python'") == '1': if int(vim_eval("&filetype != 'python'")) == 1:
vim_command('set filetype=python') vim_command('set filetype=python')
return True return True
@@ -681,7 +698,7 @@ def _tabnew(path, options=''):
:param options: `:tabnew` options, read vim help. :param options: `:tabnew` options, read vim help.
""" """
path = os.path.abspath(path) 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))) vim_command('tab drop %s %s' % (options, escape_file_path(path)))
return return

44
pythonx/jedi_vim_debug.py Normal file
View File

@@ -0,0 +1,44 @@
"""Used in jedi-vim's jedi#debug_info()"""
def display_debug_info():
import vim
def echo(msg):
vim.command('echo {0}'.format(msg))
echo("printf(' - sys.version: `%s`', {0!r})".format(
', '.join([x.strip()
for x in __import__('sys').version.split('\n')])))
echo("printf(' - site module: `%s`', {0!r})".format(
__import__('site').__file__))
try:
import jedi_vim
except Exception as e:
echo("printf('ERROR: jedi_vim is not available: %s: %s', "
"{0!r}, {1!r})".format(e.__class__.__name__, str(e)))
return
try:
if jedi_vim.jedi is None:
echo("'ERROR: could not import the \"jedi\" Python module.'")
echo("printf(' The error was: %s', {0!r})".format(
getattr(jedi_vim, "jedi_import_error", "UNKNOWN")))
else:
echo("printf('Jedi path: `%s`', {0!r})".format(
jedi_vim.jedi.__file__))
echo("printf(' - version: %s', {0!r})".format(
jedi_vim.jedi.__version__))
echo("' - sys_path:'")
script_evaluator = jedi_vim.jedi.Script('')._evaluator
try:
sys_path = script_evaluator.project.sys_path
except AttributeError:
sys_path = script_evaluator.sys_path
for p in sys_path:
echo("printf(' - `%s`', {0!r})".format(p))
except Exception as e:
echo("printf('There was an error accessing jedi_vim.jedi: %s', "
"{0!r})".format(e))

1
pythonx/parso Submodule

Submodule pythonx/parso added at 2ca629a2f6

View File

@@ -8,6 +8,8 @@ describe 'completions'
end end
after after
" default
let g:jedi#popup_select_first = 1
bd! bd!
end end
@@ -37,26 +39,32 @@ describe 'completions'
Expect getline('.') == 'IndentationError().filename' Expect getline('.') == 'IndentationError().filename'
end end
it 'dot_open' it 'multi complete'
normal oraisX ImpXErrX() normal oImpXErrX()
Expect getline('.') == 'raise ImportError()' Expect getline('.') == 'ImportError()'
end end
it 'cycling through entries' it 'cycling through entries popup_select_first=0'
" 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 let g:jedi#popup_select_first = 0
execute "normal oraise impX\<C-n>\<C-n>\<C-n>" execute "normal oraise impX\<C-n>"
Expect getline('.') == 'raise ImportWarning' " It looks like this is currently not working properly.
let g:jedi#popup_select_first = 1 "Expect getline('.') == 'raise ImportError'
end
it 'cycling through entries popup_select_first=1'
execute "normal oraise impX\<C-n>"
Expect getline('.') == 'raise ImportWarning'
end
it 'longest'
" -longest completes the first one " -longest completes the first one
set completeopt -=longest set completeopt -=longest
execute "normal oraise baseX" execute "normal oraise baseX"
Expect getline('.') == 'raise BaseException' Expect getline('.') == 'raise BaseException'
set completeopt +=longest set completeopt +=longest
end
it 'dot_open'
end end
end end

View File

@@ -13,7 +13,7 @@ describe 'documentation docstrings'
it 'simple' it 'simple'
put = 'ImportError' put = 'ImportError'
normal GK normal GK
Expect bufname('%') == "'__doc__'" Expect bufname('%') == "__doc__"
Expect &filetype == 'rst' Expect &filetype == 'rst'
let content = join(getline(1,'$'), "\n") let content = join(getline(1,'$'), "\n")
Expect stridx(content, "Import can't find module") > 0 Expect stridx(content, "Import can't find module") > 0

View File

@@ -2,7 +2,7 @@ let mapleader = '\'
source plugin/jedi.vim source plugin/jedi.vim
source test/utils.vim source test/utils.vim
describe 'goto_simple' describe 'goto simple'
before before
new " open a new split new " open a new split
set filetype=python set filetype=python
@@ -20,13 +20,13 @@ describe 'goto_simple'
bd! bd!
end end
it 'goto_definitions' it 'goto definitions'
silent normal \d normal \d
Expect line('.') == 1 Expect line('.') == 1
"Expect col('.') == 5 " not working yet. Expect col('.') == 5
end end
it 'goto_assignments' it 'goto assignments'
silent normal \g silent normal \g
Expect line('.') == 2 Expect line('.') == 2
Expect col('.') == 1 Expect col('.') == 1
@@ -45,7 +45,7 @@ describe 'goto_simple'
end end
describe 'goto_with_tabs' describe 'goto with tabs'
before before
set filetype=python set filetype=python
let g:jedi#use_tabs_not_buffers = 1 let g:jedi#use_tabs_not_buffers = 1
@@ -56,7 +56,7 @@ describe 'goto_with_tabs'
bd! bd!
end end
it 'follow_import' it 'follow import'
put = ['import subprocess', 'subprocess'] put = ['import subprocess', 'subprocess']
silent normal G\g silent normal G\g
Expect getline('.') == 'import subprocess' Expect getline('.') == 'import subprocess'
@@ -73,7 +73,7 @@ describe 'goto_with_tabs'
Expect bufname('%') == '' Expect bufname('%') == ''
end end
it 'multi_definitions' it 'multi definitions'
" This used to behave differently. Now we don't have any real multi " This used to behave differently. Now we don't have any real multi
" definitions. " definitions.
@@ -96,7 +96,7 @@ describe 'goto_with_tabs'
end end
describe 'goto_with_buffers' describe 'goto with buffers'
before before
set filetype=python set filetype=python
let g:jedi#use_tabs_not_buffers = 0 let g:jedi#use_tabs_not_buffers = 0
@@ -108,11 +108,11 @@ describe 'goto_with_buffers'
set nohidden set nohidden
end end
it 'no_new_tabs' it 'no new tabs'
put = ['import os'] put = ['import os']
normal G$ normal G$
call jedi#goto_assignments() call jedi#goto_assignments()
python jedi_vim.goto() PythonJedi jedi_vim.goto()
Expect CurrentBufferIsModule('os') == 0 Expect CurrentBufferIsModule('os') == 0
" Without hidden, it's not possible to open a new buffer, when the old " Without hidden, it's not possible to open a new buffer, when the old
" one is not saved. " one is not saved.
@@ -125,7 +125,7 @@ describe 'goto_with_buffers'
Expect col('.') == 1 Expect col('.') == 1
end end
it 'multi_definitions' it 'multi definitions'
" set hidden " set hidden
" put = ['import tokenize'] " put = ['import tokenize']
" silent normal G$\d " silent normal G$\d
@@ -147,7 +147,7 @@ end
describe 'goto_with_splits' describe 'goto with splits'
before before
set filetype=python set filetype=python
let g:jedi#use_splits_not_buffers = 'left' let g:jedi#use_splits_not_buffers = 'left'
@@ -158,7 +158,7 @@ describe 'goto_with_splits'
bd! bd!
end end
it 'follow_import' it 'follow import'
put = ['import subprocess', 'subprocess'] put = ['import subprocess', 'subprocess']
silent normal G\g silent normal G\g
Expect getline('.') == 'import subprocess' Expect getline('.') == 'import subprocess'
@@ -177,7 +177,7 @@ describe 'goto_with_splits'
end end
describe 'goto_wildignore' describe 'goto wildignore'
before before
set filetype=python set filetype=python
set wildignore=*,with\ spaces,*.pyc set wildignore=*,with\ spaces,*.pyc
@@ -198,14 +198,14 @@ describe 'goto_wildignore'
set wildignore&vim set wildignore&vim
end end
it 'restores_wildignore' it 'restores wildignore'
let before = &wildignore let before = &wildignore
call jedi#goto() call jedi#goto()
Expect getline('.') =~ 'Popen' Expect getline('.') =~ 'Popen'
Expect &wildignore == before Expect &wildignore == before
end end
it 'not_using_tagstack' it 'not using tagstack'
let g:jedi#use_tag_stack = 0 let g:jedi#use_tag_stack = 0
call jedi#goto() call jedi#goto()
Expect CurrentBufferIsModule('subprocess') == 1 Expect CurrentBufferIsModule('subprocess') == 1

View File

@@ -27,6 +27,10 @@ describe 'pyimport'
Expect jedi#py_import_completions('subproc', 0, 0) == 'subprocess' Expect jedi#py_import_completions('subproc', 0, 0) == 'subprocess'
Expect jedi#py_import_completions('subprocess', 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
end end

View File

@@ -11,14 +11,17 @@ describe 'signatures'
end end
it 'simple' it 'simple'
normal oabs( normal odef xyz(number): return
normal o
normal oxyz(
normal G$
" equals doautocmd CursorMovedI " equals doautocmd CursorMovedI
Python jedi_vim.show_call_signatures() Python jedi_vim.show_call_signatures()
Expect getline(1) == '=`=jedi=0, =`= (*_*number*_*) =`=jedi=`=' Expect getline(3) == '?!?jedi=0, ?!? (*_*number*_*) ?!?jedi?!?'
doautocmd InsertLeave doautocmd InsertLeave
Expect getline(1) == '' Expect getline(3) == ''
end end
it 'multiple buffers' it 'multiple buffers'
@@ -40,9 +43,9 @@ describe 'signatures'
it 'simple after CursorHoldI with only parenthesis' it 'simple after CursorHoldI with only parenthesis'
noautocmd normal o noautocmd normal o
doautocmd CursorHoldI doautocmd CursorHoldI
noautocmd normal iabs( noautocmd normal istr(
doautocmd CursorHoldI doautocmd CursorHoldI
Expect getline(1) == '=`=jedi=0, =`= (*_*number*_*) =`=jedi=`=' Expect getline(1) == '?!?jedi=0, ?!? (*_*object*_*) ?!?jedi?!?'
end end
it 'no signature' it 'no signature'
@@ -65,11 +68,11 @@ describe 'signatures'
let g:jedi#show_call_signatures = 2 let g:jedi#show_call_signatures = 2
call jedi#configure_call_signatures() call jedi#configure_call_signatures()
normal oabs( normal ostr(
redir => msg redir => msg
Python jedi_vim.show_call_signatures() Python jedi_vim.show_call_signatures()
redir END redir END
Expect msg == "\nabs(number)" Expect msg == "\nstr(object)"
redir => msg redir => msg
doautocmd InsertLeave doautocmd InsertLeave