diff --git a/README.rst b/README.rst index ec8188d..bb16b4a 100644 --- a/README.rst +++ b/README.rst @@ -82,9 +82,8 @@ Manual installation You might want to use `pathogen `_ or `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 ----------------------------------- diff --git a/autoload/jedi.vim b/autoload/jedi.vim index 6a075ca..4ebd96f 100644 --- a/autoload/jedi.vim +++ b/autoload/jedi.vim @@ -19,6 +19,7 @@ let s:default_settings = { \ 'goto_command': "'d'", \ 'goto_assignments_command': "'g'", \ 'goto_definitions_command': "''", + \ 'goto_stubs_command': "'s'", \ 'completions_command': "''", \ 'call_signatures_command': "'n'", \ 'usages_command': "'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() diff --git a/doc/jedi-vim.txt b/doc/jedi-vim.txt index b3a3ac4..c70a969 100644 --- a/doc/jedi-vim.txt +++ b/doc/jedi-vim.txt @@ -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* diff --git a/ftplugin/python/jedi.vim b/ftplugin/python/jedi.vim index 0708a5b..7156844 100644 --- a/ftplugin/python/jedi.vim +++ b/ftplugin/python/jedi.vim @@ -16,6 +16,9 @@ if g:jedi#auto_initialization if len(g:jedi#goto_definitions_command) execute 'nnoremap '.g:jedi#goto_definitions_command.' :call jedi#goto_definitions()' endif + if len(g:jedi#goto_stubs_command) + execute 'nnoremap '.g:jedi#goto_stubs_command.' :call jedi#goto_stubs()' + endif if len(g:jedi#usages_command) execute 'nnoremap '.g:jedi#usages_command.' :call jedi#usages()' endif diff --git a/plugin/jedi.vim b/plugin/jedi.vim index 9245bba..f8fe4b2 100644 --- a/plugin/jedi.vim +++ b/plugin/jedi.vim @@ -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 diff --git a/pythonx/jedi b/pythonx/jedi index 0bf8a69..454447d 160000 --- a/pythonx/jedi +++ b/pythonx/jedi @@ -1 +1 @@ -Subproject commit 0bf8a69024aff8599bd1f323c4feba2703ef3d59 +Subproject commit 454447d422c9d832db03dff118bafc21174ecb55 diff --git a/pythonx/jedi_vim.py b/pythonx/jedi_vim.py index 4419b48..c759d33 100644 --- a/pythonx/jedi_vim.py +++ b/pythonx/jedi_vim.py @@ -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]) diff --git a/pythonx/parso b/pythonx/parso index acccb4f..59df3fa 160000 --- a/pythonx/parso +++ b/pythonx/parso @@ -1 +1 @@ -Subproject commit acccb4f28d6d57f4ad4c882f3408136ee8f50ff5 +Subproject commit 59df3fab4358d5889556c2450c2d1deb36facdb7 diff --git a/test/test_integration.py b/test/test_integration.py index ae39307..8d53c51 100644 --- a/test/test_integration.py +++ b/test/test_integration.py @@ -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) diff --git a/test/vspec/goto.vim b/test/vspec/goto.vim index e5c14b5..002f793 100644 --- a/test/vspec/goto.vim +++ b/test/vspec/goto.vim @@ -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 diff --git a/test/vspec/signatures.vim b/test/vspec/signatures.vim index 06533f2..ca4248e 100644 --- a/test/vspec/signatures.vim +++ b/test/vspec/signatures.vim @@ -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