Debian Codegraph @

vim/test/vspec/signatures.vim

raw symbols SCIP
1 source plugin/jedi.vim
2
3 describe 'signatures'
4 before
5 enew
6 set filetype=python
7 end
8
9 after
10 try | %bwipeout! | catch | endtry
11 end
12
13 it 'simple'
14 normal odef xyz(number): return
15 normal o
16 normal oxyz()
17 doautocmd CursorHoldI
18 Expect getline(3) == '?!?jedi=0, ?!? (*_*number*_*) ?!?jedi?!?'
19
20 doautocmd InsertLeave
21 Expect getline(3) == ''
22 end
23
24 it 'multiple buffers'
25 set hidden
26 new
27 setfiletype python
28 redir => autocmds
29 autocmd jedi_call_signatures * <buffer>
30 redir END
31 Expect autocmds =~# 'jedi_call_signatures'
32 buffer #
33 redir => autocmds
34 autocmd jedi_call_signatures * <buffer>
35 redir END
36 Expect autocmds =~# 'jedi_call_signatures'
37 end
38
39 it 'simple after CursorHoldI with only parenthesis'
40 noautocmd normal o
41 doautocmd CursorHoldI
42 noautocmd normal istaticmethod()
43 doautocmd CursorHoldI
44 Expect getline(1) == '?!?jedi=0, ?!? (*_*f: Callable[_P, _R_co]*_*) ?!?jedi?!?'
45 end
46
47 it 'highlights correct argument'
48 noautocmd normal o
49 doautocmd CursorHoldI
50 noautocmd normal iformat(42, "x")
51 " Move to x - highlights "x".
52 noautocmd normal 2h
53 doautocmd CursorHoldI
54 Expect getline(1) == '?!?jedi=0, ?!? (value: object, *_*format_spec: str=""*_*) ?!?jedi?!?'
55 " Move left to 42 - hightlights first argument ("value").
56 noautocmd normal 4h
57 doautocmd CursorHoldI
58 Expect getline(1) == '?!?jedi=0, ?!? (*_*value: object*_*, format_spec: str="") ?!?jedi?!?'
59 end
60
61 it 'no signature'
62 exe 'normal ostr '
63 python3 jedi_vim.show_call_signatures()
64 Expect getline(1, '$') == ['', 'str ']
65 end
66
67 it 'signatures disabled'
68 let g:jedi#show_call_signatures = 0
69
70 exe 'normal ostr( '
71 python3 jedi_vim.show_call_signatures()
72 Expect getline(1, '$') == ['', 'str( ']
73
74 let g:jedi#show_call_signatures = 1
75 end
76
77 it 'command line simple'
78 let g:jedi#show_call_signatures = 2
79 call jedi#configure_call_signatures()
80
81 exe 'normal ostaticmethod( '
82 redir => msg
83 python3 jedi_vim.show_call_signatures()
84 redir END
85 Expect msg == "\nstaticmethod(f: Callable[_P, _R_co])"
86
87 redir => msg
88 doautocmd InsertLeave
89 redir END
90 Expect msg == "\n"
91
92 normal Sdef foo(a, b): pass
93 exe 'normal ofoo(a, b, c, '
94 redir => msg
95 python3 jedi_vim.show_call_signatures()
96 redir END
97 Expect msg == "\nfoo(a, b)"
98 end
99
100 it 'command line truncation'
101 " Disable autoindent so `o` opens a new line at column 0; relying on
102 " `\<BS>` to strip the indent is not portable across vim/nvim defaults
103 " (with `bs=eol` it joins lines instead of just removing the indent).
104 setlocal noautoindent nosmartindent indentexpr=
105
106 let g:jedi#show_call_signatures = 2
107 call jedi#configure_call_signatures()
108
109 function! Signature()
110 redir => msg
111 python3 jedi_vim.show_call_signatures()
112 redir END
113 return msg
114 endfunction
115
116 let funcname = repeat('a', &columns - (30 + (&ruler ? 18 : 0)))
117 put = 'def '.funcname.'(arg1, arg2, arg3, a, b, c):'
118 put = ' pass'
119 execute "normal o".funcname."( "
120 Expect Signature() == "\n".funcname."(arg1, …)"
121
122 exe 'normal sarg1, '
123 Expect Signature() == "\n".funcname."(…, arg2, …)"
124
125 exe 'normal sarg2, arg3, '
126 Expect Signature() == "\n".funcname."(…, a, b, c)"
127
128 exe 'normal sa, b, '
129 Expect Signature() == "\n".funcname."(…, c)"
130
131 g/^/d
132 put = 'def '.funcname.'('.repeat('b', 20).', arg2):'
133 put = ' pass'
134 execute "normal o".funcname."( "
135 Expect Signature() == "\n".funcname."(…)"
136 end
137
138 it 'command line no signature'
139 let g:jedi#show_call_signatures = 2
140 call jedi#configure_call_signatures()
141
142 exe 'normal ostr '
143 redir => msg
144 python3 jedi_vim.show_call_signatures()
145 redir END
146 Expect msg == "\n"
147 end
148 end