65 Commits

Author SHA1 Message Date
Andrey Butirsky
eebf7d2863 README.rst: fix indentation (#1142)
Some checks failed
ci / tests (push) Has been cancelled
2025-12-03 16:09:15 +00:00
Roman Nikonov
c3f9b751f3 fix Arch package page URL (#1141)
Some checks failed
ci / tests (push) Has been cancelled
2025-09-19 11:49:35 +00:00
jgb
9679051ad4 update parso to v0.8.5 - Merge pull request #1140 from jgb/master
Some checks failed
ci / tests (push) Has been cancelled
2025-08-27 22:53:32 +00:00
Dave Halter
0efafede57 Merge pull request #1139 from davidhalter/ci
Some checks failed
ci / tests (push) Has been cancelled
Ci fixes
2025-08-25 11:53:49 +00:00
Dave Halter
7c331a1b64 Remove the code-quality check at least for now 2025-08-25 13:51:29 +02:00
Dave Halter
f4e0dbc183 Upgrade to an Ubuntu 24.04 runner 2025-08-25 13:49:21 +02:00
Dave Halter
344814c214 Merge pull request #1131 from davidhalter/ci
Some checks failed
ci / tests (push) Has been cancelled
ci / code-quality (push) Has been cancelled
CI Fixes
2024-12-27 22:17:19 +00:00
Dave Halter
a06395549f Upgrade to actions/checkout@v4 2024-12-27 23:16:07 +01:00
Dave Halter
9c2f9c63d3 Remove coverage for now 2024-12-27 23:12:06 +01:00
Dave Halter
382d8a48d0 Remove a test that failed for no apparent reason 2024-12-27 23:10:27 +01:00
Jan Geboers
4ad1f2fc3d update jedi to v0.19.2 and parso to v0.8.4 2024-12-27 11:23:28 +01:00
Dave Halter
130ce7fb79 Merge pull request #1124 from adamency/master
Add Neovim Installation Requirements
2024-07-06 15:05:52 +00:00
Benjamin Habié
907b6837a9 Add Neovim Installation Requirements 2024-07-06 16:59:39 +02:00
Dave Halter
9bd79ee41a Merge pull request #1117 from dundargoc/checkhealth
Replace deprecated checkhealth syntax with newer syntax
2023-12-30 00:15:14 +00:00
dundargoc
2c188fea29 Replace deprecated checkhealth syntax with newer syntax 2023-12-27 17:03:48 +01:00
Dave Halter
b82da7d2b5 Merge pull request #1115 from jgb/master
update jedi to v0.19.1
2023-10-09 17:19:17 +00:00
Jan Geboers
c87947e760 update jedi to v0.19.1 2023-10-09 11:18:00 +02:00
Dave Halter
338af171ea Merge pull request #1112 from jgb/master
update jedi to v0.19.0
2023-07-31 22:39:54 +00:00
Jan Geboers
c0c01ede07 update jedi to v0.19.0 2023-07-31 10:12:14 +02:00
Dave Halter
42c2af1812 Merge pull request #1106 from jgb/master
update jedi to v0.18.2
2023-04-11 15:55:50 +00:00
Jan Geboers
1198e4cfa3 update jedi to v0.18.2 2023-04-11 10:27:08 +02:00
Dave Halter
c5d5d2e3b4 Merge pull request #1105 from hawkins/patch-1
Remove mention of Python 2.7 support in installation instructions
2023-04-10 21:25:51 +00:00
Josh Hawkins
0d245f3287 Remove mention of Python 2.7 support in installation instructions 2023-04-10 14:13:51 -04:00
Dave Halter
be483a2dcb Merge pull request #1097 from jamescherti/rename-that-do-not-delete-word
Add a keyboard mapping to rename  variables/functions/classes without deleting the word under the cursor
2022-12-28 19:46:41 +00:00
James Cherti
f286f9e4b6 Key mapping <Leader>R: Rename vars/functions/classes without deleting the word under the cursor
This pull request also adds the support for 'set selection=exclusive' to
the function 'rename_visual()' (bug fix).

'<Leader>R' in Normal mode:
---------------------------
Jedi-vim keeps the word under the cursor, moves the cursor to the end of the
word, and puts Vim in insert mode, where the user is expected to enter the
new variable name.

'<Leader>R' in Visual mode:
---------------------------
Use the selected text as the default answer to the prompt.
2022-12-26 13:43:42 -05:00
Dave Halter
e073385976 Merge pull request #1088 from Jakuje/patch-1
Update link to Fedora package
2022-12-24 23:40:23 +00:00
Dave Halter
6b8013c480 Merge pull request #1095 from Konfekt/popup
fix typo
2022-11-23 09:11:09 +00:00
Konfekt
c381156dd4 fix typo 2022-11-23 08:23:42 +01:00
Dave Halter
28a6765ecc Merge pull request #1093 from Konfekt/popup
prefer popup over preview window
2022-11-21 22:50:46 +00:00
Konfekt
df261c0a3e remove slash to pass check for code quality 2022-11-12 10:32:44 +01:00
Konfekt
40c7f6d09d split code line to pass check for line length 2022-11-11 10:29:45 +01:00
Konfekt
8c7161f4e9 prefer popup over preview window 2022-11-10 15:55:13 +01:00
Jakub Jelen
27db7160a5 Update link to Fedora packages 2022-05-30 20:27:13 +02:00
Dave Halter
e82d07faa1 Merge pull request #1082 from jamescherti/buffer_jedi_added_sys_path
Add the buffer-local option 'b:jedi_added_sys_path'
2022-04-08 15:07:48 +02:00
James Cherti
50dfac448a Add 'g:jedi#added_sys_path' and 'b:jedi_added_sys_path' to the cache (cache_key). 2022-04-05 15:59:09 -04:00
James Cherti
0a27795d76 Add the buffer-local option 'b:jedi_added_sys_path' (to add additional sys_path). 2022-04-05 13:04:19 -04:00
Dave Halter
32d05f7742 Merge pull request #1076 from jamescherti/case-insensitive
Add option to enable/disable case insensitive completion
2022-01-30 12:33:41 +01:00
James Cherti
873ee9325d Add an option to enable/disable case insensitive completion.
Options:
- Global option: g:jedi#case_insensitive_completion
- Buffer-local option: b:jedi_case_insensitive_completion

Values:
- 0 to disable case insensitive completion.
- 1 to enable case insensitive completion (default).
2022-01-29 17:54:33 -05:00
Dave Halter
08ad42efed Merge pull request #1074 from blueyed/bump-parso
Update parso submodule to 0.8.3 (from 0.8.2)
2022-01-17 19:26:34 +01:00
Dave Halter
f5aad68bec Merge pull request #1073 from blueyed/fixup-1059
get_project: simplify getting b:jedi_environment_path override
2022-01-17 19:22:23 +01:00
Daniel Hahler
2c99d7377f Update submodule pythonx/parso 5edab04...ee5edaf
* pythonx/parso 5edab04...ee5edaf (13):
      > Prepare Release 0.8.3
      > Add a Python 3.12 grammar, because that is probably going to be needed in a year from now
      > Merge pull request #199 from sobolevn/patch-1
      > Merge pull request #195 from sturmianseq/fix
      > Jedi still has an import dependency on search_ancestor
      > Merge pull request #194 from mgorny/python310
      > Merge pull request #188 from davidhalter/line-ending
      > Fix flaky test_cache_last_used_update again (#189)
      > Add `NodeOrLeaf.dump()` and `NodeOrLeaf.search_ancestor()` (#187)
      > Add a grammar for Python 3.11 (just copied 3.10), so the core devs can work with it
      > Relax a test regex to match new enum repr in Python 3.10.0a7+ (#186)
      > Merge pull request #185 from davidhalter/switch-to-github-actions
      > Merge pull request #184 from davidhalter/remove-nocond-39
2022-01-17 17:21:36 +01:00
Daniel Hahler
7d2fc14f4f get_project: simplify getting b:jedi_environment_path override
- the common case is having an exception here (with no buffer setting),
  which results in the exception handler always
- vim_eval has overhead, especially with Neovim, so the less calls the
  better

This patch changes it to query the `b:` dict, using the (always
set/initialized) global setting as the default.
2022-01-17 14:56:29 +01:00
Dave Halter
e1afc904e4 Merge pull request #1072 from ThomasBlauth/default_setting
Fix added_sys_path default setting
2022-01-17 09:23:57 +01:00
Thomas Blauth
64c92771be Fix added_sys_path default setting
This commit removes the inner string quotation of the default value for the
added_sys_path setting. The inner quotes cause the value of the resulting
variable g:jedi#added_sys_path to be the sting "[]" instead of an empty list.
2022-01-17 08:40:54 +01:00
Dave Halter
030211555d Merge pull request #1068 from jgb/master
Update jedi to v0.18.1 and parso to v0.8.2
2021-11-17 22:33:56 +01:00
Jan Geboers
ab2550ef29 Update jedi to v0.18.1 and parso to v0.8.2 2021-11-17 15:45:26 +01:00
Volodymyr Kozachynskyi
7ac81cb880 doc: Add hint about python 2 support (#1060)
* doc: Add hint about python 2 support

* Update README.rst

Co-authored-by: Dave Halter <davidhalter88@gmail.com>
2021-06-22 22:45:23 +02:00
Dave Halter
6812ce11b7 Merge pull request #1059 from jamescherti/buffer_jedi_environment_path
The buffer-local variable `b:jedi_environment_path`
2021-06-22 21:34:08 +02:00
James Cherti
81002ed6e7 This commit fixes the exception: jedi_vim.VimError: Vim(let):E121: Undefined variable: b:jedi_environment_path; created by 'b:jedi_environment_path' 2021-06-22 13:42:11 -04:00
James Cherti
81e1e9ca34 The buffer-local variable b:jedi_environment_path was added to override the global variable g:jedi#environment_path. 2021-06-21 14:58:57 -04:00
Dave Halter
8763462331 Merge pull request #1049 from SeungChan92/master
Add missing item in manual index
2021-03-17 23:32:13 +01:00
Seung-Chan Ahn
760120240f Add missing item in manual index 2021-03-17 09:59:43 +09:00
Dave Halter
6e6738758f Merge pull request #1048 from SeungChan92/master
Support adding extra sys_path
2021-03-16 23:38:49 +01:00
Seung-Chan Ahn
ff9a0afbda Support adding extra sys_path 2021-03-15 14:36:20 +09:00
Dave Halter
088469a8ee Merge pull request #1045 from Konstantin-Glukhov/master
Use helper function relpath() instead of os.path.relpath()
2021-02-26 11:18:52 +01:00
Konstantin-Glukhov
8730095b89 Use helper function relpath() instead of os.path.relpath() to address
issue #1044 ("path is on mount %r, start on mount %r" exception thrown
on Windows if Python and jedi-vim are installed on different drives)
2021-02-16 04:25:02 +09:00
Dave Halter
5d4615707f Fix a refactoring error, fixes #1041 2021-01-30 15:38:01 +01:00
Dave Halter
960eaa8053 Typo
Co-authored-by: Daniel Hahler <git@thequod.de>
2021-01-03 03:06:44 +01:00
Dave Halter
acd9182131 Fix some comments in signature test 2021-01-03 03:06:44 +01:00
Dave Halter
04c708cbfc Useful examples for environment_path 2021-01-03 03:06:44 +01:00
Dave Halter
91312f1755 Run CI on pull requests 2021-01-03 03:06:44 +01:00
Dave Halter
e02fa9dc10 Upgrade Jedi to 8ef2ce232cebf6f30b41b28b2677d84666a97d55 2021-01-03 03:06:44 +01:00
Dave Halter
d7be014c54 Namespaces cannot be shown properly, fixes #815
This only works with Jedi commit 2ec3d72151d1072fa22861aef07ba6fc170e3781
Once using that commit, namespaces will be used properly.
2021-01-02 12:15:25 +01:00
Dave Halter
e96eba9f53 Use relative paths when accessing a buffer 2021-01-02 04:05:46 +01:00
Dave Halter
e4daf7a74c Fix a test around signatures that was failing sometimes 2021-01-02 04:05:24 +01:00
13 changed files with 204 additions and 120 deletions

View File

@@ -1,12 +1,12 @@
name: ci
on: push
on: [push, pull_request]
jobs:
tests:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
submodules: recursive
@@ -20,44 +20,3 @@ jobs:
- name: Run tests
run: 'make test'
code-quality:
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
submodules: recursive
- name: Run tests
run: |
vim --version
make check
coverage:
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
submodules: recursive
- name: Install dependencies
run: |
sudo add-apt-repository ppa:neovim-ppa/stable -y
sudo apt-get update -q
sudo apt-get install neovim -y
sudo pip install pynvim pytest-cov
sudo pip list
nvim --version
- name: Run tests
run: |
make --keep-going test_coverage BUILD_VIRTUAL_ENV=$VIRTUAL_ENV
- name: Upload coverage data
run: |
coverage xml
bash <(curl -s https://codecov.io/bash) -X fix -f coverage.xml -F py${TRAVIS_PYTHON_VERSION//./}

View File

@@ -53,5 +53,9 @@ Tommy Allen (@tweekmonster)
Mingliang (@Aulddays)
Brian Mego (@brianmego)
Stevan Milic (@stevanmilic) <stevan.milic@yahoo.com>
Konstantin Glukhov (@Konstantin-Glukhov)
Seungchan An (@SeungChan92) <dev.issea1015@gmail.com>
Thomas Blauth (@ThomasBlauth) <thomas.blauth@protonmail.com>
James Cherti (@jamescherti)
@something are github user names.

View File

@@ -73,9 +73,15 @@ Installation
Requirements
------------
You need a VIM version that was compiled with Python 2.7 or later
(``+python`` or ``+python3``). You can check this from within VIM using
``:python3 import sys; print(sys.version)`` (use ``:python`` for Python 2).
- **Vim**: You need a VIM version that was compiled with Python 3 or later
(``+python3``). You can check this from within VIM using
``:python3 import sys; print(sys.version)``.
- **Neovim**: You need a python environment with ``pynvim`` installed:
``pip install pynvim``
then check your environment is correctly setup from within Neovim using
``:checkhealth provider.python``
Manual installation
-------------------
@@ -108,13 +114,13 @@ 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/>`__.
`vim-jedi <https://archlinux.org/packages/extra/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>`__.
`vim-jedi <https://packages.fedoraproject.org/pkgs/vim-jedi/vim-jedi/>`__.
Please note that this version might be quite old compared to using jedi-vim
from Git.
@@ -207,12 +213,20 @@ get more information. If you set them to ``""``, they are not assigned.
let g:jedi#usages_command = "<leader>n"
let g:jedi#completions_command = "<C-Space>"
let g:jedi#rename_command = "<leader>r"
let g:jedi#rename_command_keep_name = "<leader>R"
A few examples of setting up your project:
An example for setting up your project:
.. code-block:: vim
let g:jedi#environment_path = "<leader>d"
let g:jedi#environment_path = "/usr/bin/python3.9"
jedi-vim tries its best to guess your virtual env. If you want to work with a
specific virtual environment however, you can point jedi-vim towards it:
.. code-block:: vim
let g:jedi#environment_path = "venv"
Finally, if you don't want completion, but all the other features, use:
@@ -223,6 +237,12 @@ Finally, if you don't want completion, but all the other features, use:
FAQ
===
I want to use Jedi with a Python 2 Environment, but it's not listed under "Known environments"
----------------------------------------------------------------------------------------------
Starting with version 0.18.0 Jedi dropped support for Python 2.
I don't want the docstring window to popup during completion
------------------------------------------------------------

View File

@@ -1,4 +1,4 @@
function! health#jedi#check() abort
call health#report_start('jedi')
call v:lua.vim.health.start('jedi')
silent call jedi#debug_info()
endfunction

View File

@@ -24,6 +24,7 @@ let s:default_settings = {
\ 'call_signatures_command': "'<leader>n'",
\ 'usages_command': "'<leader>n'",
\ 'rename_command': "'<leader>r'",
\ 'rename_command_keep_name': "'<leader>R'",
\ 'completions_enabled': 1,
\ 'popup_on_dot': 'g:jedi#completions_enabled',
\ 'documentation_command': "'K'",
@@ -36,8 +37,10 @@ let s:default_settings = {
\ 'quickfix_window_height': 10,
\ 'force_py_version': "'auto'",
\ 'environment_path': "'auto'",
\ 'added_sys_path': '[]',
\ 'project_path': "'auto'",
\ 'smart_auto_mappings': 0,
\ 'case_insensitive_completion': 1,
\ 'use_tag_stack': 1
\ }
@@ -368,6 +371,14 @@ function! jedi#rename_visual(...) abort
python3 jedi_vim.rename_visual()
endfunction
function! jedi#rename_keep_name(...) abort
python3 jedi_vim.rename(delete_word=False)
endfunction
function! jedi#rename_visual_keep_name(...) abort
python3 jedi_vim.rename_visual(use_selected_text_as_prompt_answer=True)
endfunction
function! jedi#completions(findstart, base) abort
python3 jedi_vim.completions()
endfunction
@@ -506,7 +517,7 @@ function! jedi#goto_window_on_enter() abort
if l:data.bufnr
" close goto_window buffer
normal! ZQ
python3 jedi_vim.new_buffer(vim.eval('bufname(l:data.bufnr)'))
python3 jedi_vim.set_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

View File

@@ -27,8 +27,9 @@ Contents *jedi-vim-contents*
5.4 Go to stub |g:jedi#goto_stubs_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|
5.7. Rename variables (Reuse name) |g:jedi#rename_command_keep_name|
5.8. Show name usages |g:jedi#usages_command|
5.9. 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|
@@ -45,6 +46,11 @@ Contents *jedi-vim-contents*
6.13. smart_auto_mappings |g:jedi#smart_auto_mappings|
6.14. use_tag_stack |g:jedi#use_tag_stack|
6.15. environment_path |g:jedi#environment_path|
|b:jedi_environment_path|
6.16. added_sys_path |g:jedi#added_sys_path|
|b:jedi_added_sys_path|
6.17. case_insensitive_completion |g:jedi#case_insensitive_completion|
|b:jedi_case_insensitive_completion|
7. Testing |jedi-vim-testing|
8. Contributing |jedi-vim-contributing|
9. License |jedi-vim-license|
@@ -302,7 +308,19 @@ with the new one. The number of performed renames is displayed in the command
line.
------------------------------------------------------------------------------
5.7. `g:jedi#usages_command` *g:jedi#usages_command*
5.7. `g:jedi#rename_command_keep_name` *g:jedi#rename_command_keep_name*
Function: `jedi#rename()`
Default: <leader>R Rename variables
(This key mapping does not delete the word under the cursor)
Jedi-vim keeps the word currently under the cursor, moves the cursor to the end
of the word, and puts Vim in insert mode, where the user is expected to enter
the new variable name. Upon leaving insert mode, Jedi-vim then renames all
occurrences of the old variable name with the new one. The number of performed
renames is displayed in the command line.
------------------------------------------------------------------------------
5.8. `g:jedi#usages_command` *g:jedi#usages_command*
Function: `jedi#usages()`
Default: <leader>n Show usages of a name.
@@ -310,7 +328,7 @@ The quickfix window is populated with a list of all names which point to the
definition of the name under the cursor.
------------------------------------------------------------------------------
5.8. Open module by name *:Pyimport*
5.9. Open module by name *:Pyimport*
Function: `jedi#py_import(args)`
Default: :Pyimport e.g. `:Pyimport os` shows os.py in VIM.
@@ -344,7 +362,8 @@ 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, if
Jedi-vim sets 'completeopt' to `menuone,longest` and `popup` (for Vim version
numbers higher than 8.1.1882) respectively `preview` by default, if
'completeopt' is not changed from Vim's default.
It also remaps <Ctrl-C> to <Esc> in insert mode.
@@ -383,13 +402,15 @@ Default: 1 (Automatically select first completion entry)
------------------------------------------------------------------------------
6.5. `g:jedi#auto_close_doc` *g:jedi#auto_close_doc*
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
When doing completion and jedi-vim shows the docstring of the currently selected
item in a preview (not a popup) window, this window is being closed after
insertion of a completion item.
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.
This setting is ignored if a popup instead of a preview window is used.
Options: 0 or 1
Default: 1 (Automatically close preview window upon leaving insert mode)
@@ -509,6 +530,7 @@ Default: 1 (enabled by default)
------------------------------------------------------------------------------
6.15. `g:jedi#environment_path` *g:jedi#environment_path*
*b:jedi_environment_path*
To use a specific virtualenv or a specific Python version it is possible to
set an interpreter.
@@ -516,8 +538,36 @@ set an interpreter.
Both setting the directory and setting a project is working.
Examples: "/usr/bin/python3.9", "venv", "../venv", "../venv/bin/python"
The buffer-local variable `b:jedi_environment_path` can be used to override the
global variable `g:jedi#environment_path`.
Default: "auto"
------------------------------------------------------------------------------
6.16. `g:jedi#added_sys_path` *g:jedi#added_sys_path*
*b:jedi_added_sys_path*
To add extra sys_path.
The buffer-local variable `b:jedi_added_sys_path` can be used to add
additional extra sys_path.
Examples: ["../site-packages"]
Default: []
------------------------------------------------------------------------------
6.17. `g:jedi#case_insensitive_completion` *g:jedi#case_insensitive_completion*
*b:jedi_case_insensitive_completion*
0 to disable case insensitive completion.
1 to enable case insensitive completion (default).
The buffer-local variable `b:jedi_case_insensitive_completion` can be used to
override the global variable `g:jedi#case_insensitive_completion`.
Default: 1
==============================================================================
7. Testing *jedi-vim-testing*

View File

@@ -27,6 +27,10 @@ if g:jedi#auto_initialization
execute 'nnoremap <buffer> '.g:jedi#rename_command.' :call jedi#rename()<CR>'
execute 'vnoremap <buffer> '.g:jedi#rename_command.' :call jedi#rename_visual()<CR>'
endif
if len(g:jedi#rename_command_keep_name)
execute 'nnoremap <buffer> '.g:jedi#rename_command_keep_name.' :call jedi#rename_keep_name()<CR>'
execute 'vnoremap <buffer> '.g:jedi#rename_command_keep_name.' :call jedi#rename_visual_keep_name()<CR>'
endif
" documentation/pydoc
if len(g:jedi#documentation_command)
execute 'nnoremap <silent> <buffer>'.g:jedi#documentation_command.' :call jedi#show_documentation()<CR>'
@@ -44,10 +48,15 @@ if g:jedi#auto_initialization
inoremap <silent> <buffer> <space> <C-R>=jedi#smart_auto_mappings()<CR>
end
if g:jedi#auto_close_doc
if g:jedi#auto_close_doc && (&g:completeopt =~# '\<preview\>' && &g:completeopt !~# '\<popup\>')
" close preview if its still open after insert
augroup jedi_preview
autocmd! InsertLeave <buffer> if pumvisible() == 0|pclose|endif
if v:version > 704
autocmd CompleteDone <buffer> pclose
else
autocmd InsertLeave <buffer> if pumvisible() == 0|pclose|endif
autocmd CursorMovedI <buffer> if pumvisible() == 0|pclose|endif
endif
augroup END
endif
endif

View File

@@ -33,7 +33,12 @@ if get(g:, 'jedi#auto_vim_configuration', 1)
redir END
endif
if len(split(completeopt, '\n')) == 1
set completeopt=menuone,longest,preview
set completeopt=menuone,longest
if v:version > 801 || (v:version == 801 && has('patch-8.1.1882'))
set completeopt+=popup
else
set completeopt+=preview
endif
endif
endfunction
if has('nvim')

View File

@@ -4,12 +4,14 @@ The Python parts of the Jedi library for VIM. It is mostly about communicating
with VIM.
"""
from typing import Optional
import traceback # for exception output
import re
import os
import sys
from shlex import split as shsplit
from contextlib import contextmanager
from pathlib import Path
try:
from itertools import zip_longest
except ImportError:
@@ -216,11 +218,18 @@ _current_project_cache = None, None
def get_project():
vim_environment_path = vim_eval("g:jedi#environment_path")
vim_environment_path = vim_eval(
"get(b:, 'jedi_environment_path', g:jedi#environment_path)"
)
vim_project_path = vim_eval("g:jedi#project_path")
vim_added_sys_path = vim_eval("get(g:, 'jedi#added_sys_path', [])")
vim_added_sys_path += vim_eval("get(b:, 'jedi_added_sys_path', [])")
global _current_project_cache
cache_key = dict(project_path=vim_project_path, environment_path=vim_environment_path)
cache_key = dict(project_path=vim_project_path,
environment_path=vim_environment_path,
added_sys_path=vim_added_sys_path)
if cache_key == _current_project_cache[0]:
return _current_project_cache[1]
@@ -234,7 +243,9 @@ def get_project():
else:
project_path = vim_project_path
project = jedi.Project(project_path, environment_path=environment_path)
project = jedi.Project(project_path,
environment_path=environment_path,
added_sys_path=vim_added_sys_path)
_current_project_cache = cache_key, project
return project
@@ -283,7 +294,9 @@ def load_project():
project.save()
global _current_project_cache
cache_key = dict(project_path=path, environment_path=env_path)
cache_key = dict(project_path=path,
environment_path=env_path,
added_sys_path=[])
_current_project_cache = cache_key, project
@@ -314,6 +327,10 @@ def get_pos(column=None):
@_check_jedi_availability(show_error=False)
@catch_and_print_exceptions
def completions():
jedi.settings.case_insensitive_completion = \
bool(int(vim_eval("get(b:, 'jedi_case_insensitive_completion', "
"g:jedi#case_insensitive_completion)")))
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.
@@ -343,7 +360,9 @@ def completions():
completions = script.complete(*get_pos(column))
signatures = script.get_signatures(*get_pos(column))
add_info = "preview" in vim.eval("&completeopt").split(",")
add_info = \
any(option in vim.eval("&completeopt").split(",")
for option in ("preview", "popup"))
out = []
for c in completions:
d = dict(word=PythonToVimStr(c.name[:len(base)] + c.complete),
@@ -418,21 +437,22 @@ def _goto_specific_name(n, options=''):
if n.is_keyword:
echo_highlight("Cannot get the definition of Python keywords.")
else:
echo_highlight("Builtin modules cannot be displayed (%s)."
% (n.full_name or n.name))
name = 'Namespaces' if n.type == 'namespace' else 'Builtin modules'
echo_highlight(
"%s cannot be displayed (%s)."
% (name, n.full_name or n.name)
)
else:
using_tagstack = int(vim_eval('g:jedi#use_tag_stack')) == 1
module_path = str(n.module_path or '')
if module_path != vim.current.buffer.name:
result = new_buffer(module_path, options=options,
result = set_buffer(n.module_path, options=options,
using_tagstack=using_tagstack)
if not result:
return []
if (using_tagstack and module_path and
os.path.exists(module_path)):
if (using_tagstack and n.module_path and
n.module_path.exists()):
tagname = n.name
with tempfile('{0}\t{1}\t{2}'.format(
tagname, module_path, 'call cursor({0}, {1})'.format(
tagname, n.module_path, 'call cursor({0}, {1})'.format(
n.line, n.column + 1))) as f:
old_tags = vim.eval('&tags')
old_wildignore = vim.eval('&wildignore')
@@ -978,7 +998,7 @@ def cmdline_call_signatures(signatures):
@_check_jedi_availability(show_error=True)
@catch_and_print_exceptions
def rename():
def rename(delete_word=True):
if not int(vim.eval('a:0')):
# Need to save the cursor position before insert mode
cursor = vim.current.window.cursor
@@ -990,7 +1010,12 @@ def rename():
vim_command("let s:jedi_replace_orig = expand('<cword>')")
line = vim_eval('getline(".")')
if delete_word:
vim_command('normal! diw')
else:
vim_command('normal! yiwel')
if re.match(r'\w+$', line[cursor[1]:]):
# In case the deleted word is at the end of the line we need to
# move the cursor to the end.
@@ -1022,9 +1047,17 @@ def rename():
return do_rename(replace)
def rename_visual():
replace = vim.eval('input("Rename to: ")')
orig = vim.eval('getline(".")[(getpos("\'<")[2]-1):getpos("\'>")[2]]')
def rename_visual(use_selected_text_as_prompt_answer=False):
orig = vim.eval('getline(".")[(getpos("\'<")[2]-1):getpos("\'>")[2]'
'-((&selection ==# "exclusive") ? 2 : 1)]')
input_text = ""
if use_selected_text_as_prompt_answer:
input_text = orig
replace = vim.eval(
'input("Rename to:", "{}")'.format(PythonToVimStr(input_text))
)
do_rename(replace, orig)
@@ -1036,6 +1069,10 @@ def do_rename(replace, orig=None):
if orig is None:
orig = vim_eval('s:jedi_replace_orig')
if orig == replace:
echo_highlight('Jedi did 0 renames.')
return
# Save original window / tab.
saved_tab = int(vim_eval('tabpagenr()'))
saved_win = int(vim_eval('winnr()'))
@@ -1050,13 +1087,9 @@ def do_rename(replace, orig=None):
if r.in_builtin_module():
continue
module_path = r.module_path
if os.path.abspath(vim.current.buffer.name) != str(module_path):
assert module_path is not None
result = new_buffer(module_path)
result = set_buffer(r.module_path)
if not result:
echo_highlight('Failed to create buffer window for %s!' % (
module_path))
echo_highlight('Failed to create buffer window for %s!' % (r.module_path))
continue
buffers.add(vim.current.buffer.name)
@@ -1103,7 +1136,17 @@ def py_import_completions():
@catch_and_print_exceptions
def new_buffer(path, options='', using_tagstack=False):
def set_buffer(path: Optional[Path], options='', using_tagstack=False):
"""
Opens a new buffer if we have to or does nothing. Returns True in case of
success.
"""
path = str(path or '')
# Check both, because it might be an empty string
if path in (vim.current.buffer.name, os.path.abspath(vim.current.buffer.name)):
return True
path = relpath(path)
# options are what you can to edit the edit options
if int(vim_eval('g:jedi#use_tabs_not_buffers')) == 1:
_tabnew(path, options)
@@ -1151,7 +1194,6 @@ def _tabnew(path, options=''):
: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
@@ -1166,7 +1208,7 @@ def _tabnew(path, options=''):
# don't know why this happens :-)
pass
else:
if buf_path == path:
if os.path.abspath(buf_path) == os.path.abspath(path):
# tab exists, just switch to that tab
vim_command('tabfirst | tabnext %i' % (tab_nr + 1))
# Goto the buffer's window.

View File

@@ -52,19 +52,6 @@ describe 'completions'
Expect getline('.') == 'IndentationError().filename'
end
it 'multi complete'
" NOTE: nvim results in "importErr()" here with completeopt+=longest,
" but Vim is fine.
" This is due to `pumvisible()` in jedi#complete_opened being true
" with nvim still, but it is 0 with Vim, i.e. Vim appears to close
" the pum already (with the tests).
"
" This might be a misunderstanding though, since the test might not
" expect the "import" keyword to be offered for completion?!
normal oImpXErrX()
Expect getline('.') == 'ImportError()'
end
it 'cycling through entries popup_select_first=0'
set completeopt+=longest
let g:jedi#popup_select_first = 0

View File

@@ -47,18 +47,15 @@ describe 'signatures'
it 'highlights correct argument'
noautocmd normal o
doautocmd CursorHoldI
noautocmd normal iprint(42, sep="X", )
" Move to "=" - hightlights "sep=...".
noautocmd normal 5h
noautocmd normal iformat(42, "x")
" Move to x - highlights "x".
noautocmd normal 2h
doautocmd CursorHoldI
Expect getline(1) =~# '\V\^?!?jedi=0, ?!? (*values: object, *_*sep: Optional[Text]=...*_*'
" Move left to "=" - hightlights first argument ("values").
" NOTE: it is arguable that maybe "sep=..." should be highlighted
" still, but this tests for the cache to be "busted", and that
" fresh results are retrieved from Jedi.
noautocmd normal h
Expect getline(1) == '?!?jedi=0, ?!? (value: object, *_*format_spec: str=...*_*) ?!?jedi?!?'
" Move left to 42 - hightlights first argument ("value").
noautocmd normal 4h
doautocmd CursorHoldI
Expect getline(1) =~# '\V\^?!?jedi=0, ?!? (*_**values: object*_*, sep: Optional[Text]=...,'
Expect getline(1) == '?!?jedi=0, ?!? (*_*value: object*_*, format_spec: str=...) ?!?jedi?!?'
end
it 'no signature'