File: jedi.vim

package info (click to toggle)
python-jedi 0.19.1%2Bds1-1
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 11,680 kB
  • sloc: python: 28,783; makefile: 172; ansic: 13
file content (82 lines) | stat: -rw-r--r-- 2,766 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
"jedi-vim - Omni Completion for python in vim
" Maintainer: David Halter <davidhalter88@gmail.com>
"
" This part of the software is just the vim interface. The really big deal is
" the Jedi Python library.

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
        " vint: +ProhibitSetNoCompatible
    endif

    " 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
    " :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
            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')
        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=? -complete=file JediChooseEnvironment :call jedi#choose_environment(<q-args>)
command! -nargs=? -complete=file JediLoadProject :call jedi#load_project(<q-args>)


function! s:jedi_debug_info()
    " Ensure the autoload file has been loaded (and ignore any errors, which
    " will be displayed with the debug info).
    let unset = {}
    let saved_squelch_py_warning = get(g:, 'jedi#squelch_py_warning', unset)
    let g:jedi#squelch_py_warning = 1
    call jedi#init_python()
    if saved_squelch_py_warning is unset
        unlet g:jedi#squelch_py_warning
    else
        let g:jedi#squelch_py_warning = saved_squelch_py_warning
    endif
    call jedi#debug_info()
endfunction
command! -nargs=0 -bar JediDebugInfo call s:jedi_debug_info()
command! -nargs=0 -bang JediClearCache call jedi#clear_cache(<bang>0)

" vim: set et ts=4: