346 Commits

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: https://github.com/davidhalter/jedi/compare/995a6531225ba0b65e1ff863d97e5404d989047b...2ba78ab725f1e02dfef8bc50b0204cf656e8ee23.
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
Dave Halter dc23f0b859 Merge pull request #501 from kashiro/fix/auto-selected-last-opt
check "noselect" and "noinsert" before <C-p>
2015-11-19 13:15:06 +01:00
Tomoyuki Kashiro 217e56d9bd check "noselect" and "noinsert" before <C-p>
to prevent from selecting last option check "noselect" and "noinsert" before <C-p>
  @see https://github.com/Shougo/neocomplete.vim/blob/master/doc/neocomplete.txt#L1817-L1826
2015-11-19 18:49:15 +09:00
Jacob Niehus 0c2831d9a6 Fix parameters missing from command line call signatures
Parameters (or ellipsis) should show up in call signatures even when the
index of the current argument is unknown.

Closes https://github.com/davidhalter/jedi-vim/pull/499.
2015-11-12 02:03:46 +01:00
Dave Halter b3e91e8de2 Merge pull request #497 from wilywampa/buffer_autocmds
Fix signatures only working in a single buffer
2015-11-07 21:15:14 +01:00
Jacob Niehus 13a4a0c0c4 Fix signatures only working in a single buffer 2015-11-07 11:43:56 -07:00
Jacob Niehus 2cf1d42fff Fix handling of temporary tags file on Windows
Fixes https://github.com/davidhalter/jedi-vim/issues/482.
Closes https://github.com/davidhalter/jedi-vim/pull/489.
2015-11-02 01:04:16 +01:00
Bagrat Aznauryan 84f5cd92c7 Use escape_file_path in new_buffer
Fix: If a definition file path contains a space, the "open in split"
     fails with an error.

Fixes https://github.com/davidhalter/jedi-vim/issues/491.
Closes https://github.com/davidhalter/jedi-vim/issues/492.
2015-11-02 01:02:22 +01:00
Daniel Hahler 9af06424fb doc/jedi-vim.txt: retab with expandtab
Fixes https://github.com/davidhalter/jedi-vim/issues/437.
Closes https://github.com/davidhalter/jedi-vim/pull/487.
2015-10-26 23:53:55 +01:00
Jacob Niehus 4b32847110 Fix issues with wildignore and tag stack
Closes https://github.com/davidhalter/jedi-vim/pull/483.
Fixes https://github.com/davidhalter/jedi-vim/issues/482.
2015-10-23 00:31:28 +02:00
Daniel Hahler a5be01fb0b Merge pull request #481 from blueyed/improve-taglist-hack
Improve use_tag_stack-hack: use context managers, short 'tags'
2015-10-19 23:47:00 +02:00
Daniel Hahler 267df8b3da Improve use_tag_stack-hack: use context managers, short 'tags'
Use a NamedTemporaryFile context manager, which removes the temporary
file again, and use it as the only entry for the 'tags' setting to
improve lookup performance.
2015-10-19 18:29:54 +02:00
Daniel Hahler 005cb5225f Use string.ascii_lowercase instead of string.lowercase
Fixes https://github.com/davidhalter/jedi-vim/issues/478.
Closes https://github.com/davidhalter/jedi-vim/pull/480.
2015-10-18 22:14:31 +02:00
Dave Halter 95d8eb1b08 Merge pull request #479 from blueyed/fix-cached-signature-call
Handle parenthesis with show_call_signatures' cache
2015-10-18 21:45:18 +02:00
Daniel Hahler 431a0b11e5 Handle parenthesis with show_call_signatures' cache
After `o`, call signatures should show up after `abs(`.
2015-10-18 21:22:11 +02:00
Daniel Hahler 9a258c74f5 Merge branch 'wilywampa-callsig_columns'
Truncate command line call signature as described in #474 when the full
signature is too long to display.

Closes https://github.com/davidhalter/jedi-vim/issues/474.
Closes https://github.com/davidhalter/jedi-vim/pull/475.
2015-10-18 21:16:48 +02:00
Daniel Hahler 5c868b9a1f Use utf8 ellipsis char instead of 3 dots 2015-10-18 21:16:37 +02:00
Jacob Niehus 62c423bf29 Add test case for truncation of cmdline signatures 2015-10-18 21:16:37 +02:00
Jacob Niehus 7abc3ad8d4 Truncate long command line call signatures 2015-10-18 21:16:37 +02:00
Jacob Niehus 9633044332 Allow fewer columns in call signatures if 'ruler' is set 2015-10-18 21:16:37 +02:00
Dave Halter 067ab1ea4b Merge pull request #477 from blueyed/fix-cached-signature-call
Invalidate `show_call_signatures_delay` on InsertEnter
2015-10-18 21:01:37 +02:00
Daniel Hahler e38981fc4f Invalidate show_call_signatures_delay on InsertEnter
Followup to e241cf87fd.
Ref: https://github.com/davidhalter/jedi-vim/pull/420.
Ref: https://github.com/davidhalter/jedi-vim/pull/475#issuecomment-149013542.
2015-10-18 16:07:09 +02:00
Dave Halter 8ee4e12d3e Merge pull request #458 from wilywampa/goto_tagstack
Add g:jedi#use_tag_stack feature for jedi#goto()
2015-10-18 11:51:11 +02:00
Jacob Niehus b38ec94646 Improve documentation of use_tag_stack option 2015-10-16 12:55:40 -07:00
Jacob Niehus 9c235c79ac Fix hidden check again 2015-10-16 12:55:40 -07:00
Jacob Niehus 8cfa121b4d Fix using tabs/splits instead of buffers 2015-10-16 12:55:40 -07:00
Jacob Niehus c94fe6fcee Check if buffer can be hidden before tjump 2015-10-16 12:55:40 -07:00
Jacob Niehus 5041224c13 Use vim tempname() instead of Python tempfile 2015-10-16 12:55:40 -07:00
Jacob Niehus 4867831ad0 Add g:jedi#use_tag_stack feature for jedi#goto() 2015-10-16 12:55:40 -07:00
Dave Halter 610cbcacb7 Merge pull request #436 from blueyed/delayed-call-signatures
Delayed call signatures
2015-10-14 15:05:58 +02:00
Dave Halter b5ec9ac3ed Merge pull request #472 from blueyed/CONTRIBUTING.md-debug-info
CONTRIBUTING.md: request :version and :JediDebugInfo output
2015-10-09 00:23:21 +02:00
Daniel Hahler 253eb5102c CONTRIBUTING.md: request :version and :JediDebugInfo output
Also add sections, and fix style instructions.

[ci skip]
2015-10-08 17:30:35 +02:00
Daniel Hahler 9ec2fb44b0 smart_auto_mappings: look for from only at the start of a line
Fixes https://github.com/davidhalter/jedi-vim/issues/469.
Closes https://github.com/davidhalter/jedi-vim/pull/470.
2015-10-06 01:44:26 +02:00
Daniel Hahler e241cf87fd Conditionally skip calls to jedi_vim.show_call_signatures
Skip calls to `jedi_vim.show_call_signatures` if the (position of the) current
function's argument did not change (by means of comma positions before
and after the cursor).

Ref: https://github.com/davidhalter/jedi-vim/pull/420
2015-10-03 15:43:39 +02:00
Dave Halter 525524b5cf Merge pull request #464 from itchyny/fix-global-env-pollution
make `key` and `val` script local
2015-09-28 00:49:33 +02:00
itchyny 267f66755d make key and val script local 2015-09-28 07:02:30 +09:00
Daniel Hahler 6b96313930 Add show_call_signatures_delay option
This will use CursorHoldI instead of CursorMovedI for displaying call
signatures, with a delay of 500ms by default.

This greatly enhances the experience with slow call signatures while typing
(depending on how fast Jedi is for the given context).
2015-09-10 11:55:04 +02:00
Daniel Hahler afc02a3621 Wrap jedi#configure_call_signatures in augroup 2015-09-10 11:55:03 +02:00
Dave Halter bcf24529fa Merge pull request #461 from blueyed/importerror-with-no_jedi_warning
Pass ImportError to no_jedi_warning and display it there
2015-09-08 16:42:38 +02:00
Daniel Hahler 676b37812b Pass ImportError to no_jedi_warning and display it there
Ref: https://github.com/davidhalter/jedi-vim/issues/460
2015-09-08 14:33:40 +02:00
Daniel Hahler 0d52b56a72 Merge pull request #455 from blueyed/add-reinit_python
Add jedi#reinit_python
2015-08-20 23:38:13 +02:00
Dave Halter 45c0b91c5e Merge pull request #456 from blueyed/add-debug-info
Add JediDebugInfo command: display used Python version
2015-08-20 10:32:38 +02:00
Dave Halter 261261af3d Merge pull request #457 from blueyed/warn-auto-nvim-not-available
nvim: add a warning in case the auto-detected version is not functional
2015-08-20 10:28:57 +02:00
Daniel Hahler 3f259c2a9e Followup to 0703494: use <silent> with <C-R> mapping
Without this, the mapping/function will be displayed on Vim's cmdline.
2015-08-20 00:07:27 +02:00
Daniel Hahler 83e62d56ba Add jedi#reinit_python
This is meant to be used in case you want to re-init the Python version
used by jedi-vim, without restarting Vim.

I had this laying around.. it might be better to just export
`s:init_python` as `jedi#init_python`?!
2015-08-19 23:58:47 +02:00
Daniel Hahler ed09c7c1af Add JediDebugInfo command: display used Python version
This command is meant to come in handy to debug problems with jedi-vim.
For now, it will display the Python version that jedi-vim is using.
2015-08-19 23:57:29 +02:00
Daniel Hahler 2fbcc5b991 nvim: add a warning in case the auto-detected version is not functional
This usually means that the `neovim` module is not installed, which
commonly happens in a virtualenv.
2015-08-19 23:54:30 +02:00
Daniel Hahler 7890339ca8 Merge pull request #454 from davidhalter/smart-import-mapping
Smart import mapping

Closes https://github.com/davidhalter/jedi-vim/pull/453.
Closes https://github.com/davidhalter/jedi-vim/pull/454.
2015-08-19 23:46:22 +02:00
Daniel Hahler 91c2a031df Add tests for smart_auto_mappings 2015-08-19 22:37:32 +02:00
Daniel Hahler 0703494188 smart_auto_mappings: use C-r instead of expr-mapping
This makes it work in tests.  Using `<expr>` instead will not trigger
the expansion of the mapping.
This is likely a bug in vim-vspec; I have tried 1.4.1 (currently pinned)
and 1.6.1.
2015-08-19 22:37:13 +02:00
Daniel Hahler 6dedbf339e smart_auto_mappings: improve pattern 2015-08-19 22:36:23 +02:00
Daniel Hahler 889feae117 jedi#smart_auto_mappings: always 'popup_on_dot'
`popup_on_dot=1` means that it should not auto-select the first entry,
which is the case for the new smart-import-mapping.
2015-08-19 22:34:52 +02:00
Ali Aliyev ac1615c647 Smart completion after "from foo": add "import" and complete
This adds a new setting `jedi#smart_auto_mappings` (default 1).
2015-08-17 23:36:48 +02:00
Dave Halter d3484afe20 Merge pull request #442 from maxamillion/add_fedora
Add entry for Fedora Linux vim-jedi package
2015-08-09 13:51:45 +02:00
Bohr Shaw dc9688602c Use shellescape with system call
This properly escapes the shell argument on Windows.

`cmd.exe` would strip off the first and last quote on a command.

Closes https://github.com/davidhalter/jedi-vim/pull/443/files.
2015-07-27 02:04:21 +02:00
Daniel Hahler ed4a8be12e Revert "Use " with the shell argument for system()"
This reverts commit 95b8dd77ba.
2015-07-27 02:04:02 +02:00
Daniel Hahler 924b4db962 Add myself to AUTHORS
According to my first contribution as of:

> commit b6bef9a
> Date:   Tue Mar 3 12:59:52 2015 +0100
2015-07-27 00:50:49 +02:00
Daisuke Suzuki 95b8dd77ba Use " with the shell argument for system()
This is required on Windows.

Closes https://github.com/davidhalter/jedi-vim/pull/441.
2015-07-27 00:49:40 +02:00
Adam Miller 2e0be9069a Add entry for Fedora Linux vim-jedi package 2015-07-23 17:20:25 -05:00
Dave Halter b3978bc4aa Merge pull request #431 from blueyed/fix-valueerror-cmdline-callsigs
Fix ValueError with cmdline call signatures
2015-07-01 03:09:27 +02:00
Daniel Hahler 91b4332774 Fix ValueError with cmdline call signatures
Commit 8016665 escaped the newlines in `text`, which requires to use the
escaped version with `text.index` and `len`, too.

This fixes the following error:

    Traceback (most recent call last):
      File "…/jedi/jedi_vim.py", line 110, in wrapper
        return func(*args, **kwargs)
      File "…/jedi/jedi_vim.py", line 414, in cmdline_call_signatures
        left = text.index(params[index])
    ValueError: substring not found
2015-06-26 17:07:23 +02:00
Dave Halter 133281a021 Merge pull request #430 from blueyed/no-use_tabs_not_buffers-by-default
Use use_tabs_not_buffers=0 by default
2015-06-26 14:09:04 +02:00
Daniel Hahler 439e50e9d1 Use use_tabs_not_buffers=0 by default
Ref: https://github.com/davidhalter/jedi-vim/issues/408#issuecomment-101997691
2015-06-21 22:06:24 +02:00
Daniel Hahler 56b2268df3 Merge pull request #422 from wilywampa/winwidth
Find first column using winwidth instead of wincmds/undojoin
2015-06-08 09:24:35 +02:00
Jacob Niehus a135f3b75b Find first column with winwidth instead of wincmds 2015-05-17 15:10:17 -07:00
Dave Halter bce599fc9c Merge pull request #417 from blueyed/fix-rename
Fix rename behaviour with empty cword; honor b:changedtick
2015-05-14 11:05:53 +02:00
Daniel Hahler 0dd1b9fd44 Fix PEP8 style 2015-05-12 22:08:39 +02:00
Daniel Hahler 6c1719a68a Fix rename behaviour with empty cword; honor b:changedtick
Ref: https://github.com/davidhalter/jedi-vim/issues/416
2015-05-12 22:08:30 +02:00
Daniel Hahler d79f41149f Fix wrong call of goto in do_rename
This was overseen in dd33e38.

This is the main fix for https://github.com/davidhalter/jedi-vim/issues/41.
2015-05-12 22:04:15 +02:00
Daniel Hahler 651eac91ff goto: fix return value to always be a list
Fixes https://github.com/davidhalter/jedi-vim/issues/414#issuecomment-101341260
2015-05-12 19:43:09 +02:00
Daniel Hahler abc0c07d0f echo_highlight: escape quotes in msg 2015-05-11 13:22:21 +02:00
Dave Halter 0747189516 Merge pull request #407 from blueyed/goto-auto
Better goto functionality
2015-05-10 20:02:38 +02:00
Daniel Hahler dd33e38631 Add auto-goto command/function
This adds g:jedi#goto_command, and uses `<Leader>d` by default for it -
the old default for `g:jedi#goto_definitions_command`, which is now
empty.

It will try `script.goto_definitions()` first, and falls back to
`script.goto_assignments()` for builtins.

Closes https://github.com/davidhalter/jedi-vim/pull/407
2015-05-10 18:07:42 +02:00
Daniel Hahler 9a13f143a8 rename: fix saving/restoring of the view
This seemed(?) to work with Python 3, but not for Python 2.  Just get a
string (instead of dict) from Vim, and re-use that as-is.

This fixes afb84a8.
2015-05-09 19:14:54 +02:00
Dave Halter 6025f59945 Dropping the dev branch. Changed the notes about using it. Fixes #406. 2015-05-04 15:36:27 +02:00
Daniel Hahler 1bf69c5844 Merge pull request #360 from wilywampa/escape_newline
Escape newlines in call signatures with show_call_signatures=2
2015-05-04 00:41:51 +02:00
Daniel Hahler 054285e2b7 rename: fix opening new windows with &shellslash (Windows)
Ref: https://github.com/davidhalter/jedi-vim/pull/364#issuecomment-98418501
2015-05-03 17:16:08 +02:00
Dave Halter fb77981040 Merge pull request #403 from blueyed/fix-rename
Fix rename
2015-05-03 15:48:37 +02:00
Daniel Hahler de410d9347 Merge pull request #402 from blueyed/add-max_doc_height
Add max_doc_height setting
2015-05-03 15:40:35 +02:00
Dave Halter 299c9b26d3 Merge pull request #401 from blueyed/reorder-jedi_vim
Reorder jedi_vim.py / improved error handling
2015-05-03 03:46:19 +02:00
Daniel Hahler 4d67c1a6e3 rename: refactor into do_rename, add rename_visual
This adds a visual mode map for renaming, which asks for the new name
via input().

`rename` itself could be changed to use `input()`, too - but I've left
it for now.
2015-05-02 18:51:10 +02:00
Daniel Hahler 154e2dbae3 rename: use original word's length for replacing
Ref: https://github.com/davidhalter/jedi-vim/pull/403#discussion_r29548013
2015-05-02 18:46:52 +02:00
Daniel Hahler b9ba141069 rename: display error in case new_buffer should fail and continue
Previously it would `return`, which would not restore the previous
state.  While I am not sure that it should continue, it should at least
not return.
2015-05-02 16:42:36 +02:00
Daniel Hahler bf281dabda rename: fix _tabnew to go to the correct window 2015-05-02 16:42:28 +02:00
Daniel Hahler afb84a837c rename: save and restore view before/after changes 2015-05-02 16:42:04 +02:00
Daniel Hahler 7539614f09 rename: display number of affected buffers 2015-05-02 16:41:13 +02:00
Daniel Hahler fc95545378 rename: save/restore tab/windows; not via new_buffer
Ref: https://github.com/davidhalter/jedi-vim/pull/364#discussion-diff-25785992
2015-05-02 16:38:47 +02:00
Daniel Hahler 676c558110 VimError: set self.message
`self.message` is used in `__str__`.

Without this, tracebacks end like this:

    Traceback (most recent call last):
    [...]
      File "…/vim/neobundles/jedi/jedi_vim.py", line 87, in _catch_
    exception
        raise VimError(result['exception'], result['throwpoint'], string)
    jedi_vim.VimError: <unprintable VimError object>
2015-05-02 11:51:27 +02:00
Daniel Hahler 65c06553fd Move max_doc_height default to s:default_settings 2015-05-02 10:41:31 +02:00
petobens 4095d0efef Add variable to control the height of the buffer showing documentation 2015-05-02 10:34:43 +02:00
Daniel Hahler 527562208c jedi_vim: reorder to use echo_highlight in try-import block
This uses `echo_highlight` for exceptions caused by an empty "jedi"
folder.
2015-05-02 00:44:45 +02:00
Daniel Hahler baa2969427 minor: use 'jedi-vim' in no_jedi_warning; fix typo 'too old' 2015-05-02 00:44:37 +02:00
Daniel Hahler dd4cb80911 Move jedi#_vim_exceptions before call to jedi#init_python
It might be used during setup, in the case of errors and needs to be
defined then already.
2015-05-02 00:44:33 +02:00
Daniel Hahler e5038cc9fa Merge branch 'master' into dev 2015-05-01 04:46:13 +02:00
Daniel Hahler 2f06d90f95 Fix jedi#complete_opened for completeopt with "longest"
jedi#complete_opened: move <C-p> for is_popup_on_dot below "longest"
handling.

Fixes #399.
2015-05-01 04:41:33 +02:00
Dave Halter 03805f87f5 Merge pull request #397 from blueyed/select-mode-mapping
Select mode mapping for completion trigger
2015-04-30 19:22:00 +02:00
Dave Halter c38b549a95 Merge pull request #398 from blueyed/auto-config-in-plugin
auto-config: set completeopt only if it's the default
2015-04-30 16:56:05 +02:00
Daniel Hahler 83d398bc5d auto-config: set completeopt only if it's the default
The setting is also moved from "ftplugin" to "plugin", which allows for
easier customization, e.g. via a FileType plugin.

Ref: https://github.com/davidhalter/jedi-vim/issues/374#issuecomment-97621368
2015-04-30 02:37:36 +02:00
Daniel Hahler 0f203c12b9 Add select-mode mapping for completion trigger
This deletes the selection (by going to visual mode, and "c"), and then
triggers the completion.

This is useful with e.g. UltiSnips, when you want to start completion
with an expanded snippet argument selected.

Ref: https://github.com/davidhalter/jedi-vim/pull/339#issuecomment-97612632
2015-04-30 01:53:01 +02:00
Daniel Hahler cfb76259f1 Mapping: remap of <C-Space>: use <buffer> and map to <C-Space>
Mapping it to <C-Space> should be enough, and makes it unnecessary to
map everything twice.
2015-04-30 01:50:23 +02:00
Dave Halter 78ac52a26e Merge remote-tracking branch 'origin/dev' 2015-04-29 23:41:37 +02:00
Dave Halter 3b26cf376b Merge pull request #396 from blueyed/fix-dot-completion-dev
Fix popup-on-dot completion: use <C-p> to deselect the first entry
2015-04-29 23:20:36 +02:00
Daniel Hahler d76c00eff4 jedi#init_python: add v:throwpoint to error message 2015-04-29 23:11:44 +02:00
Daniel Hahler 3c79979c50 Move functions used by jedi#init_python before it 2015-04-29 23:11:44 +02:00
Daniel Hahler 1837cdee1f Move Python init to top of autoloading; finish in case of error
This will not define jedi-vim's functions in case initialization failed.
2015-04-29 23:11:44 +02:00
Daniel Hahler e43012afc8 Refactor init method: add jedi#init_python
- jedi#init_python is used to init the Python environment.
 - jedi#setup_py_version is the single point where PythonJedi is
   defined, and will configure `PythonJedi` to output an error in case
   initialization failed.
 - jedi#force_py_version_switch will throw an error when
   g:jedi#force_py_version is not handled (e.g. invalid or "auto" and
   unresolved).
 - When g:jedi#force_py_version is provided, it will be used always.
 - Use WarningMsg highlight for errors, which are centralized and
   handled through exceptions.
2015-04-29 23:11:44 +02:00
Daniel Hahler 2d74fe6c51 Use PythonJedi instead of Python as command wrapper
`:Python` is more likely to interfere with other plugins / user
commands.
2015-04-29 23:11:44 +02:00
Daniel Hahler 9779628322 Refactor 'auto' handling 2015-04-29 23:11:44 +02:00
Daniel Hahler 3497a9644e jedi#force_py_version: catch errors
This prevents the script from aborting, in case e.g. `py3file` is not
defined, but should be forced.
2015-04-29 23:11:44 +02:00
Daniel Hahler 0cd664d8f7 Drop jedi#get_force_py_version again, handle 'auto' once 2015-04-29 23:11:44 +02:00
Daniel Hahler 7784c29a59 Optimize python check for Neovim: skip has() calls 2015-04-29 23:11:43 +02:00
Daniel Hahler 8f7f07fb58 Support for force_py_version = "auto"
This will call `python` to look up its major version number.
2015-04-29 23:11:43 +02:00
Daniel Hahler 63dc0badac Fix popup-on-dot completion: use <C-p> to deselect the first entry
Without this, the <C-x><C-o> triggered by jedi-vim would cause the first
match to be inserted (and selected).  When using completopt=longest,
this was less so an issue.
2015-04-29 23:09:18 +02:00
Dave Halter cc254432b6 Merge remote-tracking branch 'origin/dev' 2015-04-29 22:52:03 +02:00
Dave Halter ae8a2505bc Merge branch 'master' of github.com:davidhalter/jedi-vim 2015-04-29 22:40:10 +02:00
Dave Halter 839e1b5b85 We've had some issues in running the tests with vim-vspec > 1.4.1, so we're just defaulting to that. 2015-04-29 22:39:58 +02:00
Dave Halter 27df21c7bf Merge pull request #393 from blueyed/better-builtin-error
Use `desc_with_module` in "Builtin modules cannot be displayed" error
2015-04-29 15:41:13 +02:00
Dave Halter acdd711d84 Merge pull request #395 from blueyed/improve-tests
Improve tests: use pytest.fail
2015-04-29 15:40:40 +02:00
Dave Halter 9b11e70afe Merge pull request #394 from blueyed/no-echoerr
Use "echohl WarningMsg" instead of "echoerr" in no_jedi_warning
2015-04-29 15:39:09 +02:00
Daniel Hahler ab04982d63 pep8 fixes; sort imports 2015-04-29 11:52:36 +02:00
Daniel Hahler a0bb09e891 tests: use pytest.fail instead of assert False 2015-04-29 11:51:52 +02:00
Daniel Hahler 2611ea3c27 Use "echohl WarningMsg" instead of "echoerr" in no_jedi_warning
`echoerr` causes Vim to throw an error, but like the function name
indicates, this is only a warning.
2015-04-29 11:29:27 +02:00
Daniel Hahler fe517fae74 Use desc_with_module in "Builtin modules cannot be displayed" error 2015-04-29 10:57:40 +02:00
Dave Halter 401731c98b Merge branch 'dev' of github.com:davidhalter/jedi-vim 2015-04-28 19:43:14 +02:00
Dave Halter b78f1d74c5 Merge branch 'master' of github.com:davidhalter/jedi-vim 2015-04-28 19:42:31 +02:00
Dave Halter 2bfae0acfa Jedi 0.9.0 release. 2015-04-28 19:42:21 +02:00
Dave Halter b7bdb5a06e Merge pull request #383 from blueyed/qf-min-height
add_goto_window: pass len of list and use min()
2015-04-08 23:52:37 +02:00
Daniel Hahler a233d603e3 add_goto_window: pass len of list and use min()
With less than `g:jedi#quickfix_window_height` entries in quickfix list,
this now only makes the window that large, effectively saving screen
space.
2015-04-08 16:10:56 +02:00
Dave Halter 1005d1ad64 Merge pull request #382 from d7415/dev
Add Debian and Ubuntu packages to README.rst
2015-04-07 00:46:17 +02:00
Martin Stone c22e2bcdf5 Add linux packages to docs. 2015-04-02 15:33:27 +01:00
Dave Halter bf96f7d611 jedi#auto_vim_configuration might not have been set before loading plugin. Therefore check if it was set. 2015-04-02 16:16:17 +02:00
d7415 a120f428ff Add Debian and Ubuntu packages to README.rst 2015-04-02 12:18:35 +01:00
Dave Halter d3fadd54c7 Simplification. 2015-03-31 02:17:33 +02:00
Dave Halter d65c35a69d Problem with multi definitions tokenize tests. Jedi behaves different now, therefore I have disabled the tests. Once we find another example where it actually makes sense to test it, we can reenable the tests. 2015-03-31 00:54:58 +02:00
Dave Halter f714b58300 Update the submodule to the latest Jedi module. 2015-03-31 00:50:50 +02:00
Dave Halter e87e7db0e9 Trying to improve jedi-vim, when Jedi is not found. Fixes #263. 2015-03-30 19:11:05 +02:00
Dave Halter cc9837dc23 Trying to fix the issue of non-disappearing call signatures, #276, #278. 2015-03-28 03:00:58 +01:00
Dave Halter 43dcc4809f Test if this helps fixing the online tests that are not working. 2015-03-27 12:25:40 +01:00
Dave Halter 620b538f34 Make the test error output more readable. 2015-03-26 15:38:45 +01:00
Dave Halter 2ee17b3be6 Correct the signatures test again. 2015-03-26 15:21:58 +01:00
Dave Halter 69160c329a Matching fat symbols (current params) in a better way. 2015-03-26 15:06:25 +01:00
Dave Halter 3071700635 Match the new longer call_signature_escape symbol better. 2015-03-26 14:59:05 +01:00
Dave Halter 075cd9ce69 call signature escape characters moved from == to =`=, because that's something way less common. 2015-03-25 16:29:06 +01:00
Dave Halter 2ba5656606 Forgot to replace the call signature character in the tests. 2015-03-25 14:57:06 +01:00
Dave Halter d82df60392 Replace the call_signature_escape character with == (was a weird unicode character before), fixes #238. 2015-03-25 14:29:24 +01:00
Dave Halter c9c0198467 Settin nocompatible and filetype pluin n should be part of a jedi#auto_vim_configuration check. Fixes #373. 2015-03-25 14:05:01 +01:00
Dave Halter 6dcebb4644 Remove the zt call, as discussed in #310, fixed #310. 2015-03-25 13:35:54 +01:00
Dave Halter 28497ec3a9 Merge branch 'dont-overwrite-syntax-regions' of https://github.com/blueyed/jedi-vim 2015-03-24 17:23:42 +01:00
Dave Halter 78fc26456a Merge pull request #369 from pearofducks/documentation_toggle
Set 'hide documentation' to jedi#documentation_command
2015-03-07 18:39:58 +01:00
pearofducks 55929b2713 Set 'hide documentation' to the same mapping as jedi#documentation_command - instead of K 2015-03-07 15:08:07 +01:00
Daniel Hahler b6bef9a056 Do not overwrite/re-define pythonString syntax regions
Use `containedin` instead with `jediFunction`.
2015-03-03 13:43:16 +01:00
Dave Halter 59c98d61cf Merge pull request #363 from petobens/master
Add 'winwidth' split option
2015-02-18 13:12:52 +01:00
petobens 733ba775b0 Improve 'winwidth' split option documentation 2015-02-17 16:04:14 -03:00
petobens b71ef1176c Add 'winwidth' split option 2015-02-15 19:11:38 -03:00
Jacob Niehus 8016665639 Escape newlines in call signatures 2015-02-08 13:59:37 -07:00
Dave Halter bf4a8bfd5a Merge pull request #356 from hackstedt/master
wording
2015-02-07 02:36:26 +01:00
Sven 789d06b573 wording 2015-02-04 11:47:37 +01:00
Dave Halter 9eaede84b2 Merge pull request #347 from wilywampa/remove_clearsigs
Don't clear command line call signatures in completions()
2015-01-06 10:23:08 +01:00
Dave Halter 18b9f08336 Merge pull request #346 from wilywampa/callsigs_showmode
Document 'showmode' requirement for command line call signatures
2015-01-06 10:22:47 +01:00
Jacob Niehus e3f4474dd7 Add reason for clear_call_signatures logic 2015-01-05 19:02:51 -07:00
Jacob Niehus c5c69f0ee1 Don't clear command line call signatures in completions() 2015-01-04 20:55:52 -07:00
Jacob Niehus 74d51815a5 Document 'showmode' requirement for command line call signatures 2015-01-04 20:47:34 -07:00
Dave Halter 43d16b9966 Merge pull request #344 from louima/patch-1
Fix completion function name
2015-01-02 17:13:52 +01:00
Mathieu Louis 2bccea9b5d Fix completion function name 2015-01-02 12:15:06 +01:00
Dave Halter 05f2565dac Merge pull request #342 from wilywampa/master
Escape quotes in command line call signatures
2014-12-28 11:19:06 +01:00
Jacob Niehus 57e476c214 Escape quotes in command line call signatures 2014-12-27 22:14:50 -06:00
Dave Halter 48c9420136 Merge pull request #315 from wilywampa/master
Add option to show call signatures in command line
2014-12-19 14:14:59 +01:00
Dave Halter a3210ce7b6 Merge pull request #337 from jochenvdv/master
Correct documention for g:jedi#auto_close_doc
2014-12-19 00:59:50 +01:00
Jochen Van de Velde 409da304b4 Correct doc for g:jedi#auto_close_doc (fixes #331) 2014-12-18 22:25:16 +01:00
Jacob Niehus 8ce612e3a6 Describe call signature options in readme 2014-12-06 14:47:45 -07:00
Jacob Niehus f44ae4efe0 Fix autocmd error in Vim <7.3.867 2014-12-06 14:47:45 -07:00
Jacob Niehus 9ea98e2e81 Fix obscure undojoin bug 2014-12-06 14:47:45 -07:00
Jacob Niehus fb1eaa611e Add vspec tests for cmdline call signatures 2014-12-06 14:47:45 -07:00
Jacob Niehus e1a49790cb Remove manual width calculation and handle horizontal scroll 2014-12-06 14:47:45 -07:00
Jacob Niehus 048b9dc286 Fix autocmd outside of if statement 2014-12-06 14:47:45 -07:00
Jacob Niehus cfd71a6b54 Add option to show call signatures in command line 2014-12-06 14:47:45 -07:00
Dave Halter 0ce1af78b2 Merge pull request #336 from davidhalter/dev
Merge the dangling dev branch stuff back into master
2014-12-06 16:10:47 +01:00
Dave Halter 3a8560ac58 Merge pull request #332 from itchyny/global-function-names
replace function names starting with g: to CamelCase (fix #326)
2014-11-30 12:06:14 +01:00
itchyny 6cc1d8c34a replace function names starting with g: to CamelCase (fix #326) 2014-11-30 10:01:04 +09:00
Dave Halter 10cd4c6cfb Merge pull request #328 from itchyny/fix-global-variables
fix global variables (fix #324)
2014-11-25 00:51:27 +01:00
Dave Halter 2a6f35a91e Merge pull request #329 from itchyny/add-scriptencoding
add scriptencoding (fix #325)
2014-11-25 00:50:24 +01:00
itchyny d477ee6557 add scriptencoding (fix #325) 2014-11-25 08:32:26 +09:00
itchyny 4ec0edafd8 fix global variables (#fix 324) 2014-11-25 08:26:47 +09:00
Dave Halter 2192f41442 Merge pull request #327 from beaumartinez/patch-1
Use newer Vundle syntax
2014-11-18 13:53:37 +01:00
Beau 8fded9837e Use newer Vundle syntax
Vundle has deprecated the `Bundle` syntax, replacing it with `Plugin`.

I've also added the abbreviated GitHub syntax (simply `username/repo`,
no need to pass the full git URL).
2014-11-18 12:12:38 +00:00
Dave Halter 6fabdd2fab Merge pull request #319 from Alir3z4/master
Fix 404 link on jedi-vim for AUR packages
2014-10-31 19:47:07 +01:00
Alireza Savand 997220d3a5 Fix 404 link on jedi-vim for AUR packages
it has been moved to official repositories
2014-10-30 17:57:30 +04:00
Dave Halter 21efb8a0e8 Merge pull request #312 from genzj/issue-#311
Fix upstream #311
2014-10-14 13:28:56 +02:00
ZHU Jie M 1e0ae6bd35 Fix upstream #311
Use method `docstring()` instead of property `doc`
Use property `description` instead of `get_code`
2014-10-14 18:33:05 +08:00
Dave Halter b25db7ff5d Merge pull request #305 from MadAnd/patch-1
Fix typo
2014-09-07 13:27:10 +04:30
MadAnd a6f711fbbc Fix typo 2014-09-06 15:53:22 +03:00
Dave Halter 12e9235bfd Merge pull request #293 from matatk/dev
Documentation about the need for `+conceal`
2014-07-30 16:38:00 +04:30
Matthew Tylee Atkinson 43eaec0aee Documentation about the need for +conceal
* Make README link to the text file point to the file (not the repo)
* Replace the one 'Jedi-Vim' with 'jedi-vim' in README
* Minor grammar tweak to VIM >= 7.3 requirement in the docs
* Explain the need for `+conceal` in the docs
* Update last-changed date on first line of the docs
* Hint at the need for `+conceal` in the README
2014-07-29 23:16:50 +01:00
Dave Halter 089f9b0027 Merge pull request #273 from talha81/doc_window_reuse
Find __doc__ window if opened in current tab
2014-05-26 20:45:03 +04:30
Talha Ahmed 671b12da9a updated AUTHORS.txt 2014-05-20 23:42:12 +05:00
Talha Ahmed e620b5bf50 fixed mismatched parenthesis :| 2014-05-14 10:49:19 +05:00
Talha Ahmed 1792fb9e1b Find __doc__ window if opened in current tab 2014-05-14 09:47:18 +05:00
Dave Halter c32844dfec fix a few jedi-vim tests that have either broken due to the new jedi version or because they were wrong. 2014-05-05 12:17:38 +02:00
Dave Halter 4e9aa671a7 Python 3 compatibility 2014-05-05 11:56:41 +02:00
Dave Halter 61e1f46626 update jedi to jedi 0.8.0 2014-05-05 00:40:15 +02:00
Dave Halter f8e5b8dbec update Jedi to the latest dev branch 2014-04-23 12:11:43 +02:00
Dave Halter 503fe3da67 revert to old doc property, the doc.full() call was not backwards compatible and has since been reverted within Jedi 2014-04-23 12:08:58 +02:00
Dave Halter 0f591e1283 Use stackoverflow for general usage questions. 2014-04-16 11:16:06 +02:00
Dave Halter 21192f55f4 temporary compatibility with the doc changes in Jedi 0.8 2014-03-31 12:46:54 +02:00
Dave Halter aa1d83cf68 Merge remote-tracking branch 'origin/master' into dev 2014-03-31 12:46:14 +02:00
Dave Halter feb7688d07 Merge pull request #260 from haconeco/master
modified mapping to :call goto_window_on_enter()
2014-03-08 13:34:00 +04:30
haconeco 5e0bf55972 Update jedi.vim 2014-03-07 22:53:09 +09:00
Dave Halter c9bede82b6 Merge pull request #256 from justincheevers/patch-1
Add example installation command
2014-03-06 13:38:29 +04:30
justincheevers fa08586a94 Update README.rst 2014-03-01 13:21:02 -07:00
justincheevers bbe2861fa1 Add example installation command
It's easier if an example installation command is there for you.
2014-03-01 12:52:39 -07:00
Dave Halter bb5c473633 get rid of the compatibility layer of jedi 2014-01-15 12:20:26 +01:00
Dave Halter 4724e18b63 new version stuff 2014-01-15 12:17:51 +01:00
Dave Halter d9a43db019 remove unused jedi.keywords import that caused jedi-vim not to work because the file was moved internally in the Jedi package 2014-01-13 15:38:48 +01:00
Dave Halter ce7ba53224 pep8 styling 2014-01-13 15:37:49 +01:00
Dave Halter 154d9b8295 Merge pull request #243 from toupeira/master
Fix typo in jedi-vim.txt (closes #242)
2014-01-09 07:34:56 -08:00
Markus Koller 8f1e8f62fb Update AUTHORS.txt 2014-01-09 16:00:56 +01:00
Markus Koller ee46c28669 Fix typo in jedi-vim.txt (closes #242) 2014-01-09 11:18:25 +01:00
Dave Halter 38f966092e Merge pull request #240 from ShengYun/bugfix-wrong-sys-path-insert-with-space-paths
add expand to make paths which contains spaces work correctly
2014-01-02 11:35:34 -08:00
Sheng Yun 99a9445acb add expand to make paths which contains spaces work correctly 2014-01-02 14:26:48 +08:00
28 changed files with 2102 additions and 1044 deletions
+44
View File
@@ -0,0 +1,44 @@
### Issue
<!--
Please describe the issue here.
If you are not using jedi-vim from Git (but e.g. from a distribution's package,
please try it with jedi-vim's Git master, too).
-->
### Steps to reproduce
<!--
Include if relevant.
Please provide steps to reproduce it here, preferably based on a minimal Vim
configuration.
You can use the following template (save it as `minimal.vimrc` in the directory
where jedi-vim is installed, `cd` into that directory, and run Vim with
`vim -u minimal.vimrc`):
```
set nocompatible
let script_dir = fnamemodify(expand('<sfile>'), ':h')
let &runtimepath .= ','.script_dir.','.script_dir.'/after'
" Put your config changes here.
" let g:jedi#show_call_signatures=1
syntax on
filetype plugin indent on
```
Please provide the `minimal.vimrc` you have used here, too.
-->
### Output of “:verbose JediDebugInfo”
<!--
Please execute `:redir @+> | silent verb JediDebugInfo | redir END` in a
Python buffer to copy debug information into your clipboard.
Then paste it here.
-->
+4 -1
View File
@@ -1,3 +1,6 @@
[submodule "jedi"]
path = jedi
path = pythonx/jedi
url = https://github.com/davidhalter/jedi.git
[submodule "pythonx/parso"]
path = pythonx/parso
url = https://github.com/davidhalter/parso.git
+11 -2
View File
@@ -1,6 +1,15 @@
sudo: false
language: python
python: 3.6
env:
matrix:
- ENV=test
- ENV=check
install:
- pip install --quiet --use-mirrors pytest
- |
if [ "$ENV" = "test" ]; then
python3.6 -m pip install pytest
fi
script:
- vim --version
- py.test
- make "$ENV"
+11 -1
View File
@@ -40,6 +40,16 @@ Justin M. Keyes (@justinmk)
nagev (@np1)
Chris Lasher (@gotgenes) <chris.lasher@gmail.com>
Doan Thanh Nam (@tndoan)
Markus Koller (@toupeira)
Justin Cheevers @justincheevers
Talha Ahmed (@talha81) <talha.ahmed@gmail.com>
Matthew Tylee Atkinson (@matatk)
Pedro Ferrari (@petobens)
Daniel Hahler (@blueyed)
Dave Honneffer (@pearofducks)
Bagrat Aznauryan (@n9code)
Tomoyuki Kashiro (@kashiro)
Tommy Allen (@tweekmonster)
Mingliang (@Aulddays)
@something are github user names.
+6 -6
View File
@@ -1,12 +1,12 @@
Pull Requests are great (on the **dev** branch)!
# We <3 pull requests!
1. Fork the Repo on github.
2. Add yourself to AUTHORS.txt
3. Add a test if possible.
4. Push to your fork and submit a **pull request to the dev branch**.
4. Push to your fork and submit a pull request.
My **master** branch is a 100% stable (should be). I only push to it after I am
certain that things are working out. Many people are using Jedi directly from
the github master branch.
Please use PEP8 as a Python code style. For VIM, just try to style your
code similar to the jedi-vim code that is already there.
Please use Pep8 to style your code.
# Bug reports
Please include the output of `:version` and `:JediDebugInfo`.
+16
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
+98 -28
View File
@@ -2,11 +2,11 @@
jedi-vim - awesome Python autocompletion with VIM
#################################################
.. image:: https://travis-ci.org/davidhalter/jedi-vim.png?branch=master
.. image:: https://travis-ci.org/davidhalter/jedi-vim.svg?branch=master
:target: https://travis-ci.org/davidhalter/jedi-vim
:alt: Travis-CI build status
jedi-vim is a is a VIM binding to the autocompletion library
jedi-vim is a VIM binding to the autocompletion library
`Jedi <http://github.com/davidhalter/jedi>`_.
Here are some pictures:
@@ -32,9 +32,13 @@ Documentation
=============
Documentation is available in your vim: ``:help jedi-vim``. You can also look
it up `on github <http://github.com/davidhalter/jedi-vim>`_.
it up `on github <http://github.com/davidhalter/jedi-vim/blob/master/doc/jedi-vim.txt>`_.
You can read the Jedi library documentation `here <http://jedi.jedidjah.ch>`_.
You can read the Jedi library documentation `here <http://jedi.readthedocs.io/en/latest/>`_.
If you want to report issues, just use the github issue tracker. In case of
questions about the software, please use `stackoverflow
<https://stackoverflow.com/questions/tagged/jedi-vim>`_ and tag your question with ``jedi-vim``.
Contributing
@@ -64,25 +68,66 @@ Apart from that, jedi-vim supports the following commands
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
`vundle <https://github.com/gmarik/vundle>`_ to install jedi in VIM. Also you
need a VIM version that was compiled with ``+python``, which is typical for most
distributions on Linux.
`Vundle <https://github.com/gmarik/vundle>`_ to install jedi-vim.
The first thing you need after that is an up-to-date version of Jedi. You can
either get it via ``pip install jedi`` or with ``git submodule update --init``
in your jedi-vim repository.
either install it via ``pip install jedi`` or with
``git submodule update --init`` in your jedi-vim repository.
On Arch Linux, you can also install jedi-vim from AUR: `vim-jedi
<https://aur.archlinux.org/packages/vim-jedi/>`__.
Example installation command using Pathogen:
.. code-block:: sh
git clone --recursive https://github.com/davidhalter/jedi-vim.git ~/.vim/bundle/jedi-vim
Example installation using Vundle:
Add the following line in your `~/.vimrc`
.. code-block:: vim
Plugin 'davidhalter/jedi-vim'
Installation with your distribution
-----------------------------------
On Arch Linux, you can also install jedi-vim from official repositories as
`vim-jedi <https://www.archlinux.org/packages/community/any/vim-jedi/>`__.
It is also available on
`Debian (≥8) <https://packages.debian.org/vim-python-jedi>`__ and
`Ubuntu (≥14.04) <http://packages.ubuntu.com/vim-python-jedi>`__ as
vim-python-jedi.
On Fedora Linux, it is available as
`vim-jedi <https://apps.fedoraproject.org/packages/vim-jedi>`__.
Please note that this version might be quite old compared to using jedi-vim
from Git.
Caveats
-------
Note that the `python-mode <https://github.com/klen/python-mode>`_ VIM plugin seems
to conflict with jedi-vim, therefore you should disable it before enabling
jedi-vim.
To enjoy the full features of Jedi-Vim, you should have VIM >= 7.3. For older
version of VIM, the parameter recommendation list maybe not appeared when you type
open bracket after the function name.
To enjoy the full features of jedi-vim, you should have VIM >= 7.3, compiled with
``+conceal`` (which is not the case on some platforms, including OS X). If your VIM
does not meet these requirements, the parameter recommendation list may not appear
when you type an open bracket after a function name. Please read
`the documentation <http://github.com/davidhalter/jedi-vim/blob/master/doc/jedi-vim.txt>`_
for details.
Settings
@@ -96,19 +141,18 @@ you disable the auto-initialization in your ``.vimrc``:
let g:jedi#auto_initialization = 0
There are also some VIM options (like ``completeopt`` and key defaults) which
are automatically initialized, but you can change all of them:
are automatically initialized, but you can skip this:
.. code-block:: vim
let g:jedi#auto_vim_configuration = 0
If you are a person who likes to use VIM-buffers not tabs, you might want to
put that in your ``.vimrc``:
You can make jedi-vim use tabs when going to a definition etc:
.. code-block:: vim
let g:jedi#use_tabs_not_buffers = 0
let g:jedi#use_tabs_not_buffers = 1
If you are a person who likes to use VIM-splits, you might want to put this in your ``.vimrc``:
@@ -116,7 +160,7 @@ If you are a person who likes to use VIM-splits, you might want to put this in y
let g:jedi#use_splits_not_buffers = "left"
This options could be "left", "right", "top" or "bottom". It will decide the direction where the split open.
This options could be "left", "right", "top", "bottom" or "winwidth". It will decide the direction where the split open.
Jedi automatically starts the completion, if you type a dot, e.g. ``str.``, if
you don't want this:
@@ -132,18 +176,30 @@ and usually saves one keypress.
let g:jedi#popup_select_first = 0
Jedi displays function call signatures in insert mode in real-time, highlighting
the current argument. The call signatures can be displayed as a pop-up in the
buffer (set to 1, the default), which has the advantage of being easier to refer
to, or in Vim's command line aligned with the function call (set to 2), which
can improve the integrity of Vim's undo history.
.. code-block:: vim
let g:jedi#show_call_signatures = "1"
Here are a few more defaults for actions, read the docs (``:help jedi-vim``) to
get more information. If you set them to ``""``, they are not assigned.
.. code-block:: vim
NOTE: subject to change!
let g:jedi#goto_command = "<leader>d"
let g:jedi#goto_assignments_command = "<leader>g"
let g:jedi#goto_definitions_command = "<leader>d"
let g:jedi#goto_definitions_command = ""
let g:jedi#documentation_command = "K"
let g:jedi#usages_command = "<leader>n"
let g:jedi#completions_command = "<C-Space>"
let g:jedi#rename_command = "<leader>r"
let g:jedi#show_call_signatures = "1"
Finally, if you don't want completion, but all the other features, use:
@@ -173,16 +229,30 @@ Don't even think about changing the Jedi command to ``<Tab>``,
use `supertab <https://github.com/ervandew/supertab>`_!
The completion is waaay too slow!
---------------------------------
The completion is too slow!
---------------------------
Completion of complex libraries (like Numpy) should only be slow the first time
you complete it. After that, the results should be cached and very fast.
1. Completion of complex libraries (like Numpy) should only be slow the first
time you complete them. After that the results should be cached and very fast.
If it's still slow, in case you've installed the python-mode VIM plugin, disable
it. It seems to conflict with jedi-vim. See issue `#163
<https://github.com/davidhalter/jedi-vim/issues/163>`__.
2. If it is still slow after the initial completion and you have installed the
python-mode Vim plugin, try disabling its rope mode:
.. code-block:: vim
let g:pymode_rope = 0
See issue `#163 <https://github.com/davidhalter/jedi-vim/issues/163>`__.
3. You can also use `deoplete-jedi <https://github.com/zchee/deoplete-jedi>`__
for completions, which uses Jedi, but does completions asynchronously
(requires Neovim).
It makes sense to use both jedi-vim and deoplete-jedi, but you should disable
jedi-vim's completions then:
.. code-block:: vim
let g:jedi#completions_enabled = 0
Testing
=======
+2 -15
View File
@@ -1,16 +1,3 @@
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>
inoremap <expr> <Nul> jedi#complete_string(0)
endif
if g:jedi#completions_command != ""
execute "inoremap <expr> <buffer> ".g:jedi#completions_command." jedi#complete_string(0)"
endif
endif
if jedi#init_python() && g:jedi#auto_initialization && g:jedi#completions_enabled
call jedi#setup_completion()
endif
+17 -25
View File
@@ -1,15 +1,22 @@
if g:jedi#show_call_signatures == 1 && has('conceal')
" conceal is normal for vim >= 7.3
if !jedi#init_python()
finish
endif
let e = g:jedi#call_signature_escape
let l1 = e.'jedi=[^'.e.']*'.e.'[^'.e.']*'.e.'jedi'.e
let l2 = e.'jedi=\?[^'.e.']*'.e
exe 'syn match jediIgnore "'.l2.'" contained conceal'
if g:jedi#show_call_signatures > 0 && has('conceal')
" +conceal is the default for vim >= 7.3
let s:e = g:jedi#call_signature_escape
let s:full = s:e.'jedi=.\{-}'.s:e.'.\{-}'.s:e.'jedi'.s:e
let s:ignore = s:e.'jedi.\{-}'.s:e
exe 'syn match jediIgnore "'.s:ignore.'" contained conceal'
setlocal conceallevel=2
syn match jediFatSymbol "*" contained conceal
syn match jediFat "\*[^*]\+\*" contained contains=jediFatSymbol
syn match jediFatSymbol "\*_\*" contained conceal
syn match jediFat "\*_\*.\{-}\*_\*" contained contains=jediFatSymbol
syn match jediSpace "\v[ ]+( )@=" contained
exe 'syn match jediFunction "'.l1.'" keepend extend contains=jediIgnore,jediFat,jediSpace'
exe 'syn match jediFunction "'.s:full.'" keepend extend '
\ .' contains=jediIgnore,jediFat,jediSpace'
\ .' containedin=pythonComment,pythonString,pythonRawString'
unlet! s:e s:full s:ignore
hi def link jediIgnore Ignore
hi def link jediFatSymbol Ignore
@@ -21,20 +28,5 @@ if g:jedi#show_call_signatures == 1 && has('conceal')
else
hi jediFunction term=NONE cterm=NONE ctermfg=6 guifg=Black gui=NONE ctermbg=0 guibg=Grey
hi jediFat term=bold,underline cterm=bold,underline gui=bold,underline ctermbg=0 guibg=#555555
end
" override defaults (add jediFunction to contains)
syn match pythonComment "#.*$" contains=pythonTodo,@Spell,jediFunction
syn region pythonString
\ start=+[uU]\=\z(['"]\)+ end="\z1" skip="\\\\\|\\\z1"
\ contains=pythonEscape,@Spell,jediFunction
syn region pythonString
\ start=+[uU]\=\z('''\|"""\)+ end="\z1" keepend
\ contains=pythonEscape,pythonSpaceError,pythonDoctest,@Spell,jediFunction
syn region pythonRawString
\ start=+[uU]\=[rR]\z(['"]\)+ end="\z1" skip="\\\\\|\\\z1"
\ contains=@Spell,jediFunction
syn region pythonRawString
\ start=+[uU]\=[rR]\z('''\|"""\)+ end="\z1" keepend
\ contains=pythonSpaceError,pythonDoctest,@Spell,jediFunction
endif
endif
+4
View File
@@ -0,0 +1,4 @@
function! health#jedi#check() abort
call health#report_start('jedi')
silent call jedi#debug_info()
endfunction
+575 -235
View File
@@ -1,159 +1,277 @@
scriptencoding utf-8
" ------------------------------------------------------------------------
" functions that call python code
" Settings initialization
" ------------------------------------------------------------------------
function! jedi#goto_assignments()
Python jedi_vim.goto()
endfunction
let s:deprecations = {
\ 'get_definition_command': 'goto_definitions_command',
\ 'pydoc': 'documentation_command',
\ 'related_names_command': 'usages_command',
\ 'autocompletion_command': 'completions_command',
\ 'show_function_definition': 'show_call_signatures',
\ }
function! jedi#goto_definitions()
Python jedi_vim.goto(is_definition=True)
endfunction
let s:default_settings = {
\ 'use_tabs_not_buffers': 0,
\ 'use_splits_not_buffers': 1,
\ 'auto_initialization': 1,
\ 'auto_vim_configuration': 1,
\ 'goto_command': "'<leader>d'",
\ 'goto_assignments_command': "'<leader>g'",
\ 'goto_definitions_command': "''",
\ 'completions_command': "'<C-Space>'",
\ 'call_signatures_command': "'<leader>n'",
\ 'usages_command': "'<leader>n'",
\ 'rename_command': "'<leader>r'",
\ 'completions_enabled': 1,
\ 'popup_on_dot': 'g:jedi#completions_enabled',
\ 'documentation_command': "'K'",
\ 'show_call_signatures': 1,
\ 'show_call_signatures_delay': 500,
\ 'call_signature_escape': "'?!?'",
\ 'auto_close_doc': 1,
\ 'max_doc_height': 30,
\ 'popup_select_first': 1,
\ 'quickfix_window_height': 10,
\ 'force_py_version': "'auto'",
\ 'smart_auto_mappings': 1,
\ 'use_tag_stack': 1
\ }
function! jedi#usages()
Python jedi_vim.goto(is_related_name=True)
endfunction
for [s:key, s:val] in items(s:deprecations)
if exists('g:jedi#'.s:key)
echom "'g:jedi#".s:key."' is deprecated. Please use 'g:jedi#".s:val."' instead. Sorry for the inconvenience."
exe 'let g:jedi#'.s:val.' = g:jedi#'.s:key
endif
endfor
function! jedi#rename(...)
Python jedi_vim.rename()
endfunction
function! jedi#completions(findstart, base)
Python jedi_vim.completions()
endfunction
function! jedi#enable_speed_debugging()
Python jedi_vim.jedi.set_debug_function(jedi_vim.print_to_stdout, speed=True, warnings=False, notices=False)
endfunction
function! jedi#enable_debugging()
Python jedi_vim.jedi.set_debug_function(jedi_vim.print_to_stdout)
endfunction
function! jedi#disable_debugging()
Python jedi_vim.jedi.set_debug_function(None)
endfunction
function! jedi#py_import(args)
Python jedi_vim.py_import()
endfun
function! jedi#py_import_completions(argl, cmdl, pos)
Python jedi_vim.py_import_completions()
endfun
for [s:key, s:val] in items(s:default_settings)
if !exists('g:jedi#'.s:key)
exe 'let g:jedi#'.s:key.' = '.s:val
endif
endfor
" ------------------------------------------------------------------------
" show_documentation
" Python initialization
" ------------------------------------------------------------------------
function! jedi#show_documentation()
Python jedi_vim.show_documentation()
let s:script_path = fnameescape(expand('<sfile>:p:h:h'))
if bufnr("__doc__") > 0
" If the __doc__ buffer is open in the current window, jump to it
silent execute "sbuffer ".bufnr("__doc__")
function! s:init_python() abort
if g:jedi#force_py_version !=# 'auto'
" Always use the user supplied version.
try
return jedi#setup_py_version(g:jedi#force_py_version)
catch
throw 'Could not setup g:jedi#force_py_version: '.v:exception
endtry
endif
" Handle "auto" version.
if has('nvim') || (has('python') && has('python3'))
" Neovim usually has both python providers. Skipping the `has` check
" avoids starting both of them.
" Get default python version from interpreter in $PATH.
let s:def_py = system('python -c '.shellescape('import sys; sys.stdout.write(str(sys.version_info[0]))'))
if v:shell_error != 0 || !len(s:def_py)
if !exists('g:jedi#squelch_py_warning')
echohl WarningMsg
echom 'Warning: jedi-vim failed to get Python version from sys.version_info: ' . s:def_py
echom 'Falling back to version 2.'
echohl None
endif
let s:def_py = 2
elseif &verbose
echom 'jedi-vim: auto-detected Python: '.s:def_py
endif
" Make sure that the auto-detected version is available in Vim.
if !has('nvim') || has('python'.(s:def_py == 2 ? '' : s:def_py))
return jedi#setup_py_version(s:def_py)
endif
" Add a warning in case the auto-detected version is not available,
" usually because of a missing neovim module in a VIRTUAL_ENV.
if has('nvim')
echohl WarningMsg
echom 'jedi-vim: the detected Python version ('.s:def_py.')'
\ 'is not functional.'
\ 'Is the "neovim" module installed?'
\ 'While jedi-vim will work, it might not use the'
\ 'expected Python path.'
echohl None
endif
endif
if has('python')
call jedi#setup_py_version(2)
elseif has('python3')
call jedi#setup_py_version(3)
else
split '__doc__'
throw 'jedi-vim requires Vim with support for Python 2 or 3.'
endif
setlocal modifiable
setlocal noswapfile
setlocal buftype=nofile
silent normal! ggdG
silent $put=l:doc
silent normal! 1Gdd
setlocal nomodifiable
setlocal nomodified
setlocal filetype=rst
if l:doc_lines > 30 " max lines for plugin
let l:doc_lines = 30
endif
execute "resize ".l:doc_lines
" quit comands
nnoremap <buffer> q ZQ
nnoremap <buffer> K 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
" ------------------------------------------------------------------------
" helper functions
" ------------------------------------------------------------------------
function! jedi#add_goto_window()
set lazyredraw
cclose
execute 'belowright copen '.g:jedi#quickfix_window_height
set nolazyredraw
if g:jedi#use_tabs_not_buffers == 1
map <buffer> <CR> :call jedi#goto_window_on_enter()<CR>
endif
au WinLeave <buffer> q " automatically leave, if an option is chosen
redraw!
return 1
endfunction
function! jedi#goto_window_on_enter()
let l:list = getqflist()
let l:data = l:list[line('.') - 1]
if l:data.bufnr
" close goto_window buffer
normal ZQ
Python jedi_vim.new_buffer(vim.eval('bufname(l:data.bufnr)'))
call cursor(l:data.lnum, l:data.col)
function! jedi#reinit_python() abort
unlet! s:_init_python
call jedi#init_python()
endfunction
let s:_init_python = -1
function! jedi#init_python() abort
if s:_init_python == -1
try
let s:_init_python = s:init_python()
catch
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
endif
return s:_init_python
endfunction
let s:python_version = 'null'
function! jedi#setup_py_version(py_version) abort
if a:py_version == 2
let cmd_exec = 'python'
let s:python_version = 2
elseif a:py_version == 3
let cmd_exec = 'python3'
let s:python_version = 3
else
echohl WarningMsg | echo "Builtin module cannot be opened." | echohl None
throw 'jedi#setup_py_version: invalid py_version: '.a:py_version
endif
endfunction
execute 'command! -nargs=1 PythonJedi '.cmd_exec.' <args>'
function! s:syn_stack()
if !exists("*synstack")
return []
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
exe 'PythonJedi exec('''.escape(join(init_lines, '\n'), "'").''')'
catch
throw printf('jedi#setup_py_version: failed to run Python for initialization: %s.', v:exception)
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 map(synstack(line('.'), col('.') - 1), 'synIDattr(v:val, "name")')
endfunc
function! jedi#do_popup_on_dot_in_highlight()
let highlight_groups = s:syn_stack()
for a in highlight_groups
if a == 'pythonDoctest'
return 1
endif
endfor
for a in highlight_groups
for b in ['pythonString', 'pythonComment', 'pythonNumber']
if a == b
return 0
endif
endfor
endfor
return 1
endfunc
function! jedi#popup_on_dot_string()
endfunction
function! jedi#configure_call_signatures()
autocmd InsertLeave <buffer> Python jedi_vim.clear_call_signatures()
autocmd CursorMovedI <buffer> Python jedi_vim.show_call_signatures()
function! jedi#debug_info() abort
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
function! jedi#force_py_version(py_version) abort
let g:jedi#force_py_version = a:py_version
return jedi#setup_py_version(a:py_version)
endfunction
function! jedi#force_py_version_switch() abort
if g:jedi#force_py_version == 2
call jedi#force_py_version(3)
elseif g:jedi#force_py_version == 3
call jedi#force_py_version(2)
else
throw "Don't know how to switch from ".g:jedi#force_py_version.'!'
endif
endfunction
" Helper function instead of `python vim.eval()`, and `.command()` because
" these also return error definitions.
function! jedi#_vim_exceptions(str, is_eval)
function! jedi#_vim_exceptions(str, is_eval) abort
let l:result = {}
try
if a:is_eval
@@ -169,130 +287,352 @@ function! jedi#_vim_exceptions(str, is_eval)
return l:result
endfunction
call jedi#init_python() " Might throw an error.
function! jedi#complete_string(is_popup_on_dot)
" ------------------------------------------------------------------------
" functions that call python code
" ------------------------------------------------------------------------
function! jedi#goto() abort
PythonJedi jedi_vim.goto(mode="goto")
endfunction
if a:is_popup_on_dot && !(g:jedi#popup_on_dot && jedi#do_popup_on_dot_in_highlight())
return ''
function! jedi#goto_assignments() abort
PythonJedi jedi_vim.goto(mode="assignment")
endfunction
end
if pumvisible() && !a:is_popup_on_dot
return "\<C-n>"
function! jedi#goto_definitions() abort
PythonJedi jedi_vim.goto(mode="definition")
endfunction
function! jedi#usages() abort
PythonJedi jedi_vim.goto(mode="related_name")
endfunction
function! jedi#rename(...) abort
PythonJedi jedi_vim.rename()
endfunction
function! jedi#rename_visual(...) abort
PythonJedi jedi_vim.rename_visual()
endfunction
function! jedi#completions(findstart, base) abort
PythonJedi jedi_vim.completions()
endfunction
function! jedi#enable_speed_debugging() abort
PythonJedi jedi_vim.jedi.set_debug_function(jedi_vim.print_to_stdout, speed=True, warnings=False, notices=False)
endfunction
function! jedi#enable_debugging() abort
PythonJedi jedi_vim.jedi.set_debug_function(jedi_vim.print_to_stdout)
endfunction
function! jedi#disable_debugging() abort
PythonJedi jedi_vim.jedi.set_debug_function(None)
endfunction
function! jedi#py_import(args) abort
PythonJedi jedi_vim.py_import()
endfun
function! jedi#py_import_completions(argl, cmdl, pos) abort
PythonJedi jedi_vim.py_import_completions()
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
" ------------------------------------------------------------------------
function! jedi#show_documentation() abort
PythonJedi if jedi_vim.show_documentation() is None: vim.command('return')
let bn = bufnr('__doc__')
if bn > 0
let wi=index(tabpagebuflist(tabpagenr()), bn)
if wi >= 0
" If the __doc__ buffer is open in the current tab, jump to it
silent execute (wi+1).'wincmd w'
else
return "\<C-x>\<C-o>\<C-r>=jedi#complete_opened()\<CR>"
end
silent execute 'sbuffer '.bn
endif
else
split __doc__
endif
setlocal modifiable
setlocal noswapfile
setlocal buftype=nofile
silent normal! ggdG
silent $put=l:doc
silent normal! 1Gdd
setlocal nomodifiable
setlocal nomodified
setlocal filetype=rst
setlocal foldlevel=200 " do not fold in __doc__
if l:doc_lines > g:jedi#max_doc_height " max lines for plugin
let l:doc_lines = g:jedi#max_doc_height
endif
execute 'resize '.l:doc_lines
" quit comands
nnoremap <buffer> q ZQ
execute 'nnoremap <buffer> '.g:jedi#documentation_command.' ZQ'
endfunction
" ------------------------------------------------------------------------
" helper functions
" ------------------------------------------------------------------------
function! jedi#add_goto_window(len) abort
set lazyredraw
cclose
let height = min([a:len, g:jedi#quickfix_window_height])
execute 'belowright copen '.height
set nolazyredraw
if g:jedi#use_tabs_not_buffers == 1
noremap <buffer> <CR> :call jedi#goto_window_on_enter()<CR>
endif
augroup jedi_goto_window
au!
au WinLeave <buffer> q " automatically leave, if an option is chosen
augroup END
redraw!
endfunction
function! jedi#complete_opened()
if pumvisible() && g:jedi#popup_select_first && stridx(&completeopt, 'longest') > -1
" only go down if it is visible, user-enabled and the longest option is set
function! jedi#goto_window_on_enter() abort
let l:list = getqflist()
let l:data = l:list[line('.') - 1]
if l:data.bufnr
" close goto_window buffer
normal! ZQ
PythonJedi jedi_vim.new_buffer(vim.eval('bufname(l:data.bufnr)'))
call cursor(l:data.lnum, l:data.col)
else
echohl WarningMsg | echo 'Builtin module cannot be opened.' | echohl None
endif
endfunction
function! s:syn_stack() abort
if !exists('*synstack')
return []
endif
return map(synstack(line('.'), col('.') - 1), "synIDattr(v:val, 'name')")
endfunc
function! jedi#do_popup_on_dot_in_highlight() abort
let highlight_groups = s:syn_stack()
for a in highlight_groups
if a ==# 'pythonDoctest'
return 1
endif
endfor
for a in highlight_groups
for b in ['pythonString', 'pythonComment', 'pythonNumber']
if a == b
return 0
endif
endfor
endfor
return 1
endfunc
let s:show_call_signatures_last = [0, 0, '']
function! jedi#show_call_signatures() abort
if s:_init_python == 0
return 1
endif
let [line, col] = [line('.'), col('.')]
let curline = getline(line)
let reload_signatures = 1
" Caching. On the same line only.
if line == s:show_call_signatures_last[0]
" Check if the number of commas and parenthesis before or after the
" cursor has not changed since the last call, which means that the
" argument position was not changed and we can skip repainting.
let prevcol = s:show_call_signatures_last[1]
let prevline = s:show_call_signatures_last[2]
if substitute(curline[:col-2], '[^,()]', '', 'g')
\ == substitute(prevline[:prevcol-2], '[^,()]', '', 'g')
\ && substitute(curline[(col-2):], '[^,()]', '', 'g')
\ == substitute(prevline[(prevcol-2):], '[^,()]', '', 'g')
let reload_signatures = 0
endif
endif
let s:show_call_signatures_last = [line, col, curline]
if reload_signatures
PythonJedi jedi_vim.show_call_signatures()
endif
endfunction
function! jedi#clear_call_signatures() abort
if s:_init_python == 0
return 1
endif
let s:show_call_signatures_last = [0, 0, '']
PythonJedi jedi_vim.clear_call_signatures()
endfunction
function! jedi#configure_call_signatures() abort
augroup jedi_call_signatures
autocmd! * <buffer>
if g:jedi#show_call_signatures == 2 " Command line call signatures
autocmd InsertEnter <buffer> let g:jedi#first_col = s:save_first_col()
endif
autocmd InsertEnter <buffer> let s:show_call_signatures_last = [0, 0, '']
autocmd InsertLeave <buffer> call jedi#clear_call_signatures()
if g:jedi#show_call_signatures_delay > 0
autocmd InsertEnter <buffer> let b:_jedi_orig_updatetime = &updatetime
\ | let &updatetime = g:jedi#show_call_signatures_delay
autocmd InsertLeave <buffer> if exists('b:_jedi_orig_updatetime')
\ | let &updatetime = b:_jedi_orig_updatetime
\ | unlet b:_jedi_orig_updatetime
\ | endif
autocmd CursorHoldI <buffer> call jedi#show_call_signatures()
else
autocmd CursorMovedI <buffer> call jedi#show_call_signatures()
endif
augroup END
endfunction
" Determine where the current window is on the screen for displaying call
" signatures in the correct column.
function! s:save_first_col() abort
if bufname('%') ==# '[Command Line]' || winnr('$') == 1
return 0
endif
let startwin = winnr()
let winwidth = winwidth(0)
if winwidth == &columns
return 0
elseif winnr('$') == 2
return startwin == 1 ? 0 : (winwidth(1) + 1)
elseif winnr('$') == 3
if startwin == 1
return 0
endif
let ww1 = winwidth(1)
let ww2 = winwidth(2)
let ww3 = winwidth(3)
if ww1 + ww2 + ww3 + 2 == &columns
if startwin == 2
return ww1 + 1
else
return ww1 + ww2 + 2
endif
elseif startwin == 2
if ww2 + ww3 + 1 == &columns
return 0
else
return ww1 + 1
endif
else " startwin == 3
if ww2 + ww3 + 1 == &columns
return ww2 + 1
else
return ww1 + 1
endif
endif
endif
return 0
endfunction
function! jedi#complete_string(autocomplete) abort
if a:autocomplete
if !(g:jedi#popup_on_dot && jedi#do_popup_on_dot_in_highlight())
return ''
endif
let s:saved_completeopt = &completeopt
set completeopt-=longest
set completeopt+=menuone
set completeopt-=menu
if &completeopt !~# 'noinsert\|noselect'
" Patch 775 introduced noinsert and noselect, previously these
" options didn't exist. Setting them in earlier versions results in
" errors (E474).
if has('patch-7.4-775')
if g:jedi#popup_select_first
set completeopt+=noinsert
else
set completeopt+=noselect
endif
else
" To pass the tests we use this, it seems to get the closest to
" the other options. I'm really not sure if this properly
" works, but VIM 7.4-775 is already pretty old, so it might not
" be a problem anymore in a few years.
set completeopt+=longest
endif
endif
elseif pumvisible()
return "\<C-n>"
endif
return "\<C-x>\<C-o>\<C-r>=jedi#complete_opened(".a:autocomplete.")\<CR>"
endfunction
function! jedi#complete_opened(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>"
end
return ""
endif
return ''
endfunction
function! jedi#force_py_version(py_version)
let g:jedi#force_py_version = a:py_version
if g:jedi#force_py_version == 2
command! -nargs=1 Python python <args>
execute 'pyfile '.s:script_path.'/initialize.py'
elseif g:jedi#force_py_version == 3
command! -nargs=1 Python python3 <args>
execute 'py3file '.s:script_path.'/initialize.py'
function! jedi#smart_auto_mappings() abort
" Auto put import statement after from module.name<space> and complete
if search('\m^\s*from\s\+[A-Za-z0-9._]\{1,50}\%#\s*$', 'bcn', line('.'))
" Enter character and start completion.
return "\<space>import \<C-r>=jedi#complete_string(1)\<CR>"
endif
return "\<space>"
endfunction
function! jedi#force_py_version_switch()
if g:jedi#force_py_version == 2
call jedi#force_py_version(3)
elseif g:jedi#force_py_version == 3
call jedi#force_py_version(2)
function! jedi#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
" ------------------------------------------------------------------------
" deprecations
" ------------------------------------------------------------------------
let s:deprecations = {
\ 'get_definition_command': 'goto_definitions_command',
\ 'goto_command': 'goto_assignments_command',
\ 'pydoc': 'documentation_command',
\ 'related_names_command': 'usages_command',
\ 'autocompletion_command': 'completions_command',
\ 'show_function_definition': 'show_call_signatures',
\ }
" ------------------------------------------------------------------------
" defaults for jedi-vim
" ------------------------------------------------------------------------
let s:settings = {
\ 'use_tabs_not_buffers': 1,
\ 'use_splits_not_buffers': 1,
\ 'auto_initialization': 1,
\ 'auto_vim_configuration': 1,
\ 'goto_assignments_command': "'<leader>g'",
\ 'completions_command': "'<C-Space>'",
\ 'goto_definitions_command': "'<leader>d'",
\ 'call_signatures_command': "'<leader>n'",
\ 'usages_command': "'<leader>n'",
\ 'rename_command': "'<leader>r'",
\ 'popup_on_dot': 1,
\ 'documentation_command': "'K'",
\ 'show_call_signatures': 1,
\ 'call_signature_escape': "'≡'",
\ 'auto_close_doc': 1,
\ 'popup_select_first': 1,
\ 'quickfix_window_height': 10,
\ 'completions_enabled': 1,
\ 'force_py_version': 2
\ }
function! s:init()
for [key, val] in items(s:deprecations)
if exists('g:jedi#'.key)
echom "'g:jedi#".key."' is deprecated. Please use 'g:jedi#".val."' instead. Sorry for the inconvenience."
exe 'let g:jedi#'.val.' = g:jedi#'.key
end
endfor
for [key, val] in items(s:settings)
if !exists('g:jedi#'.key)
exe 'let g:jedi#'.key.' = '.val
endif
endfor
endfunction
call s:init()
" ------------------------------------------------------------------------
" Python initialization
" ------------------------------------------------------------------------
let s:script_path = fnameescape(expand('<sfile>:p:h:h'))
if has('python') && has('python3')
call jedi#force_py_version(g:jedi#force_py_version)
elseif has('python')
command! -nargs=1 Python python <args>
execute 'pyfile '.s:script_path.'/initialize.py'
elseif has('python3')
command! -nargs=1 Python python3 <args>
execute 'py3file '.s:script_path.'/initialize.py'
else
if !exists("g:jedi#squelch_py_warning")
echomsg "Error: jedi-vim requires vim compiled with +python"
endif
finish
end
"Python jedi_vim.jedi.set_debug_function(jedi_vim.print_to_stdout, speed=True, warnings=False, notices=False)
"Python jedi_vim.jedi.set_debug_function(jedi_vim.print_to_stdout)
"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)
" vim: set et ts=4:
+31 -13
View File
@@ -1,10 +1,13 @@
import os
import urllib
import zipfile
import subprocess
import urllib.request
import zipfile
import pytest
VSPEC_URL = 'https://github.com/kana/vim-vspec/archive/1.4.1.zip'
CACHE_FOLDER = '.cache'
VSPEC_FOLDER = os.path.join(CACHE_FOLDER, 'vim-vspec-master')
VSPEC_FOLDER = os.path.join(CACHE_FOLDER, 'vim-vspec-1.4.1')
VSPEC_RUNNER = os.path.join(VSPEC_FOLDER, 'bin/vspec')
TEST_DIR = 'test'
@@ -14,11 +17,26 @@ class IntegrationTestFile(object):
self.path = path
def run(self):
output = subprocess.check_output([VSPEC_RUNNER, '.', VSPEC_FOLDER, self.path])
output = subprocess.check_output(
[VSPEC_RUNNER, '.', VSPEC_FOLDER, self.path])
had_ok = False
for line in output.splitlines():
if line.startswith('not ok') or line.startswith('Error'):
print(output)
assert False
if (line.startswith(b'not ok') or
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)
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):
return "<%s: %s>" % (type(self), self.path)
@@ -29,8 +47,7 @@ def pytest_configure(config):
os.mkdir(CACHE_FOLDER)
if not os.path.exists(VSPEC_FOLDER):
url = 'https://github.com/kana/vim-vspec/archive/master.zip'
name, hdrs = urllib.urlretrieve(url)
name, hdrs = urllib.request.urlretrieve(VSPEC_URL)
z = zipfile.ZipFile(name)
for n in z.namelist():
dest = os.path.join(CACHE_FOLDER, n)
@@ -39,10 +56,10 @@ def pytest_configure(config):
os.makedirs(destdir)
data = z.read(n)
if not os.path.isdir(dest):
with open(dest, 'w') as f:
with open(dest, 'wb') as f:
f.write(data)
z.close()
os.chmod(VSPEC_RUNNER, 0777)
os.chmod(VSPEC_RUNNER, 0o777)
def pytest_generate_tests(metafunc):
@@ -51,7 +68,8 @@ def pytest_generate_tests(metafunc):
"""
def collect_tests():
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))
metafunc.parametrize('case', list(collect_tests()))
tests = list(collect_tests())
metafunc.parametrize('case', tests, ids=[test.name for test in tests])
+139 -54
View File
@@ -1,4 +1,4 @@
*jedi-vim.txt* - For Vim version 7.3 - Last change: 2013/3/1
*jedi-vim.txt* - For Vim version 7.3 - Last change: 2014/07/29
__ _______ _______ __ ____ ____ __ .___ ___.~
| | | ____|| \ | | \ \ / / | | | \/ |~
| | | |__ | .--. || | _____\ \/ / | | | \ / |~
@@ -17,16 +17,18 @@ Contents *jedi-vim-contents*
2.1. Manually |jedi-vim-installation-manually|
2.2. Using Pathogen |jedi-vim-installation-pathogen|
2.3. Using Vundle |jedi-vim-installation-vundle|
2.4. Installing from Repositories |jedi-vim-installation-repos|
3. Supported Python features |jedi-vim-support|
4. Usage |jedi-vim-usage|
5. Mappings |jedi-vim-keybindings|
5.1. Start completion |g:jedi#completions_command|
5.2. Go to assignment |g:jedi#goto_assignments_command|
5.3. Get original definition |g:jedi#goto_definitions_command|
5.4. Show documentation |g:jedi#documentation_command|
5.5. Rename variables |g:jedi#rename_command|
5.6. Show name usages |g:jedi#usages_command|
5.7. Open module by name |:Pyimport|
5.2. Go to definition |g:jedi#goto_command|
5.3. Go to assignment |g:jedi#goto_assignments_command|
5.4 Go to definition (deprecated) |g:jedi#goto_definitions_command|
5.5. Show documentation |g:jedi#documentation_command|
5.6. Rename variables |g:jedi#rename_command|
5.7. Show name usages |g:jedi#usages_command|
5.8. Open module by name |:Pyimport|
6. Configuration |jedi-vim-configuration|
6.1. auto_initialization |g:jedi#auto_initialization|
6.2. auto_vim_configuration |g:jedi#auto_vim_configuration|
@@ -34,11 +36,14 @@ Contents *jedi-vim-contents*
6.4. popup_select_first |g:jedi#popup_select_first|
6.5. auto_close_doc |g:jedi#auto_close_doc|
6.6. show_call_signatures |g:jedi#show_call_signatures|
6.7. use_tabs_not_buffers |g:jedi#use_tabs_not_buffers|
6.8. squelch_py_warning |g:jedi#squelch_py_warning|
6.9. completions_enable |g:jedi#completions_enable|
6.10. use_splits_not_buffers |g:jedi#use_splits_not_buffers|
6.11. force_py_version |g:jedi#force_py_version|
6.7. show_call_signatures_delay |g:jedi#show_call_signatures_delay|
6.8. use_tabs_not_buffers |g:jedi#use_tabs_not_buffers|
6.9. squelch_py_warning |g:jedi#squelch_py_warning|
6.10. completions_enabled |g:jedi#completions_enabled|
6.11. use_splits_not_buffers |g:jedi#use_splits_not_buffers|
6.12. force_py_version |g:jedi#force_py_version|
6.13. smart_auto_mappings |g:jedi#smart_auto_mappings|
6.14. use_tag_stack |g:jedi#use_tag_stack|
7. Testing |jedi-vim-testing|
8. Contributing |jedi-vim-contributing|
9. License |jedi-vim-license|
@@ -46,7 +51,7 @@ Contents *jedi-vim-contents*
==============================================================================
1. Introduction *jedi-vim-introduction*
Jedi-vim is a is a Vim binding to the awesome Python autocompletion library
Jedi-vim is a Vim binding to the awesome Python autocompletion library
`jedi`. Among jedi's (and, therefore, jedi-vim's) features are:
- Completion for a wide array of Python features (see |jedi-vim-support|)
@@ -82,9 +87,22 @@ using pip: >
However, you can also install it as a git submodule if you don't want to use
jedi for anything but this plugin. How to do this is detailed below.
It is the best if you have VIM >= 7.3. For the older version, you probably
cannot see the parameter recommendation list of function after typing open
bracket.
It is best if you have VIM >= 7.3, compiled with the `+conceal` option. With
older versions, you will probably not see the parameter recommendation list
for functions after typing the open bracket. Some platforms (including OS X
releases) do not ship a VIM with `+conceal`. You can check if your VIM has the
feature with >
:ver
and look for "`+conceal`" (as opposed to "`-conceal`") or >
:echo has('conceal')
which will report 0 (not included) or 1 (included). If your VIM lacks this
feature and you would like function parameter completion, you will need to
build your own VIM, or use a package for your operating system that has this
feature (such as MacVim on OS X, which also contains a console binary).
------------------------------------------------------------------------------
2.1. Installing manually *jedi-vim-installation-manually*
@@ -105,7 +123,7 @@ bracket.
: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.
@@ -125,14 +143,21 @@ Pathogen simplifies installation considerably.
will automatically get the jedi library with the jedi-vim plugin. Add the
following to the Bundles section in your .vimrc file: >
Bundle 'git://github.com/davidhalter/jedi-vim'
Plugin 'davidhalter/jedi-vim'
2. Issue the following command in Vim: >
:BundleInstall
:PluginInstall
Help tags are generated automatically, so you should be good to go.
------------------------------------------------------------------------------
2.4. Installing from Repositories *jedi-vim-installation-repos*
Some Linux distributions have jedi-vim packages in their official
repositories. On Arch Linux, install vim-jedi. On Debian (8+) or Ubuntu
(14.04+) install vim-python-jedi.
==============================================================================
3. Supported Python features *jedi-vim-support*
@@ -212,17 +237,15 @@ Note: If you want to use <Tab> for completion, please install Supertab:
https://github.com/ervandew/supertab.
------------------------------------------------------------------------------
5.2. `g:jedi#goto_assignments_command` *g:jedi#goto_assignments_command*
Function: `jedi#goto_assignments()`
Default: <leader>g Go to definition
5.2. `g:jedi#goto_command` *g:jedi#goto_command*
Function: `jedi#goto()`
Default: <leader>d Go to definition (or assignment)
This function finds the first definition of the function/class under the
cursor. It produces an error if the definition is not in a Python file.
------------------------------------------------------------------------------
5.3. `g:jedi#goto_definitions_command` *g:jedi#goto_definitions_command*
Function: `jedi#goto_definitions()`
Default: <leader>d Go to original definition
This function first tries |jedi#goto_definitions|, and falls back to
|jedi#goto_assignments| for builtin modules. It produces an error if nothing
could be found.
NOTE: this implementation is subject to change.
Ref: https://github.com/davidhalter/jedi/issues/570
This command tries to find the original definition of the function/class under
the cursor. Just like the `jedi#goto_assignments()` function, it does not work
@@ -254,15 +277,32 @@ you all the way to the >
line in file3.py.
------------------------------------------------------------------------------
5.4. `g:jedi#documentation_command` *g:jedi#documentation_command*
5.3. `g:jedi#goto_assignments_command` *g:jedi#goto_assignments_command*
Function: `jedi#goto_assignments()`
Default: <leader>g Go to assignment
This function finds the first definition of the function/class under the
cursor. It produces an error if the definition is not in a Python file.
------------------------------------------------------------------------------
5.4. `g:jedi#goto_definitions_command` *g:jedi#goto_definitions_command*
Function: `jedi#goto_definitions()`
Default: - Go to original definition
NOTE: Deprecated. Use |g:jedi#goto_command| / |jedi#goto()| instead, which
currently uses this internally.
------------------------------------------------------------------------------
5.5. `g:jedi#documentation_command` *g:jedi#documentation_command*
Function: `jedi#show_documentation()`
Default: <K> Show pydoc documentation
This shows the pydoc documentation for the item currently under the cursor.
The documentation is opened in a horizontally split buffer.
The documentation is opened in a horizontally split buffer. The height of this
buffer is controlled by `g:jedi#max_doc_height` (set by default to 30).
------------------------------------------------------------------------------
5.5. `g:jedi#rename_command` *g:jedi#rename_command*
5.6. `g:jedi#rename_command` *g:jedi#rename_command*
Function: `jedi#rename()`
Default: <leader>r Rename variables
@@ -273,7 +313,7 @@ with the new one. The number of performed renames is displayed in the command
line.
------------------------------------------------------------------------------
5.6. `g:jedi#usages_command` *g:jedi#usages_command*
5.7. `g:jedi#usages_command` *g:jedi#usages_command*
Function: `jedi#usages()`
Default: <leader>n Show usages of a name.
@@ -281,7 +321,7 @@ The quickfix window is populated with a list of all names which point to the
definition of the name under the cursor.
------------------------------------------------------------------------------
5.7. Open module by name *:Pyimport*
5.8. Open module by name *:Pyimport*
Function: `jedi#py_import(args)`
Default: :Pyimport e.g. `:Pyimport os` shows os.py in VIM.
@@ -301,7 +341,7 @@ plugin.
Upon initialization, jedi-vim performs the following steps:
1. Set the current buffers 'omnifunc' to its own completion function
`jedi#complete`
`jedi#completions`
2. Create mappings to commands specified in |jedi-vim-keybindings|
3. Call `jedi#configure_call_signatures()` if
`g:jedi#show_call_signatures` is set
@@ -315,9 +355,11 @@ Default: 1 (Perform automatic initialization)
------------------------------------------------------------------------------
6.2. `g:jedi#auto_vim_configuration` *g:jedi#auto_vim_configuration*
Jedi-vim sets 'completeopt' to `menuone,longest,preview` by default. It also
remaps <Ctrl-C> to <Esc> in insert mode. If you want to keep your own
configuration, disable this setting.
Jedi-vim sets 'completeopt' to `menuone,longest,preview` by default, if
'completeopt' is not changed from Vim's default.
It also remaps <Ctrl-C> to <Esc> in insert mode.
If you want to keep your own configuration, disable this setting.
Options: 0 or 1
Default: 1 (Set 'completeopt' and mapping as described above)
@@ -331,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
menu. By disabling this setting, completion is only started when you manually
press the completion key.
You need to also have `g:jedi#completions_enabled` enabled for this.
Options: 0 or 1
Default: 1 (Start completion on typing a period)
@@ -355,7 +398,7 @@ When doing completion, jedi-vim shows the docstring of the currently selected
item in a preview window. By default, this window is being closed after
insertion of a completion item.
Set this to 1 to leave the preview window open even after leaving insert mode.
Set this to 0 to leave the preview window open even after leaving insert mode.
This could be useful if you want to browse longer docstrings.
Options: 0 or 1
@@ -366,11 +409,15 @@ Default: 1 (Automatically close preview window upon leaving insert mode)
Jedi-vim can display a small window detailing the arguments of the currently
completed function and highlighting the currently selected argument. This can
be disabled by setting this option to 0.
be disabled by setting this option to 0. Setting this option to 2 shows call
signatures in the command line instead of a popup window.
Options: 0 or 1
Options: 0, 1, or 2
Default: 1 (Show call signatures window)
Note: 'showmode' must be disabled for command line call signatures to be
visible.
Note: This setting is ignored if |g:jedi#auto_initialization| is set to 0. In
that case, if you want to see call signatures, you have to set it up
manually by calling a function in your configuration file: >
@@ -378,17 +425,27 @@ manually by calling a function in your configuration file: >
call jedi#configure_call_signatures()
------------------------------------------------------------------------------
6.7. `g:jedi#use_tabs_not_buffers` *g:jedi#use_tabs_not_buffers*
6.7. `g:jedi#show_call_signatures_delay` *g:jedi#show_call_signatures_delay*
By default, jedi-vim opens a new tab if you use the "go to", "show
definition", or "related names" commands. When you set this option to 0, they
open in the current buffer instead.
The delay to be used with |g:jedi#show_call_signatures|. If it is greater
than 0 it will use Vim's |CursorHoldI| event instead of |CursorMovedI|.
It will temporarily set Vim's |'updatetime'| option during insert mode.
Options: 0 or 1
Default: 1 (Command output is put in a new tab)
Options: delay in milliseconds
Default: 500
------------------------------------------------------------------------------
6.8. `g:jedi#squelch_py_warning` *g:jedi#squelch_py_warning*
6.8. `g:jedi#use_tabs_not_buffers` *g:jedi#use_tabs_not_buffers*
You can make jedi-vim open a new tab if you use the "go to", "show
definition", or "related names" commands. When you leave this at the default
(0), they open in the current buffer instead.
Options: 0 or 1
Default: 0 (Command output is put in a new tab)
------------------------------------------------------------------------------
6.9. `g:jedi#squelch_py_warning` *g:jedi#squelch_py_warning*
When Vim has not been compiled with +python, jedi-vim shows a warning to that
effect and aborts loading itself. Set this to 1 to suppress that warning.
@@ -397,7 +454,7 @@ Options: 0 or 1
Default: 0 (Warning is shown)
------------------------------------------------------------------------------
6.9. `g:jedi#completions_enable` *g:jedi#completions_enable*
6.10. `g:jedi#completions_enabled` *g:jedi#completions_enabled*
If you don't want Jedi completion, but all the other features, you can disable
it in favor of another completion engine (that probably also uses Jedi, like
@@ -407,16 +464,21 @@ Options: 0 or 1
Default: 1
------------------------------------------------------------------------------
6.10. `g:jedi#use_splits_not_buffers` *g:jedi#use_splits_not_buffers*
6.11. `g:jedi#use_splits_not_buffers` *g:jedi#use_splits_not_buffers*
If you want to open new split for "go to", you could set this option to the
direction which you want to open a split with.
Options: top, left, right or bottom
Options: top, left, right, bottom or winwidth
Default: "" (not enabled by default)
Note: with the 'winwidth' option the window is split vertically or horizontally
depending on the width of the window relative to 'textwidth'. This essentially
means that if the window is big enough it will be split vertically but if it is
small a horizontal split happens.
------------------------------------------------------------------------------
6.11. `g:jedi#force_py_version` *g:jedi#force_py_version*
6.12. `g:jedi#force_py_version` *g:jedi#force_py_version*
If you have installed both python 2 and python 3, you can force which one jedi
should use by setting this variable. It forces the internal Vim command, which
@@ -432,7 +494,30 @@ or set directly using this function, which has the same name as the variable:
Function: `jedi#force_py_version(py_version)`
Options: 2 or 3
Default: 2
Default: "auto" (will use sys.version_info from "python" in your $PATH)
------------------------------------------------------------------------------
6.13. `g:jedi#smart_auto_mappings` *g:jedi#smart_auto_mappings*
When you start typing `from module.name<space>` jedi-vim automatically
adds the "import" statement and displays the autocomplete popup.
This option can be disabled in the .vimrc:
`let g:jedi#smart_auto_mappings = 0`
Options: 0 or 1
Default: 1 (enabled by default)
------------------------------------------------------------------------------
6.14. `g:jedi#use_tag_stack` *g:jedi#use_tag_stack*
Write results of |jedi#goto| to a temporary file and use the |:tjump| command
to enable full |tagstack| functionality. Use of the tag stack allows
returning to the usage of a function with CTRL-T after exploring the
definition with arbitrary changes to the |jumplist|.
Options: 0 or 1
Default: 1 (enabled by default)
==============================================================================
7. Testing *jedi-vim-testing*
@@ -457,4 +542,4 @@ We love Pull Requests! Read the instructions in `CONTRIBUTING.md`.
Jedi-vim is licensed with the MIT license.
vim: textwidth=78 tabstop=8 filetype=help:norightleft:
vim: textwidth=78 et filetype=help:norightleft:
+25 -22
View File
@@ -1,4 +1,4 @@
if !has('python') && !has('python3')
if !jedi#init_python()
finish
endif
" ------------------------------------------------------------------------
@@ -7,25 +7,29 @@ endif
if g:jedi#auto_initialization
" goto / get_definition / usages
if g:jedi#goto_assignments_command != ''
execute "nnoremap <buffer> ".g:jedi#goto_assignments_command." :call jedi#goto_assignments()<CR>"
if len(g:jedi#goto_command)
execute 'nnoremap <buffer> '.g:jedi#goto_command.' :call jedi#goto()<CR>'
endif
if g:jedi#goto_definitions_command != ''
execute "nnoremap <buffer> ".g:jedi#goto_definitions_command." :call jedi#goto_definitions()<CR>"
if len(g:jedi#goto_assignments_command)
execute 'nnoremap <buffer> '.g:jedi#goto_assignments_command.' :call jedi#goto_assignments()<CR>'
endif
if g:jedi#usages_command != ''
execute "nnoremap <buffer> ".g:jedi#usages_command." :call jedi#usages()<CR>"
if len(g:jedi#goto_definitions_command)
execute 'nnoremap <buffer> '.g:jedi#goto_definitions_command.' :call jedi#goto_definitions()<CR>'
endif
if len(g:jedi#usages_command)
execute 'nnoremap <buffer> '.g:jedi#usages_command.' :call jedi#usages()<CR>'
endif
" rename
if g:jedi#rename_command != ''
execute "nnoremap <buffer> ".g:jedi#rename_command." :call jedi#rename()<CR>"
if len(g:jedi#rename_command)
execute 'nnoremap <buffer> '.g:jedi#rename_command.' :call jedi#rename()<CR>'
execute 'vnoremap <buffer> '.g:jedi#rename_command.' :call jedi#rename_visual()<CR>'
endif
" documentation/pydoc
if g:jedi#documentation_command != ''
execute "nnoremap <silent> <buffer>".g:jedi#documentation_command." :call jedi#show_documentation()<CR>"
if len(g:jedi#documentation_command)
execute 'nnoremap <silent> <buffer>'.g:jedi#documentation_command.' :call jedi#show_documentation()<CR>'
endif
if g:jedi#show_call_signatures == 1 && has('conceal')
if g:jedi#show_call_signatures > 0 && has('conceal')
call jedi#configure_call_signatures()
endif
@@ -33,15 +37,14 @@ if g:jedi#auto_initialization
inoremap <silent> <buffer> . .<C-R>=jedi#complete_string(1)<CR>
endif
if g:jedi#smart_auto_mappings == 1
inoremap <silent> <buffer> <space> <C-R>=jedi#smart_auto_mappings()<CR>
end
if g:jedi#auto_close_doc
" close preview if its still open after insert
autocmd InsertLeave <buffer> if pumvisible() == 0|pclose|endif
end
end
if g:jedi#auto_vim_configuration
setlocal completeopt=menuone,longest,preview
if len(mapcheck('<C-c>', 'i')) == 0
inoremap <C-c> <ESC>
end
end
augroup jedi_preview
autocmd! InsertLeave <buffer> if pumvisible() == 0|pclose|endif
augroup END
endif
endif
-26
View File
@@ -1,26 +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('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('s:script_path'))
try:
import jedi_vim
except ImportError:
vim.command('echoerr "Please install Jedi if you want to use jedi_vim."')
sys.path.pop(1)
Submodule jedi deleted from 78f1ae5e71
-473
View File
@@ -1,473 +0,0 @@
"""
The Python parts of the Jedi library for VIM. It is mostly about communicating
with VIM.
"""
import traceback # for exception output
import re
import os
from shlex import split as shsplit
import vim
import jedi
import jedi.keywords
from jedi._compatibility import unicode, is_py3k
def catch_and_print_exceptions(func):
def wrapper(*args, **kwargs):
try:
return func(*args, **kwargs)
except (Exception, vim.error):
print(traceback.format_exc())
return None
return wrapper
class VimError(Exception):
def __init__(self, message, throwpoint, executing):
super(type(self), self).__init__(message)
self.throwpoint = throwpoint
self.executing = executing
def __str__(self):
return self.message + '; created by: ' + repr(self.executing)
def _catch_exception(string, is_eval):
"""
Interface between vim and python calls back to it.
Necessary, because the exact error message is not given by `vim.error`.
"""
e = 'jedi#_vim_exceptions(%s, %s)'
result = vim.eval(e % (repr(PythonToVimStr(string, 'UTF-8')), is_eval))
if 'exception' in result:
raise VimError(result['exception'], result['throwpoint'], string)
return result['result']
def vim_eval(string):
return _catch_exception(string, 1)
def vim_command(string):
_catch_exception(string, 0)
def echo_highlight(msg):
vim_command('echohl WarningMsg | echom "%s" | echohl None' % msg)
class PythonToVimStr(unicode):
""" Vim has a different string implementation of single quotes """
__slots__ = []
def __new__(cls, obj, encoding='UTF-8'):
if is_py3k or isinstance(obj, unicode):
return unicode.__new__(cls, obj)
else:
return unicode.__new__(cls, obj, encoding)
def __repr__(self):
# this is totally stupid and makes no sense but vim/python unicode
# support is pretty bad. don't ask how I came up with this... It just
# works...
# It seems to be related to that bug: http://bugs.python.org/issue5876
if unicode is str:
s = self
else:
s = self.encode('UTF-8')
return '"%s"' % s.replace('\\', '\\\\').replace('"', r'\"')
@catch_and_print_exceptions
def get_script(source=None, column=None):
jedi.settings.additional_dynamic_modules = [b.name for b in vim.buffers
if b.name is not None and b.name.endswith('.py')]
if source is None:
source = '\n'.join(vim.current.buffer)
row = vim.current.window.cursor[0]
if column is None:
column = vim.current.window.cursor[1]
buf_path = vim.current.buffer.name
encoding = vim_eval('&encoding') or 'latin1'
return jedi.Script(source, row, column, buf_path, encoding)
@catch_and_print_exceptions
def completions():
row, column = vim.current.window.cursor
clear_call_signatures()
if vim.eval('a:findstart') == '1':
count = 0
for char in reversed(vim.current.line[:column]):
if not re.match('[\w\d]', char):
break
count += 1
vim.command('return %i' % (column - count))
else:
base = vim.eval('a:base')
source = ''
for i, line in enumerate(vim.current.buffer):
# enter this path again, otherwise source would be incomplete
if i == row - 1:
source += line[:column] + base + line[column:]
else:
source += line
source += '\n'
# here again hacks, because jedi has a different interface than vim
column += len(base)
try:
script = get_script(source=source, column=column)
completions = script.completions()
signatures = script.call_signatures()
out = []
for c in completions:
d = dict(word=PythonToVimStr(c.name[:len(base)] + c.complete),
abbr=PythonToVimStr(c.name),
# stuff directly behind the completion
menu=PythonToVimStr(c.description),
info=PythonToVimStr(c.doc), # docstr
icase=1, # case insensitive
dup=1 # allow duplicates (maybe later remove this)
)
out.append(d)
strout = str(out)
except Exception:
# print to stdout, will be in :messages
print(traceback.format_exc())
strout = ''
completions = []
signatures = []
show_call_signatures(signatures)
vim.command('return ' + strout)
@catch_and_print_exceptions
def goto(is_definition=False, is_related_name=False, no_output=False):
definitions = []
script = get_script()
try:
if is_related_name:
definitions = script.usages()
elif is_definition:
definitions = script.goto_definitions()
else:
definitions = script.goto_assignments()
except jedi.NotFoundError:
echo_highlight( "Cannot follow nothing. Put your cursor on a valid name.")
else:
if no_output:
return definitions
if not definitions:
echo_highlight("Couldn't find any definitions for this.")
elif len(definitions) == 1 and not is_related_name:
# just add some mark to add the current position to the jumplist.
# this is ugly, because it overrides the mark for '`', so if anyone
# has a better idea, let me know.
vim_command('normal! m`')
d = list(definitions)[0]
if d.in_builtin_module():
if d.is_keyword:
echo_highlight(
"Cannot get the definition of Python keywords.")
else:
echo_highlight("Builtin modules cannot be displayed (%s)."
% d.module_path)
else:
if d.module_path != vim.current.buffer.name:
result = new_buffer(d.module_path)
if not result:
return
vim.current.window.cursor = d.line, d.column
vim_command('normal! zt') # cursor at top of screen
else:
# multiple solutions
lst = []
for d in definitions:
if d.in_builtin_module():
lst.append(dict(text=
PythonToVimStr('Builtin ' + 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()')
return definitions
@catch_and_print_exceptions
def show_documentation():
script = get_script()
try:
definitions = script.goto_definitions()
except jedi.NotFoundError:
definitions = []
except Exception:
# print to stdout, will be in :messages
definitions = []
print("Exception, this shouldn't happen.")
print(traceback.format_exc())
if not definitions:
echo_highlight('No documentation found for that.')
vim.command('return')
else:
docs = ['Docstring for %s\n%s\n%s' % (d.desc_with_module, '='*40, d.doc) if d.doc
else '|No Docstring for %s|' % d for d in definitions]
text = ('\n' + '-' * 79 + '\n').join(docs)
vim.command('let l:doc = %s' % repr(PythonToVimStr(text)))
vim.command('let l:doc_lines = %s' % len(text.split('\n')))
@catch_and_print_exceptions
def clear_call_signatures():
cursor = vim.current.window.cursor
e = vim_eval('g:jedi#call_signature_escape')
regex = r'%sjedi=([0-9]+), ([^%s]*)%s.*%sjedi%s'.replace('%s', e)
for i, line in enumerate(vim.current.buffer):
match = re.search(r'%s' % regex, line)
if match is not None:
vim_regex = r'\v' + regex.replace('=', r'\=') + '.{%s}' % \
int(match.group(1))
vim_command(r'try | %s,%ss/%s/\2/g | catch | endtry' \
% (i + 1, i + 1, vim_regex))
vim_eval('histdel("search", -1)')
vim_command('let @/ = histget("search", -1)')
vim.current.window.cursor = cursor
@catch_and_print_exceptions
def show_call_signatures(signatures=()):
if vim_eval("has('conceal') && g:jedi#show_call_signatures") == '0':
return
if signatures == ():
signatures = get_script().call_signatures()
clear_call_signatures()
if not signatures:
return
for i, signature in enumerate(signatures):
line, column = signature.bracket_start
# signatures are listed above each other
line_to_replace = line - i - 1
# because there's a space before the bracket
insert_column = column - 1
if insert_column < 0 or line_to_replace <= 0:
# Edge cases, when the call signature has no space on the screen.
break
# TODO check if completion menu is above or below
line = vim_eval("getline(%s)" % line_to_replace)
params = [p.get_code().replace('\n', '') for p in signature.params]
try:
params[signature.index] = '*%s*' % params[signature.index]
except (IndexError, TypeError):
pass
# This stuff is reaaaaally a hack! I cannot stress enough, that
# this is a stupid solution. But there is really no other yet.
# There is no possibility in VIM to draw on the screen, but there
# will be one (see :help todo Patch to access screen under Python.
# (Marko Mahni, 2010 Jul 18))
text = " (%s) " % ', '.join(params)
text = ' ' * (insert_column - len(line)) + text
end_column = insert_column + len(text) - 2 # -2 due to bold symbols
# Need to decode it with utf8, because vim returns always a python 2
# string even if it is unicode.
e = vim_eval('g:jedi#call_signature_escape')
if hasattr(e, 'decode'):
e = e.decode('UTF-8')
# replace line before with cursor
regex = "xjedi=%sx%sxjedix".replace('x', e)
prefix, replace = line[:insert_column], line[insert_column:end_column]
# Check the replace stuff for strings, to append them
# (don't want to break the syntax)
regex_quotes = r'''\\*["']+'''
# `add` are all the quotation marks.
# join them with a space to avoid producing '''
add = ' '.join(re.findall(regex_quotes, replace))
# search backwards
if add and replace[0] in ['"', "'"]:
a = re.search(regex_quotes + '$', prefix)
add = ('' if a is None else a.group(0)) + add
tup = '%s, %s' % (len(add), replace)
repl = prefix + (regex % (tup, text)) + add + line[end_column:]
vim_eval('setline(%s, %s)' % (line_to_replace, repr(PythonToVimStr(repl))))
@catch_and_print_exceptions
def rename():
if not int(vim.eval('a:0')):
_rename_cursor = vim.current.window.cursor
vim_command('normal A ') # otherwise startinsert doesn't work well
vim.current.window.cursor = _rename_cursor
vim_command('augroup jedi_rename')
vim_command('autocmd InsertLeave <buffer> call jedi#rename(1)')
vim_command('augroup END')
vim_command('normal! diw')
vim_command(':startinsert')
else:
window_path = vim.current.buffer.name
# reset autocommand
vim_command('autocmd! jedi_rename InsertLeave')
replace = vim_eval("expand('<cword>')")
vim_command('normal! u') # undo new word
cursor = vim.current.window.cursor
vim_command('normal! u') # undo the space at the end
vim.current.window.cursor = cursor
if replace is None:
echo_highlight('No rename possible, if no name is given.')
else:
temp_rename = goto(is_related_name=True, no_output=True)
# sort the whole thing reverse (positions at the end of the line
# must be first, because they move the stuff before the position).
temp_rename = sorted(temp_rename, reverse=True,
key=lambda x: (x.module_path, x.start_pos))
for r in temp_rename:
if r.in_builtin_module():
continue
if vim.current.buffer.name != r.module_path:
result = new_buffer(r.module_path)
if not result:
return
vim.current.window.cursor = r.start_pos
vim_command('normal! cw%s' % replace)
result = new_buffer(window_path)
if not result:
return
vim.current.window.cursor = cursor
echo_highlight('Jedi did %s renames!' % len(temp_rename))
@catch_and_print_exceptions
def py_import():
# args are the same as for the :edit command
args = shsplit(vim.eval('a:args'))
import_path = args.pop()
text = 'import %s' % import_path
scr = jedi.Script(text, 1, len(text), '')
try:
completion = scr.goto_assignments()[0]
except IndexError:
echo_highlight('Cannot find %s in sys.path!' % import_path)
else:
if completion.in_builtin_module():
echo_highlight('%s is a builtin module.' % import_path)
else:
cmd_args = ' '.join([a.replace(' ', '\\ ') for a in args])
new_buffer(completion.module_path, cmd_args)
@catch_and_print_exceptions
def py_import_completions():
argl = vim.eval('a:argl')
try:
import jedi
except ImportError:
print('Pyimport completion requires jedi module: https://github.com/davidhalter/jedi')
comps = []
else:
text = 'import %s' % argl
script=jedi.Script(text, 1, len(text), '')
comps = ['%s%s' % (argl, c.complete) for c in script.completions()]
vim.command("return '%s'" % '\n'.join(comps))
@catch_and_print_exceptions
def new_buffer(path, options=''):
# options are what you can to edit the edit options
if vim_eval('g:jedi#use_tabs_not_buffers') == '1':
_tabnew(path, options)
elif not vim_eval('g:jedi#use_splits_not_buffers') == '1':
user_split_option = vim_eval('g:jedi#use_splits_not_buffers')
split_options = {
'top': 'topleft split',
'left': 'topleft vsplit',
'right': 'botright vsplit',
'bottom': 'botright split'
}
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()))
else:
vim_command(split_options[user_split_option] + " %s" % path)
else:
if vim_eval("!&hidden && &modified") == '1':
if vim_eval("bufname('%')") is None:
echo_highlight('Cannot open a new buffer, use `:set hidden` or save your buffer')
return False
else:
vim_command('w')
vim_command('edit %s %s' % (options, escape_file_path(path)))
# sometimes syntax is being disabled and the filetype not set.
if vim_eval('!exists("g:syntax_on")') == '1':
vim_command('syntax enable')
if vim_eval("&filetype != 'python'") == '1':
vim_command('set filetype=python')
return True
@catch_and_print_exceptions
def _tabnew(path, options=''):
"""
Open a file in a new tab or switch to an existing one.
:param options: `:tabnew` options, read vim help.
"""
path = os.path.abspath(path)
if vim_eval('has("gui")') == '1':
vim_command('tab drop %s %s' % (options, escape_file_path(path)))
return
for tab_nr in range(int(vim_eval("tabpagenr('$')"))):
for buf_nr in vim_eval("tabpagebuflist(%i + 1)" % tab_nr):
buf_nr = int(buf_nr) - 1
try:
buf_path = vim.buffers[buf_nr].name
except (LookupError, ValueError):
# Just do good old asking for forgiveness.
# don't know why this happens :-)
pass
else:
if buf_path == path:
# tab exists, just switch to that tab
vim_command('tabfirst | tabnext %i' % (tab_nr + 1))
break
else:
continue
break
else:
# tab doesn't exist, add a new one.
vim_command('tabnew %s' % escape_file_path(path))
def escape_file_path(path):
return path.replace(' ', r'\ ')
def print_to_stdout(level, str_out):
print(str_out)
if not hasattr(jedi, '__version__') or jedi.__version__ < (0, 7, 0):
echo_highlight('Please update your Jedi version, it is to old.')
+41 -6
View File
@@ -4,16 +4,51 @@
" This part of the software is just the vim interface. The really big deal is
" the Jedi Python library.
" jedi-vim doesn't work in compatible mode (vim script syntax problems)
if &compatible
if get(g:, 'jedi#auto_vim_configuration', 1)
" jedi-vim doesn't work in compatible mode (vim script syntax problems)
if &compatible
" vint: -ProhibitSetNoCompatible
set nocompatible
endif
" vint: +ProhibitSetNoCompatible
endif
" jedi-vim really needs, otherwise jedi-vim cannot start.
filetype plugin on
" jedi-vim really needs, otherwise jedi-vim cannot start.
filetype plugin on
" Change completeopt, but only if it was not set already.
" This gets done on VimEnter, since otherwise Vim fails to restore the
" screen. Neovim is not affected, this is likely caused by using
" :redir/execute() before the (alternate) terminal is configured.
function! s:setup_completeopt()
if exists('*execute')
let completeopt = execute('silent verb set completeopt?')
else
redir => completeopt
silent verb set completeopt?
redir END
endif
if len(split(completeopt, '\n')) == 1
set completeopt=menuone,longest,preview
endif
endfunction
if has('nvim')
call s:setup_completeopt()
else
augroup jedi_startup
au!
autocmd VimEnter * call s:setup_completeopt()
augroup END
endif
if len(mapcheck('<C-c>', 'i')) == 0
inoremap <C-c> <ESC>
endif
endif
" Pyimport command
command! -nargs=1 -complete=custom,jedi#py_import_completions Pyimport :call jedi#py_import(<q-args>)
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:
Submodule
+1
Submodule pythonx/jedi added at 02f238ce08
+734
View File
@@ -0,0 +1,734 @@
# -*- coding: utf-8 -*-
"""
The Python parts of the Jedi library for VIM. It is mostly about communicating
with VIM.
"""
import traceback # for exception output
import re
import os
import sys
from shlex import split as shsplit
from contextlib import contextmanager
try:
from itertools import zip_longest
except ImportError:
from itertools import izip_longest as zip_longest # Python 2
import vim
is_py3 = sys.version_info[0] >= 3
if is_py3:
ELLIPSIS = ""
unicode = str
else:
ELLIPSIS = u""
class PythonToVimStr(unicode):
""" Vim has a different string implementation of single quotes """
__slots__ = []
def __new__(cls, obj, encoding='UTF-8'):
if not (is_py3 or isinstance(obj, unicode)):
obj = unicode.__new__(cls, obj, encoding)
# Vim cannot deal with zero bytes:
obj = obj.replace('\0', '\\0')
return unicode.__new__(cls, obj)
def __repr__(self):
# this is totally stupid and makes no sense but vim/python unicode
# support is pretty bad. don't ask how I came up with this... It just
# works...
# It seems to be related to that bug: http://bugs.python.org/issue5876
if unicode is str:
s = self
else:
s = self.encode('UTF-8')
return '"%s"' % s.replace('\\', '\\\\').replace('"', r'\"')
class VimError(Exception):
def __init__(self, message, throwpoint, executing):
super(type(self), self).__init__(message)
self.message = message
self.throwpoint = throwpoint
self.executing = executing
def __str__(self):
return self.message + '; created by: ' + repr(self.executing)
def _catch_exception(string, is_eval):
"""
Interface between vim and python calls back to it.
Necessary, because the exact error message is not given by `vim.error`.
"""
result = vim.eval('jedi#_vim_exceptions({0}, {1})'.format(
repr(PythonToVimStr(string, 'UTF-8')), int(is_eval)))
if 'exception' in result:
raise VimError(result['exception'], result['throwpoint'], string)
return result['result']
def vim_command(string):
_catch_exception(string, False)
def vim_eval(string):
return _catch_exception(string, True)
def no_jedi_warning(error=None):
vim.command('echohl WarningMsg')
vim.command('echom "Please install Jedi if you want to use jedi-vim."')
if error:
vim.command('echom "The error was: {0}"'.format(error))
vim.command('echohl None')
def echo_highlight(msg):
vim_command('echohl WarningMsg | echom "jedi-vim: {0}" | echohl None'.format(
str(msg).replace('"', '\\"')))
jedi_path = os.path.join(os.path.dirname(__file__), 'jedi')
sys.path.insert(0, jedi_path)
parso_path = os.path.join(os.path.dirname(__file__), 'parso')
sys.path.insert(0, parso_path)
try:
import jedi
except ImportError as e:
no_jedi_warning(str(e))
jedi = None
jedi_import_error = str(e)
else:
try:
version = jedi.__version__
except Exception as e: # e.g. AttributeError
echo_highlight(
"Error when loading the jedi python module ({0}). "
"Please ensure that Jedi is installed correctly (see Installation "
"in the README.".format(e))
jedi = None
else:
if isinstance(version, str):
# the normal use case, now.
from jedi import utils
version = utils.version_info()
if version < (0, 7):
echo_highlight('Please update your Jedi version, it is too old.')
finally:
sys.path.remove(jedi_path)
sys.path.remove(parso_path)
def catch_and_print_exceptions(func):
def wrapper(*args, **kwargs):
try:
return func(*args, **kwargs)
except (Exception, vim.error):
print(traceback.format_exc())
return None
return wrapper
def _check_jedi_availability(show_error=False):
def func_receiver(func):
def wrapper(*args, **kwargs):
if jedi is None:
if show_error:
no_jedi_warning()
return
else:
return func(*args, **kwargs)
return wrapper
return func_receiver
@catch_and_print_exceptions
def get_script(source=None, column=None):
jedi.settings.additional_dynamic_modules = \
[b.name for b in vim.buffers if b.name is not None and b.name.endswith('.py')]
if source is None:
source = '\n'.join(vim.current.buffer)
row = vim.current.window.cursor[0]
if column is None:
column = vim.current.window.cursor[1]
buf_path = vim.current.buffer.name
encoding = vim_eval('&encoding') or 'latin1'
return jedi.Script(source, row, column, buf_path, encoding)
@_check_jedi_availability(show_error=False)
@catch_and_print_exceptions
def completions():
row, column = vim.current.window.cursor
# Clear call signatures in the buffer so they aren't seen by the completer.
# Call signatures in the command line can stay.
if int(vim_eval("g:jedi#show_call_signatures")) == 1:
clear_call_signatures()
if vim.eval('a:findstart') == '1':
count = 0
for char in reversed(vim.current.line[:column]):
if not re.match('[\w\d]', char):
break
count += 1
vim.command('return %i' % (column - count))
else:
base = vim.eval('a:base')
source = ''
for i, line in enumerate(vim.current.buffer):
# enter this path again, otherwise source would be incomplete
if i == row - 1:
source += line[:column] + base + line[column:]
else:
source += line
source += '\n'
# here again hacks, because jedi has a different interface than vim
column += len(base)
try:
script = get_script(source=source, column=column)
completions = script.completions()
signatures = script.call_signatures()
out = []
for c in completions:
d = dict(word=PythonToVimStr(c.name[:len(base)] + c.complete),
abbr=PythonToVimStr(c.name_with_symbols),
# stuff directly behind the completion
menu=PythonToVimStr(c.description),
info=PythonToVimStr(c.docstring()), # docstr
icase=1, # case insensitive
dup=1 # allow duplicates (maybe later remove this)
)
out.append(d)
strout = str(out)
except Exception:
# print to stdout, will be in :messages
print(traceback.format_exc())
strout = ''
completions = []
signatures = []
show_call_signatures(signatures)
vim.command('return ' + strout)
@contextmanager
def tempfile(content):
# Using this instead of the tempfile module because Windows won't read
# from a file not yet written to disk
with open(vim_eval('tempname()'), 'w') as f:
f.write(content)
try:
yield f
finally:
os.unlink(f.name)
@_check_jedi_availability(show_error=True)
@catch_and_print_exceptions
def goto(mode="goto", no_output=False):
"""
:param str mode: "related_name", "definition", "assignment", "auto"
:return: list of definitions/assignments
:rtype: list
"""
script = get_script()
if mode == "goto":
definitions = [x for x in script.goto_definitions()
if not x.in_builtin_module()]
if not definitions:
definitions = script.goto_assignments()
elif mode == "related_name":
definitions = script.usages()
elif mode == "definition":
definitions = script.goto_definitions()
elif mode == "assignment":
definitions = script.goto_assignments()
if no_output:
return definitions
if not definitions:
echo_highlight("Couldn't find any definitions for this.")
elif len(definitions) == 1 and mode != "related_name":
d = list(definitions)[0]
if d.in_builtin_module():
if d.is_keyword:
echo_highlight("Cannot get the definition of Python keywords.")
else:
echo_highlight("Builtin modules cannot be displayed (%s)."
% d.desc_with_module)
else:
using_tagstack = int(vim_eval('g:jedi#use_tag_stack')) == 1
if (d.module_path or '') != vim.current.buffer.name:
result = new_buffer(d.module_path,
using_tagstack=using_tagstack)
if not result:
return []
if d.module_path and os.path.exists(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:
# 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
@_check_jedi_availability(show_error=True)
@catch_and_print_exceptions
def show_documentation():
script = get_script()
try:
definitions = script.goto_definitions()
except jedi.NotFoundError:
definitions = []
except Exception:
# print to stdout, will be in :messages
definitions = []
print("Exception, this shouldn't happen.")
print(traceback.format_exc())
if not definitions:
echo_highlight('No documentation found for that.')
vim.command('return')
else:
docs = ['Docstring for %s\n%s\n%s' % (d.desc_with_module, '=' * 40, d.docstring())
if d.docstring() else '|No Docstring for %s|' % d for d in definitions]
text = ('\n' + '-' * 79 + '\n').join(docs)
vim.command('let l:doc = %s' % repr(PythonToVimStr(text)))
vim.command('let l:doc_lines = %s' % len(text.split('\n')))
return True
@catch_and_print_exceptions
def clear_call_signatures():
# Check if using command line call signatures
if int(vim_eval("g:jedi#show_call_signatures")) == 2:
vim_command('echo ""')
return
cursor = vim.current.window.cursor
e = vim_eval('g:jedi#call_signature_escape')
# We need two turns here to search and replace certain lines:
# 1. Search for a line with a call signature and save the appended
# characters
# 2. Actually replace the line and redo the status quo.
py_regex = r'%sjedi=([0-9]+), (.*?)%s.*?%sjedi%s'.replace(
'%s', re.escape(e))
for i, line in enumerate(vim.current.buffer):
match = re.search(py_regex, line)
if match is not None:
# Some signs were added to minimize syntax changes due to call
# signatures. We have to remove them again. The number of them is
# specified in `match.group(1)`.
after = line[match.end() + int(match.group(1)):]
line = line[:match.start()] + match.group(2) + after
vim.current.buffer[i] = line
vim.current.window.cursor = cursor
@_check_jedi_availability(show_error=False)
@catch_and_print_exceptions
def show_call_signatures(signatures=()):
if int(vim_eval("has('conceal') && g:jedi#show_call_signatures")) == 0:
return
if signatures == ():
signatures = get_script().call_signatures()
clear_call_signatures()
if not signatures:
return
if int(vim_eval("g:jedi#show_call_signatures")) == 2:
return cmdline_call_signatures(signatures)
for i, signature in enumerate(signatures):
line, column = signature.bracket_start
# signatures are listed above each other
line_to_replace = line - i - 1
# because there's a space before the bracket
insert_column = column - 1
if insert_column < 0 or line_to_replace <= 0:
# Edge cases, when the call signature has no space on the screen.
break
# TODO check if completion menu is above or below
line = vim_eval("getline(%s)" % line_to_replace)
# Descriptions are usually looking like `param name`, remove the param.
params = [p.description.replace('\n', '').replace('param ', '', 1) for p in signature.params]
try:
# *_*PLACEHOLDER*_* makes something fat. See after/syntax file.
params[signature.index] = '*_*%s*_*' % params[signature.index]
except (IndexError, TypeError):
pass
# This stuff is reaaaaally a hack! I cannot stress enough, that
# this is a stupid solution. But there is really no other yet.
# There is no possibility in VIM to draw on the screen, but there
# will be one (see :help todo Patch to access screen under Python.
# (Marko Mahni, 2010 Jul 18))
text = " (%s) " % ', '.join(params)
text = ' ' * (insert_column - len(line)) + text
end_column = insert_column + len(text) - 2 # -2 due to bold symbols
# Need to decode it with utf8, because vim returns always a python 2
# string even if it is unicode.
e = vim_eval('g:jedi#call_signature_escape')
if hasattr(e, 'decode'):
e = e.decode('UTF-8')
# replace line before with cursor
regex = "xjedi=%sx%sxjedix".replace('x', e)
prefix, replace = line[:insert_column], line[insert_column:end_column]
# Check the replace stuff for strings, to append them
# (don't want to break the syntax)
regex_quotes = r'''\\*["']+'''
# `add` are all the quotation marks.
# join them with a space to avoid producing '''
add = ' '.join(re.findall(regex_quotes, replace))
# search backwards
if add and replace[0] in ['"', "'"]:
a = re.search(regex_quotes + '$', prefix)
add = ('' if a is None else a.group(0)) + add
tup = '%s, %s' % (len(add), replace)
repl = prefix + (regex % (tup, text)) + add + line[end_column:]
vim_eval('setline(%s, %s)' % (line_to_replace, repr(PythonToVimStr(repl))))
@catch_and_print_exceptions
def cmdline_call_signatures(signatures):
def get_params(s):
return [p.description.replace('\n', '').replace('param ', '', 1) for p in s.params]
def escape(string):
return string.replace('"', '\\"').replace(r'\n', r'\\n')
def join():
return ', '.join(filter(None, (left, center, right)))
def too_long():
return len(join()) > max_msg_len
if len(signatures) > 1:
params = zip_longest(*map(get_params, signatures), fillvalue='_')
params = ['(' + ', '.join(p) + ')' for p in params]
else:
params = get_params(signatures[0])
index = next(iter(s.index for s in signatures if s.index is not None), None)
# Allow 12 characters for showcmd plus 18 for ruler - setting
# noruler/noshowcmd here causes incorrect undo history
max_msg_len = int(vim_eval('&columns')) - 12
if int(vim_eval('&ruler')):
max_msg_len -= 18
max_msg_len -= len(signatures[0].name) + 2 # call name + parentheses
if max_msg_len < (1 if params else 0):
return
elif index is None:
text = escape(', '.join(params))
if params and len(text) > max_msg_len:
text = ELLIPSIS
elif max_msg_len < len(ELLIPSIS):
return
else:
left = escape(', '.join(params[:index]))
center = escape(params[index])
right = escape(', '.join(params[index + 1:]))
while too_long():
if left and left != ELLIPSIS:
left = ELLIPSIS
continue
if right and right != ELLIPSIS:
right = ELLIPSIS
continue
if (left or right) and center != ELLIPSIS:
left = right = None
center = ELLIPSIS
continue
if too_long():
# Should never reach here
return
max_num_spaces = max_msg_len
if index is not None:
max_num_spaces -= len(join())
_, column = signatures[0].bracket_start
spaces = min(int(vim_eval('g:jedi#first_col +'
'wincol() - col(".")')) +
column - len(signatures[0].name),
max_num_spaces) * ' '
if index is not None:
vim_command(' echon "%s" | '
'echohl Function | echon "%s" | '
'echohl None | echon "(" | '
'echohl jediFunction | echon "%s" | '
'echohl jediFat | echon "%s" | '
'echohl jediFunction | echon "%s" | '
'echohl None | echon ")"'
% (spaces, signatures[0].name,
left + ', ' if left else '',
center, ', ' + right if right else ''))
else:
vim_command(' echon "%s" | '
'echohl Function | echon "%s" | '
'echohl None | echon "(%s)"'
% (spaces, signatures[0].name, text))
@_check_jedi_availability(show_error=True)
@catch_and_print_exceptions
def rename():
if not int(vim.eval('a:0')):
# Need to save the cursor position before insert mode
cursor = vim.current.window.cursor
changenr = vim.eval('changenr()') # track undo tree
vim_command('augroup jedi_rename')
vim_command('autocmd InsertLeave <buffer> call jedi#rename'
'({}, {}, {})'.format(cursor[0], cursor[1], changenr))
vim_command('augroup END')
vim_command("let s:jedi_replace_orig = expand('<cword>')")
vim_command('normal! diw')
vim_command('startinsert')
else:
# Remove autocommand.
vim_command('autocmd! jedi_rename InsertLeave')
args = vim.eval('a:000')
cursor = tuple(int(x) for x in args[:2])
changenr = args[2]
# Get replacement, if there is something on the cursor.
# This won't be the case when the user ends insert mode right away,
# and `<cword>` would pick up the nearest word instead.
if vim_eval('getline(".")[getpos(".")[2]-1]') != ' ':
replace = vim_eval("expand('<cword>')")
else:
replace = None
vim_command('undo {}'.format(changenr))
vim.current.window.cursor = cursor
if replace:
return do_rename(replace)
def rename_visual():
replace = vim.eval('input("Rename to: ")')
orig = vim.eval('getline(".")[(getpos("\'<")[2]-1):getpos("\'>")[2]]')
do_rename(replace, orig)
def do_rename(replace, orig=None):
if not len(replace):
echo_highlight('No rename possible without name.')
return
if orig is None:
orig = vim_eval('s:jedi_replace_orig')
# Save original window / tab.
saved_tab = int(vim_eval('tabpagenr()'))
saved_win = int(vim_eval('winnr()'))
temp_rename = goto(mode="related_name", no_output=True)
# Sort the whole thing reverse (positions at the end of the line
# must be first, because they move the stuff before the position).
temp_rename = sorted(temp_rename, reverse=True,
key=lambda x: (x.module_path, x.line, x.column))
buffers = set()
for r in temp_rename:
if r.in_builtin_module():
continue
if os.path.abspath(vim.current.buffer.name) != r.module_path:
assert r.module_path is not None
result = new_buffer(r.module_path)
if not result:
echo_highlight("Jedi-vim: failed to create buffer window for {0}!".format(r.module_path))
continue
buffers.add(vim.current.buffer.name)
# Save view.
saved_view = vim_eval('string(winsaveview())')
# Replace original word.
vim.current.window.cursor = (r.line, r.column)
vim_command('normal! c{0:d}l{1}'.format(len(orig), replace))
# Restore view.
vim_command('call winrestview(%s)' % saved_view)
# Restore previous tab and window.
vim_command('tabnext {0:d}'.format(saved_tab))
vim_command('{0:d}wincmd w'.format(saved_win))
if len(buffers) > 1:
echo_highlight('Jedi did {0:d} renames in {1:d} buffers!'.format(
len(temp_rename), len(buffers)))
else:
echo_highlight('Jedi did {0:d} renames!'.format(len(temp_rename)))
@_check_jedi_availability(show_error=True)
@catch_and_print_exceptions
def py_import():
# args are the same as for the :edit command
args = shsplit(vim.eval('a:args'))
import_path = args.pop()
text = 'import %s' % import_path
scr = jedi.Script(text, 1, len(text), '')
try:
completion = scr.goto_assignments()[0]
except IndexError:
echo_highlight('Cannot find %s in sys.path!' % import_path)
else:
if completion.in_builtin_module():
echo_highlight('%s is a builtin module.' % import_path)
else:
cmd_args = ' '.join([a.replace(' ', '\\ ') for a in args])
new_buffer(completion.module_path, cmd_args)
@catch_and_print_exceptions
def py_import_completions():
argl = vim.eval('a:argl')
try:
import jedi
except ImportError:
print('Pyimport completion requires jedi module: https://github.com/davidhalter/jedi')
comps = []
else:
text = 'import %s' % argl
script = jedi.Script(text, 1, len(text), '')
comps = ['%s%s' % (argl, c.complete) for c in script.completions()]
vim.command("return '%s'" % '\n'.join(comps))
@catch_and_print_exceptions
def new_buffer(path, options='', using_tagstack=False):
# options are what you can to edit the edit options
if int(vim_eval('g:jedi#use_tabs_not_buffers')) == 1:
_tabnew(path, options)
elif not vim_eval('g:jedi#use_splits_not_buffers') in [1, '1']:
user_split_option = vim_eval('g:jedi#use_splits_not_buffers')
split_options = {
'top': 'topleft split',
'left': 'topleft vsplit',
'right': 'botright vsplit',
'bottom': 'botright split',
'winwidth': 'vs'
}
if (user_split_option == 'winwidth' and
vim.current.window.width <= 2 * int(vim_eval(
"&textwidth ? &textwidth : 80"))):
split_options['winwidth'] = 'sp'
if user_split_option not in split_options:
print('Unsupported value for g:jedi#use_splits_not_buffers: {0}. '
'Valid options are: {1}.'.format(
user_split_option, ', '.join(split_options.keys())))
else:
vim_command(split_options[user_split_option] + " %s" % escape_file_path(path))
else:
if int(vim_eval("!&hidden && &modified")) == 1:
if not vim_eval("bufname('%')"):
echo_highlight('Cannot open a new buffer, use `:set hidden` or save your buffer')
return False
else:
vim_command('w')
if using_tagstack:
return True
vim_command('edit %s %s' % (options, escape_file_path(path)))
# sometimes syntax is being disabled and the filetype not set.
if int(vim_eval('!exists("g:syntax_on")')) == 1:
vim_command('syntax enable')
if int(vim_eval("&filetype != 'python'")) == 1:
vim_command('set filetype=python')
return True
@catch_and_print_exceptions
def _tabnew(path, options=''):
"""
Open a file in a new tab or switch to an existing one.
:param options: `:tabnew` options, read vim help.
"""
path = os.path.abspath(path)
if int(vim_eval('has("gui")')) == 1:
vim_command('tab drop %s %s' % (options, escape_file_path(path)))
return
for tab_nr in range(int(vim_eval("tabpagenr('$')"))):
for buf_nr in vim_eval("tabpagebuflist(%i + 1)" % tab_nr):
buf_nr = int(buf_nr) - 1
try:
buf_path = vim.buffers[buf_nr].name
except (LookupError, ValueError):
# Just do good old asking for forgiveness.
# don't know why this happens :-)
pass
else:
if buf_path == path:
# tab exists, just switch to that tab
vim_command('tabfirst | tabnext %i' % (tab_nr + 1))
# Goto the buffer's window.
vim_command('exec bufwinnr(%i) . " wincmd w"' % (buf_nr + 1))
break
else:
continue
break
else:
# tab doesn't exist, add a new one.
vim_command('tabnew %s' % escape_file_path(path))
def escape_file_path(path):
return path.replace(' ', r'\ ')
def print_to_stdout(level, str_out):
print(str_out)
+44
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))
Submodule
+1
Submodule pythonx/parso added at 2ca629a2f6
+29 -10
View File
@@ -8,9 +8,22 @@ describe 'completions'
end
after
" default
let g:jedi#popup_select_first = 1
bd!
end
it 'smart import'
exec "normal ifrom os "
Expect getline('.') == 'from os import '
end
it 'no smart import after space'
exec "normal! ifrom os "
exec "normal a "
Expect getline('.') == 'from os '
end
it 'import'
" X is the completion command
normal oimporX
@@ -26,26 +39,32 @@ describe 'completions'
Expect getline('.') == 'IndentationError().filename'
end
it 'dot_open'
normal oraisX ImpXErrX()
Expect getline('.') == 'raise ImportError()'
it 'multi complete'
normal oImpXErrX()
Expect getline('.') == 'ImportError()'
end
it 'cycling through entries'
" testing select_first doesn't seem to work in ex mode
execute "normal oraise impX\<C-n>\<C-n>\<C-n>"
Expect getline('.') == 'raise ImportWarning'
it 'cycling through entries popup_select_first=0'
let g:jedi#popup_select_first = 0
execute "normal oraise impX\<C-n>\<C-n>\<C-n>"
Expect getline('.') == 'raise ImportWarning'
let g:jedi#popup_select_first = 1
execute "normal oraise impX\<C-n>"
" It looks like this is currently not working properly.
"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
set completeopt -=longest
execute "normal oraise baseX"
Expect getline('.') == 'raise BaseException'
set completeopt +=longest
end
it 'dot_open'
end
end
+2 -2
View File
@@ -13,7 +13,7 @@ describe 'documentation docstrings'
it 'simple'
put = 'ImportError'
normal GK
Expect bufname('%') == "'__doc__'"
Expect bufname('%') == "__doc__"
Expect &filetype == 'rst'
let content = join(getline(1,'$'), "\n")
Expect stridx(content, "Import can't find module") > 0
@@ -23,7 +23,7 @@ describe 'documentation docstrings'
it 'no documentation'
put = 'x = 2'
normal G0K
normal o<ESC>GK
Expect bufname('%') == ''
end
end
+88 -47
View File
@@ -2,7 +2,7 @@ let mapleader = '\'
source plugin/jedi.vim
source test/utils.vim
describe 'goto_simple'
describe 'goto simple'
before
new " open a new split
set filetype=python
@@ -20,13 +20,13 @@ describe 'goto_simple'
bd!
end
it 'goto_definitions'
silent normal \d
it 'goto definitions'
normal \d
Expect line('.') == 1
"Expect col('.') == 5 " not working yet.
Expect col('.') == 5
end
it 'goto_assignments'
it 'goto assignments'
silent normal \g
Expect line('.') == 2
Expect col('.') == 1
@@ -45,9 +45,10 @@ describe 'goto_simple'
end
describe 'goto_with_tabs'
describe 'goto with tabs'
before
set filetype=python
let g:jedi#use_tabs_not_buffers = 1
end
after
@@ -55,7 +56,7 @@ describe 'goto_with_tabs'
bd!
end
it 'follow_import'
it 'follow import'
put = ['import subprocess', 'subprocess']
silent normal G\g
Expect getline('.') == 'import subprocess'
@@ -63,7 +64,7 @@ describe 'goto_with_tabs'
Expect col('.') == 8
silent normal G\d
Expect g:current_buffer_is_module('subprocess') == 1
Expect CurrentBufferIsModule('subprocess') == 1
Expect line('.') == 1
Expect col('.') == 1
Expect tabpagenr('$') == 2
@@ -72,27 +73,30 @@ describe 'goto_with_tabs'
Expect bufname('%') == ''
end
it 'multi_definitions'
put = ['import tokenize']
silent normal G$\d
Expect g:current_buffer_is_module('tokenize') == 0
Expect g:current_buffer_is_module('token') == 0
execute "normal \<CR>"
Expect tabpagenr('$') == 2
Expect winnr('$') == 1
Expect g:current_buffer_is_module('token') == 1
it 'multi definitions'
" This used to behave differently. Now we don't have any real multi
" definitions.
bd
silent normal G$\d
execute "normal j\<CR>"
Expect tabpagenr('$') == 2
Expect winnr('$') == 1
Expect g:current_buffer_is_module('tokenize') == 1
" put = ['import tokenize']
" silent normal G$\d
" Expect CurrentBufferIsModule('tokenize') == 1
" Expect CurrentBufferIsModule('token') == 0
" execute "normal \<CR>"
" Expect tabpagenr('$') == 2
" Expect winnr('$') == 1
" Expect CurrentBufferIsModule('token') == 1
" bd
" silent normal G$\d
" execute "normal j\<CR>"
" Expect tabpagenr('$') == 2
" Expect winnr('$') == 1
" Expect CurrentBufferIsModule('tokenize') == 1
end
end
describe 'goto_with_buffers'
describe 'goto with buffers'
before
set filetype=python
let g:jedi#use_tabs_not_buffers = 0
@@ -104,46 +108,46 @@ describe 'goto_with_buffers'
set nohidden
end
it 'no_new_tabs'
it 'no new tabs'
put = ['import os']
normal G$
call jedi#goto_assignments()
python jedi_vim.goto()
Expect g:current_buffer_is_module('os') == 0
PythonJedi jedi_vim.goto()
Expect CurrentBufferIsModule('os') == 0
" Without hidden, it's not possible to open a new buffer, when the old
" one is not saved.
set hidden
call jedi#goto_assignments()
Expect g:current_buffer_is_module('os') == 1
Expect CurrentBufferIsModule('os') == 1
Expect winnr('$') == 1
Expect tabpagenr('$') == 1
Expect line('.') == 1
Expect col('.') == 1
end
it 'multi_definitions'
set hidden
put = ['import tokenize']
silent normal G$\d
Expect g:current_buffer_is_module('tokenize') == 0
Expect g:current_buffer_is_module('token') == 0
execute "normal \<CR>"
Expect tabpagenr('$') == 1
Expect winnr('$') == 1
Expect g:current_buffer_is_module('token') == 1
it 'multi definitions'
" set hidden
" put = ['import tokenize']
" silent normal G$\d
" Expect CurrentBufferIsModule('tokenize') == 0
" Expect CurrentBufferIsModule('token') == 0
" execute "normal \<CR>"
" Expect tabpagenr('$') == 1
" Expect winnr('$') == 1
" Expect CurrentBufferIsModule('token') == 1
bd
silent normal G$\d
execute "normal j\<CR>"
Expect tabpagenr('$') == 1
Expect winnr('$') == 1
Expect g:current_buffer_is_module('tokenize') == 1
" bd
" silent normal G$\d
" execute "normal j\<CR>"
" Expect tabpagenr('$') == 1
" Expect winnr('$') == 1
" Expect CurrentBufferIsModule('tokenize') == 1
end
end
describe 'goto_with_splits'
describe 'goto with splits'
before
set filetype=python
let g:jedi#use_splits_not_buffers = 'left'
@@ -154,7 +158,7 @@ describe 'goto_with_splits'
bd!
end
it 'follow_import'
it 'follow import'
put = ['import subprocess', 'subprocess']
silent normal G\g
Expect getline('.') == 'import subprocess'
@@ -162,7 +166,7 @@ describe 'goto_with_splits'
Expect col('.') == 8
silent normal G\d
Expect g:current_buffer_is_module('subprocess') == 1
Expect CurrentBufferIsModule('subprocess') == 1
Expect line('.') == 1
Expect col('.') == 1
Expect winnr('$') == 2
@@ -173,4 +177,41 @@ describe 'goto_with_splits'
end
describe 'goto wildignore'
before
set filetype=python
set wildignore=*,with\ spaces,*.pyc
set hidden
let g:jedi#use_tag_stack = 1
let g:jedi#use_tabs_not_buffers = 0
" Need to use splits for code coverage in new_buffer()
let g:jedi#use_splits_not_buffers = 1
put = ['from subprocess import Popen', 'Popen']
Expect CurrentBufferIsModule('subprocess') == 0
silent normal G
end
after
bd!
bd!
set wildignore&vim
end
it 'restores wildignore'
let before = &wildignore
call jedi#goto()
Expect getline('.') =~ 'Popen'
Expect &wildignore == before
end
it 'not using tagstack'
let g:jedi#use_tag_stack = 0
call jedi#goto()
Expect CurrentBufferIsModule('subprocess') == 1
Expect getline('.') =~ 'Popen'
end
end
" vim: et:ts=4:sw=4
+12 -4
View File
@@ -2,6 +2,10 @@ source plugin/jedi.vim
source test/utils.vim
describe 'pyimport'
before
let g:jedi#use_tabs_not_buffers = 1
end
after
bd!
bd!
@@ -9,9 +13,9 @@ describe 'pyimport'
it 'open_tab'
Pyimport os
Expect g:current_buffer_is_module('os') == 1
Expect CurrentBufferIsModule('os') == 1
Pyimport subprocess
Expect g:current_buffer_is_module('subprocess') == 1
Expect CurrentBufferIsModule('subprocess') == 1
" the empty tab is sometimes also a tab
Expect tabpagenr('$') >= 2
end
@@ -19,10 +23,14 @@ describe 'pyimport'
it 'completion'
" don't know how to test this directly
"execute "Pyimport subproc\<Tab>"
"Expect g:current_buffer_is_module('subprocess') == 1
"Expect CurrentBufferIsModule('subprocess') == 1
Expect jedi#py_import_completions('subproc', 0, 0) == 'subprocess'
Expect jedi#py_import_completions('subprocess', 0, 0) == 'subprocess'
Expect jedi#py_import_completions('zip', 0, 0) == "zipfile\nzipimport"
let g:comp = jedi#py_import_completions('zip', 0, 0)
" Sometimes zipapp is in there sometimes not, depends on Python
" version.
let g:comp = substitute(g:comp, '^zipapp\n', '', '')
Expect g:comp == "zipfile\nzipimport"
end
end
+99 -5
View File
@@ -11,14 +11,41 @@ describe 'signatures'
end
it 'simple'
normal ostr(
normal odef xyz(number): return
normal o
normal oxyz(
normal G$
" equals doautocmd CursorMovedI
Python jedi_vim.show_call_signatures()
Expect getline(1) == 'jedi=0, (*obj*) ≡jedi'
Expect getline(3) == '?!?jedi=0, ?!? (*_*number*_*) ?!?jedi?!?'
doautocmd InsertLeave
Expect getline(1) == ''
Expect getline(3) == ''
end
it 'multiple buffers'
set hidden
new
setfiletype python
redir => autocmds
autocmd jedi_call_signatures * <buffer>
redir END
Expect autocmds =~# 'jedi_call_signatures'
buffer #
redir => autocmds
autocmd jedi_call_signatures * <buffer>
redir END
Expect autocmds =~# 'jedi_call_signatures'
bd!
end
it 'simple after CursorHoldI with only parenthesis'
noautocmd normal o
doautocmd CursorHoldI
noautocmd normal istr(
doautocmd CursorHoldI
Expect getline(1) == '?!?jedi=0, ?!? (*_*object*_*) ?!?jedi?!?'
end
it 'no signature'
@@ -28,12 +55,79 @@ describe 'signatures'
end
it 'signatures disabled'
let g:jedi#show_signatures = 0
let g:jedi#show_call_signatures = 0
normal ostr(
Python jedi_vim.show_call_signatures()
Expect getline(1, '$') == ['', 'str( ']
let g:jedi#show_signatures = 1
let g:jedi#show_call_signatures = 1
end
it 'command line simple'
let g:jedi#show_call_signatures = 2
call jedi#configure_call_signatures()
normal ostr(
redir => msg
Python jedi_vim.show_call_signatures()
redir END
Expect msg == "\nstr(object)"
redir => msg
doautocmd InsertLeave
redir END
Expect msg == "\n"
normal Sdef foo(a, b): pass
normal ofoo(a, b, c,
redir => msg
Python jedi_vim.show_call_signatures()
redir END
Expect msg == "\nfoo(a, b)"
end
it 'command line truncation'
let g:jedi#show_call_signatures = 2
call jedi#configure_call_signatures()
function! Signature()
redir => msg
Python jedi_vim.show_call_signatures()
redir END
return msg
endfunction
let funcname = repeat('a', &columns - 30)
put = 'def '.funcname.'(arg1, arg2, arg3, a, b, c):'
put = ' pass'
execute "normal o".funcname."( "
Expect Signature() == "\n".funcname."(arg1, …)"
normal sarg1,
Expect Signature() == "\n".funcname."(…, arg2, …)"
normal sarg2, arg3,
Expect Signature() == "\n".funcname."(…, a, b, c)"
normal sa, b,
Expect Signature() == "\n".funcname."(…, c)"
g/^/d
put = 'def '.funcname.'('.repeat('b', 20).', arg2):'
put = ' pass'
execute "normal o".funcname."( "
Expect Signature() == "\n".funcname."(…)"
end
it 'command line no signature'
let g:jedi#show_call_signatures = 2
call jedi#configure_call_signatures()
normal ostr
redir => msg
Python jedi_vim.show_call_signatures()
redir END
Expect msg == "\n"
end
end
+3 -3
View File
@@ -1,9 +1,9 @@
function! g:current_buffer_is_module(module_name)
return g:ends_with(bufname('%'), a:module_name.'.py')
function! CurrentBufferIsModule(module_name)
return EndsWith(bufname('%'), a:module_name.'.py')
endfunction
function g:ends_with(string, end)
function EndsWith(string, end)
let l:should = len(a:string) - strlen(a:end)
return l:should == stridx(a:string, a:end, should)
endfunction