File: signatures.vim

package info (click to toggle)
python-jedi 0.10.0~git1%2Bf05c071-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,064 kB
  • ctags: 3,014
  • sloc: python: 16,997; makefile: 149; ansic: 13
file content (130 lines) | stat: -rw-r--r-- 3,291 bytes parent folder | download
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
source plugin/jedi.vim

describe 'signatures'
    before
        set filetype=python
    end

    after
        bd!
        bd!
    end

    it 'simple'
        normal oabs( 
        " equals doautocmd CursorMovedI
        Python jedi_vim.show_call_signatures()

        Expect getline(1) == '=`=jedi=0, =`=   (*_*number*_*) =`=jedi=`='

        doautocmd InsertLeave
        Expect getline(1) == ''
    end

    it 'multiple buffers'
        set hidden
        new
        setfiletype python
        redir => autocmds
        autocmd jedi_call_signatures * <buffer>
        redir END
        Expect autocmds =~# 'jedi_call_signatures'
        buffer #
        redir => autocmds
        autocmd jedi_call_signatures * <buffer>
        redir END
        Expect autocmds =~# 'jedi_call_signatures'
        bd!
    end

    it 'simple after CursorHoldI with only parenthesis'
        noautocmd normal o
        doautocmd CursorHoldI
        noautocmd normal iabs( 
        doautocmd CursorHoldI
        Expect getline(1) == '=`=jedi=0, =`=   (*_*number*_*) =`=jedi=`='
    end

    it 'no signature'
        normal ostr 
        Python jedi_vim.show_call_signatures()
        Expect getline(1, '$') == ['', 'str ']
    end

    it 'signatures disabled'
        let g:jedi#show_call_signatures = 0

        normal ostr( 
        Python jedi_vim.show_call_signatures()
        Expect getline(1, '$') == ['', 'str( ']

        let g:jedi#show_call_signatures = 1
    end

    it 'command line simple'
        let g:jedi#show_call_signatures = 2
        call jedi#configure_call_signatures()

        normal oabs( 
        redir => msg
        Python jedi_vim.show_call_signatures()
        redir END
        Expect msg == "\nabs(number)"

        redir => msg
        doautocmd InsertLeave 
        redir END
        Expect msg == "\n"

        normal Sdef foo(a, b): pass
        normal ofoo(a, b, c, 
        redir => msg
        Python jedi_vim.show_call_signatures()
        redir END
        Expect msg == "\nfoo(a, b)"
    end

    it 'command line truncation'
        let g:jedi#show_call_signatures = 2
        call jedi#configure_call_signatures()

        function! Signature()
            redir => msg
            Python jedi_vim.show_call_signatures()
            redir END
            return msg
        endfunction

        let funcname = repeat('a', &columns - 30)
        put = 'def '.funcname.'(arg1, arg2, arg3, a, b, c):'
        put = '    pass'
        execute "normal o".funcname."( "
        Expect Signature() == "\n".funcname."(arg1, …)"

        normal sarg1, 
        Expect Signature() == "\n".funcname."(…, arg2, …)"

        normal sarg2, arg3, 
        Expect Signature() == "\n".funcname."(…, a, b, c)"

        normal sa, b, 
        Expect Signature() == "\n".funcname."(…, c)"

        g/^/d
        put = 'def '.funcname.'('.repeat('b', 20).', arg2):'
        put = '    pass'
        execute "normal o".funcname."( "
        Expect Signature() == "\n".funcname."(…)"
    end

    it 'command line no signature'
        let g:jedi#show_call_signatures = 2
        call jedi#configure_call_signatures()

        normal ostr 
        redir => msg
        Python jedi_vim.show_call_signatures()
        redir END
        Expect msg == "\n"
    end
end