forked from VimPlug/jedi-vim
Compare commits
36 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
28a6765ecc | ||
|
|
df261c0a3e | ||
|
|
40c7f6d09d | ||
|
|
8c7161f4e9 | ||
|
|
e82d07faa1 | ||
|
|
50dfac448a | ||
|
|
0a27795d76 | ||
|
|
32d05f7742 | ||
|
|
873ee9325d | ||
|
|
08ad42efed | ||
|
|
f5aad68bec | ||
|
|
2c99d7377f | ||
|
|
7d2fc14f4f | ||
|
|
e1afc904e4 | ||
|
|
64c92771be | ||
|
|
030211555d | ||
|
|
ab2550ef29 | ||
|
|
7ac81cb880 | ||
|
|
6812ce11b7 | ||
|
|
81002ed6e7 | ||
|
|
81e1e9ca34 | ||
|
|
8763462331 | ||
|
|
760120240f | ||
|
|
6e6738758f | ||
|
|
ff9a0afbda | ||
|
|
088469a8ee | ||
|
|
8730095b89 | ||
|
|
5d4615707f | ||
|
|
960eaa8053 | ||
|
|
acd9182131 | ||
|
|
04c708cbfc | ||
|
|
91312f1755 | ||
|
|
e02fa9dc10 | ||
|
|
d7be014c54 | ||
|
|
e96eba9f53 | ||
|
|
e4daf7a74c |
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@@ -1,5 +1,5 @@
|
||||
name: ci
|
||||
on: push
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
tests:
|
||||
|
||||
@@ -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.
|
||||
|
||||
17
README.rst
17
README.rst
@@ -208,11 +208,18 @@ get more information. If you set them to ``""``, they are not assigned.
|
||||
let g:jedi#completions_command = "<C-Space>"
|
||||
let g:jedi#rename_command = "<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 +230,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
|
||||
------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -36,8 +36,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
|
||||
\ }
|
||||
|
||||
@@ -506,7 +508,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
|
||||
|
||||
@@ -45,6 +45,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|
|
||||
@@ -344,7 +349,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 +389,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 +517,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 +525,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*
|
||||
|
||||
|
||||
@@ -44,10 +44,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
|
||||
|
||||
@@ -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')
|
||||
|
||||
Submodule pythonx/jedi updated: 4b5b2e791b...fae26fa7a4
@@ -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,
|
||||
using_tagstack=using_tagstack)
|
||||
if not result:
|
||||
return []
|
||||
if (using_tagstack and module_path and
|
||||
os.path.exists(module_path)):
|
||||
result = set_buffer(n.module_path, options=options,
|
||||
using_tagstack=using_tagstack)
|
||||
if not result:
|
||||
return []
|
||||
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')
|
||||
@@ -1050,14 +1070,10 @@ 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)
|
||||
if not result:
|
||||
echo_highlight('Failed to create buffer window for %s!' % (
|
||||
module_path))
|
||||
continue
|
||||
result = set_buffer(r.module_path)
|
||||
if not result:
|
||||
echo_highlight('Failed to create buffer window for %s!' % (r.module_path))
|
||||
continue
|
||||
|
||||
buffers.add(vim.current.buffer.name)
|
||||
|
||||
@@ -1103,7 +1119,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 +1177,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 +1191,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.
|
||||
|
||||
Submodule pythonx/parso updated: ef90bba3b3...ee5edaf22f
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user