forked from VimPlug/jedi-vim
Merge pull request #915 from davidhalter/typeshed
With typeshed coming to Jedi, builtin modules should be displayed
This commit is contained in:
@@ -82,9 +82,8 @@ Manual installation
|
||||
You might want to use `pathogen <https://github.com/tpope/vim-pathogen>`_ or
|
||||
`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 install it via ``pip install jedi`` or with
|
||||
``git submodule update --init`` in your jedi-vim repository.
|
||||
The first thing you need after that is an up-to-date version of Jedi. Install
|
||||
``git submodule update --init --recursive`` in your jedi-vim repository.
|
||||
|
||||
Example installation command using Pathogen:
|
||||
|
||||
@@ -100,6 +99,9 @@ Add the following line in your `~/.vimrc`
|
||||
|
||||
Plugin 'davidhalter/jedi-vim'
|
||||
|
||||
For installing Jedi, ``pip install jedi`` will also work, but you might run
|
||||
into issues when working in virtual environments. Please use git submodules.
|
||||
|
||||
|
||||
Installation with your distribution
|
||||
-----------------------------------
|
||||
|
||||
@@ -19,6 +19,7 @@ let s:default_settings = {
|
||||
\ 'goto_command': "'<leader>d'",
|
||||
\ 'goto_assignments_command': "'<leader>g'",
|
||||
\ 'goto_definitions_command': "''",
|
||||
\ 'goto_stubs_command': "'<leader>s'",
|
||||
\ 'completions_command': "'<C-Space>'",
|
||||
\ 'call_signatures_command': "'<leader>n'",
|
||||
\ 'usages_command': "'<leader>n'",
|
||||
@@ -287,6 +288,10 @@ function! jedi#goto_definitions() abort
|
||||
PythonJedi jedi_vim.goto(mode="definition")
|
||||
endfunction
|
||||
|
||||
function! jedi#goto_stubs() abort
|
||||
PythonJedi jedi_vim.goto(mode="stubs")
|
||||
endfunction
|
||||
|
||||
function! jedi#usages() abort
|
||||
call jedi#remove_usages()
|
||||
PythonJedi jedi_vim.usages()
|
||||
|
||||
@@ -78,15 +78,6 @@ By leveraging this library, jedi-vim adds the following capabilities to Vim:
|
||||
|
||||
First of all, jedi-vim requires Vim to be compiled with the `+python` option.
|
||||
|
||||
The jedi library has to be installed for jedi-vim to work properly. You can
|
||||
install it first, by using e.g. your distribution's package manager, or by
|
||||
using pip: >
|
||||
|
||||
pip install jedi
|
||||
|
||||
However, you can also install it as a git submodule if you don't want to use
|
||||
jedi for anything but this plugin. How to do this is detailed below.
|
||||
|
||||
It is best if you have VIM >= 7.3, compiled with the `+conceal` option. With
|
||||
older versions, you will probably not see the parameter recommendation list
|
||||
for functions after typing the open bracket. Some platforms (including OS X
|
||||
@@ -107,11 +98,7 @@ feature (such as MacVim on OS X, which also contains a console binary).
|
||||
------------------------------------------------------------------------------
|
||||
2.1. Installing manually *jedi-vim-installation-manually*
|
||||
|
||||
1a. Get the latest repository from Github: >
|
||||
|
||||
git clone http://github.com/davidhalter/jedi-vim path/to/bundles/jedi-vim
|
||||
|
||||
1b. If you want to install jedi as a submodule instead, issue this command: >
|
||||
1. If you want to install jedi as a submodule instead, issue this command: >
|
||||
|
||||
git clone --recursive http://github.com/davidhalter/jedi-vim
|
||||
|
||||
@@ -161,8 +148,8 @@ repositories. On Arch Linux, install vim-jedi. On Debian (8+) or Ubuntu
|
||||
==============================================================================
|
||||
3. Supported Python features *jedi-vim-support*
|
||||
|
||||
The Jedi library does all the hard work behind the scenes. It supports
|
||||
completion of a large number of Python features, among them:
|
||||
The Jedi library does all the hard work behind the scenes. It understands most
|
||||
Python features, among them:
|
||||
|
||||
- Builtins
|
||||
- Multiple `return`s or `yield`s
|
||||
@@ -185,10 +172,12 @@ completion of a large number of Python features, among them:
|
||||
- Simple/usual `sys.path` modifications
|
||||
- `isinstance` checks for `if`/`while`/`assert` case, that doesn’t work with
|
||||
Jedi
|
||||
- Stubs
|
||||
- And more...
|
||||
|
||||
Note: This list is not necessarily up to date. For a complete list of
|
||||
features, please refer to the Jedi documentation at http://jedi.jedidjah.ch.
|
||||
features, please refer to the Jedi documentation at
|
||||
http://jedi.readthedocs.io.
|
||||
|
||||
==============================================================================
|
||||
4. Usage *jedi-vim-usage*
|
||||
|
||||
@@ -16,6 +16,9 @@ if g:jedi#auto_initialization
|
||||
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#goto_stubs_command)
|
||||
execute 'nnoremap <buffer> '.g:jedi#goto_stubs_command.' :call jedi#goto_stubs()<CR>'
|
||||
endif
|
||||
if len(g:jedi#usages_command)
|
||||
execute 'nnoremap <buffer> '.g:jedi#usages_command.' :call jedi#usages()<CR>'
|
||||
endif
|
||||
|
||||
@@ -15,6 +15,11 @@ if get(g:, 'jedi#auto_vim_configuration', 1)
|
||||
" jedi-vim really needs, otherwise jedi-vim cannot start.
|
||||
filetype plugin on
|
||||
|
||||
augroup jedi_pyi
|
||||
au!
|
||||
autocmd BufNewFile,BufRead *.pyi set filetype=python
|
||||
augroup END
|
||||
|
||||
" Change completeopt, but only if it was not set already.
|
||||
" This gets done on VimEnter, since otherwise Vim fails to restore the
|
||||
" screen. Neovim is not affected, this is likely caused by using
|
||||
|
||||
Submodule pythonx/jedi updated: 0bf8a69024...454447d422
@@ -304,12 +304,14 @@ def goto(mode="goto"):
|
||||
definitions = script.goto_definitions()
|
||||
elif mode == "assignment":
|
||||
definitions = script.goto_assignments()
|
||||
elif mode == "stubs":
|
||||
definitions = script.goto_assignments(follow_imports=True, only_stubs=True)
|
||||
|
||||
if not definitions:
|
||||
echo_highlight("Couldn't find any definitions for this.")
|
||||
elif len(definitions) == 1 and mode != "related_name":
|
||||
d = list(definitions)[0]
|
||||
if d.in_builtin_module():
|
||||
if d.column is None:
|
||||
if d.is_keyword:
|
||||
echo_highlight("Cannot get the definition of Python keywords.")
|
||||
else:
|
||||
@@ -372,9 +374,7 @@ def show_goto_multi_results(definitions):
|
||||
"""Create a quickfix list for multiple definitions."""
|
||||
lst = []
|
||||
for d in definitions:
|
||||
if d.in_builtin_module():
|
||||
lst.append(dict(text=PythonToVimStr('Builtin ' + d.description)))
|
||||
elif d.module_path is None:
|
||||
if d.column is None:
|
||||
# Typically a namespace, in the future maybe other things as
|
||||
# well.
|
||||
lst.append(dict(text=PythonToVimStr(d.description)))
|
||||
@@ -740,7 +740,7 @@ def py_import():
|
||||
except IndexError:
|
||||
echo_highlight('Cannot find %s in sys.path!' % import_path)
|
||||
else:
|
||||
if completion.in_builtin_module():
|
||||
if completion.column is None: # Python modules always have a line number.
|
||||
echo_highlight('%s is a builtin module.' % import_path)
|
||||
else:
|
||||
cmd_args = ' '.join([a.replace(' ', '\\ ') for a in args])
|
||||
|
||||
Submodule pythonx/parso updated: acccb4f28d...59df3fab43
@@ -56,10 +56,10 @@ def test_integration(install_vspec, path):
|
||||
if (line.startswith(b'not ok') or
|
||||
line.startswith(b'Error') or
|
||||
line.startswith(b'Bail out!')):
|
||||
pytest.fail("{0} failed:\n{1}".format(
|
||||
pytest.fail(u"{0} failed:\n{1}".format(
|
||||
path, output.decode('utf-8')), pytrace=False)
|
||||
if not had_ok and line.startswith(b'ok'):
|
||||
had_ok = True
|
||||
if not had_ok:
|
||||
pytest.fail("{0} failed: no 'ok' found:\n{1}".format(
|
||||
pytest.fail(u"{0} failed: no 'ok' found:\n{1}".format(
|
||||
path, output.decode('utf-8')), pytrace=False)
|
||||
|
||||
@@ -2,7 +2,7 @@ let mapleader = '\'
|
||||
source plugin/jedi.vim
|
||||
source test/_utils.vim
|
||||
|
||||
describe 'goto simple'
|
||||
describe 'goto simple:'
|
||||
before
|
||||
new
|
||||
set filetype=python
|
||||
@@ -45,7 +45,7 @@ describe 'goto simple'
|
||||
end
|
||||
|
||||
|
||||
describe 'goto with tabs'
|
||||
describe 'goto with tabs:'
|
||||
before
|
||||
set filetype=python
|
||||
let g:jedi#use_tabs_not_buffers = 1
|
||||
|
||||
@@ -39,9 +39,9 @@ describe 'signatures'
|
||||
it 'simple after CursorHoldI with only parenthesis'
|
||||
noautocmd normal o
|
||||
doautocmd CursorHoldI
|
||||
noautocmd normal istr()
|
||||
noautocmd normal istaticmethod()
|
||||
doautocmd CursorHoldI
|
||||
Expect getline(1) == '?!?jedi=0, ?!? (*_*object*_*) ?!?jedi?!?'
|
||||
Expect getline(1) == '?!?jedi=0, ?!? (*_*f: Callable*_*) ?!?jedi?!?'
|
||||
end
|
||||
|
||||
it 'no signature'
|
||||
@@ -64,11 +64,11 @@ describe 'signatures'
|
||||
let g:jedi#show_call_signatures = 2
|
||||
call jedi#configure_call_signatures()
|
||||
|
||||
exe 'normal ostr( '
|
||||
exe 'normal ostaticmethod( '
|
||||
redir => msg
|
||||
Python jedi_vim.show_call_signatures()
|
||||
redir END
|
||||
Expect msg == "\nstr(object)"
|
||||
Expect msg == "\nstaticmethod(f: Callable)"
|
||||
|
||||
redir => msg
|
||||
doautocmd InsertLeave
|
||||
|
||||
Reference in New Issue
Block a user