Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Completion of function arguments get an extra = sign #385

Closed
apuignav opened this issue Apr 13, 2015 · 6 comments
Closed

Completion of function arguments get an extra = sign #385

apuignav opened this issue Apr 13, 2015 · 6 comments
Labels

Comments

@apuignav
Copy link

With the latest jedi-vim, when completing a variable name that corresponds to a function argument an extra '=' sign appears. It looks to me like it thinks it's still in the function definition, where adding the sign makes sense for keyword arguments.

I attach a screenshot of what happens:

screen shot 2015-04-13 at 17 22 28

I don't know if I can provide further information (please let me know if I can). I have VIM compiled from source with homebrew:

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Dec 12 2014 14:24:23)
MacOS X (unix) version
Included patches: 1-258
Compiled by Homebrew
Huge version with MacVim GUI.  Features included (+) or not (-):
+acl             +file_in_path    +mouse_sgr       +tag_binary
+arabic          +find_in_path    -mouse_sysmouse  +tag_old_static
+autocmd         +float           +mouse_urxvt     -tag_any_white
+balloon_eval    +folding         +mouse_xterm     +tcl
+browse          -footer          +multi_byte      +terminfo
++builtin_terms  +fork()          +multi_lang      +termresponse
+byte_offset     +fullscreen      -mzscheme        +textobjects
+cindent         -gettext         +netbeans_intg   +title
+clientserver    -hangul_input    +odbeditor       +toolbar
+clipboard       +iconv           +path_extra      +transparency
+cmdline_compl   +insert_expand   +perl            +user_commands
+cmdline_hist    +jumplist        +persistent_undo +vertsplit
+cmdline_info    +keymap          +postscript      +virtualedit
+comments        +langmap         +printer         +visual
+conceal         +libcall         +profile         +visualextra
+cryptv          +linebreak       +python          +viminfo
+cscope          +lispindent      -python3         +vreplace
+cursorbind      +listcmds        +quickfix        +wildignore
+cursorshape     +localmap        +reltime         +wildmenu
+dialog_con_gui  +lua             +rightleft       +windows
+diff            +menu            +ruby            +writebackup
+digraphs        +mksession       +scrollbind      -X11
+dnd             +modify_fname    +signs           -xfontset
-ebcdic          +mouse           +smartindent     +xim
+emacs_tags      +mouseshape      -sniff           -xsmp
+eval            +mouse_dec       +startuptime     -xterm_clipboard
+ex_extra        -mouse_gpm       +statusline      -xterm_save
+extra_search    -mouse_jsbterm   -sun_workshop    -xpm
+farsi           +mouse_netterm   +syntax
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/Applications/MacVim.app/Contents/Resources/vim"
Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_MACVIM -Wall -Wno-unknown-pragmas -pipe  -DMACOS_X_UNIX  -I/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/include/python2.7 -fno-strict-aliasing -fno-common -dynamic -I/usr/local/include -I/usr/local/opt/sqlite/include -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1     -I/System/Library/Frameworks/Tcl.framework/Headers  -D_REENTRANT=1  -D_THREAD_SAFE=1  -D_DARWIN_C_SOURCE=1
Linking: clang   -L.   -L.   -L/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config -lpython2.7 -framework CoreFoundation -L/usr/local/lib -o Vim -framework Cocoa -framework Carbon       -lncurses -liconv -framework Cocoa  -L/usr/local/lib -llua -fstack-protector -L/usr/local/lib  -L/System/Library/Perl/5.12/darwin-thread-multi-2level/CORE -lperl -lm -lutil -lc -framework Python  -F/System/Library/Frameworks -framework Tcl -framework CoreFoundation -framework Ruby

Thanks.

@davidhalter
Copy link
Owner

Yeah, I think I have noticed this one as well! Thanks.

@apuignav
Copy link
Author

Hi, just nudging this. Is there anything I can help to debug this issue?

I've noticed that if the completion happens inside a parens and there is a line after, not only the = sign is added but also the cursor jumps in the next line.

For example, if I complete here in longvarn (^ marks the cursor)

class A:
    def a(self, longvarname):
        v = set(longvarn)
                        ^
        testline

I get

class A:
    def a(self, longvarname):
        v = set(longvarname=)
        testline
                ^

@davidhalter
Copy link
Owner

I'm sure it's not that hard to fix, it's just that I don't have the time to do it. If someone wants to fix this, you have to check where it originates from. It might as well be a Jedi bug (not jedi-vim).

@linluk
Copy link

linluk commented Jan 2, 2016

Hi, I experience the same issue. If someone is going to fix it and needs any help reproducing or debugging, feel free to ask me.

Here is an additional screenshot:
screenshot

my jedi-vim settings:

" vim-jedi {{{2
let g:jedi#popup_on_dot = 0
let g:jedi#popup_select_first = 0
let g:jedi#show_call_signatures = "1"
let g:jedi#goto_assignments_command = "<C-i>"
let g:jedi#completions_command = "<C-Space>"
let g:jedi#auto_vim_configuration = 0

...

augroup mypythonstuff "{{{2
  autocmd!
  autocmd FileType python set cindent
  autocmd FileType python set shiftwidth=4
  autocmd FileType python set softtabstop=4
  autocmd FileType python set expandtab
  autocmd FileType python setlocal completeopt-=preview
  autocmd FileType python set omnifunc=jedi#completions
  autocmd FileType python map <F5> <ESC>:w<CR>:!python % <CR>
augroup END

and my vim version:

:version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Oct 21 2015 13:03:51)
Inklusive der Korrekturen: 1-712
Verändert von pkg-vim-maintainers@lists.alioth.debian.org
Übersetzt von buildd@
Riesige Version ohne GUI. Ein- (+) oder ausschließlich (-) der Eigenschaften:
+acl             +cmdline_info    +emacs_tags      -hangul_input    +menu            +mouse_xterm     -python3         +syntax          +virtualedit     -xsmp
+arabic          +comments        +eval            +iconv           +mksession       +multi_byte      +quickfix        +tag_binary      +visual          -xterm_clipboard
+autocmd         +conceal         +ex_extra        +insert_expand   +modify_fname    +multi_lang      +reltime         +tag_old_static  +visualextra     -xterm_save
-balloon_eval    +cryptv          +extra_search    +jumplist        +mouse           -mzscheme        +rightleft       -tag_any_white   +viminfo         -xpm
-browse          +cscope          +farsi           +keymap          -mouseshape      +netbeans_intg   +ruby            +tcl             +vreplace
++builtin_terms  +cursorbind      +file_in_path    +langmap         +mouse_dec       +path_extra      +scrollbind      +terminfo        +wildignore
+byte_offset     +cursorshape     +find_in_path    +libcall         +mouse_gpm       +perl            +signs           +termresponse    +wildmenu
+cindent         +dialog_con      +float           +linebreak       -mouse_jsbterm   +persistent_undo +smartindent     +textobjects     +windows
-clientserver    +diff            +folding         +lispindent      +mouse_netterm   +postscript      -sniff           +title           +writebackup
-clipboard       +digraphs        -footer          +listcmds        +mouse_sgr       +printer         +startuptime     -toolbar         -X11
+cmdline_compl   -dnd             +fork()          +localmap        -mouse_sysmouse  +profile         +statusline      +user_commands   -xfontset
+cmdline_hist    -ebcdic          +gettext         +lua             +mouse_urxvt     +python          -sun_workshop    +vertsplit       -xim
          System-vimrc-Datei: "$VIM/vimrc"
        Benutzer-vimrc-Datei: "$HOME/.vimrc"
 zweite Benutzer-vimrc-Datei: "~/.vim/vimrc"
         Benutzer-exrc-Datei: "$HOME/.exrc"
     Voreinstellung für $VIM: "/usr/share/vim"
Übersetzt: gcc -c -I. -Iproto -DHAVE_CONFIG_H     -g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1     -I/usr
/include/tcl8.6  -D_REENTRANT=1  -D_THREAD_SAFE=1  -D_LARGEFILE64_SOURCE=1
Linken: gcc   -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -L/build/ruby2.1-_3OTYb/ruby2.1-2.1.5/debian/lib -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-E  -Wl,-Bsy
mbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim        -lm -ltinfo -lnsl  -lselinux  -lacl -lattr -lgpm -ldl  -L/usr/lib -llua5.2 -Wl,-E  -fst
ack-protector -L/usr/local/lib  -L/usr/lib/x86_64-linux-gnu/perl/5.20/CORE -lperl -ldl -lm -lpthread -lcrypt -L/usr/lib/python2.7/config-x86_64-linux-gnu -lpython2.7 -lp
thread -ldl -lutil -lm -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions  -L/usr/lib/x86_64-linux-gnu -ltcl8.6 -ldl -lz -lpthread -lieee -lm -lruby-2.1 -lpthread
 -lgmp -ldl -lcrypt -lm
Betätigen Sie die EINGABETASTE oder geben Sie einen Befehl ein
n.org
    Übersetzt von buildd@
    Riesige Version ohne GUI. Ein- (+) oder ausschließlich (-) der Eigenschaften:
    +acl             +cmdline_info    +emacs_tags      -hangul_input    +menu            +mouse_xterm     -python3         +syntax          +virtualedit     -xsmp
    +arabic          +comments        +eval            +iconv           +mksession       +multi_byte      +quickfix        +tag_binary      +visual          -xterm_clipboard
    +autocmd         +conceal         +ex_extra        +insert_expand   +modify_fname    +multi_lang      +reltime         +tag_old_static  +visualextra     -xterm_save
    -balloon_eval    +cryptv          +extra_search    +jumplist        +mouse           -mzscheme        +rightleft       -tag_any_white   +viminfo         -xpm
    -browse          +cscope          +farsi           +keymap          -mouseshape      +netbeans_intg   +ruby            +tcl             +vreplace
    ++builtin_terms  +cursorbind      +file_in_path    +langmap         +mouse_dec       +path_extra      +scrollbind      +terminfo        +wildignore
    +byte_offset     +cursorshape     +find_in_path    +libcall         +mouse_gpm       +perl            +signs           +termresponse    +wildmenu
    +cindent         +dialog_con      +float           +linebreak       -mouse_jsbterm   +persistent_undo +smartindent     +textobjects     +windows
    -clientserver    +diff            +folding         +lispindent      +mouse_netterm   +postscript      -sniff           +title           +writebackup
    -clipboard       +digraphs        -footer          +listcmds        +mouse_sgr       +printer         +startuptime     -toolbar         -X11
    +cmdline_compl   -dnd             +fork()          +localmap        -mouse_sysmouse  +profile         +statusline      +user_commands   -xfontset
    +cmdline_hist    -ebcdic          +gettext         +lua             +mouse_urxvt     +python          -sun_workshop    +vertsplit       -xim
              System-vimrc-Datei: "$VIM/vimrc"
            Benutzer-vimrc-Datei: "$HOME/.vimrc"
     zweite Benutzer-vimrc-Datei: "~/.vim/vimrc"
             Benutzer-exrc-Datei: "$HOME/.exrc"
         Voreinstellung für $VIM: "/usr/share/vim"
    Übersetzt: gcc -c -I. -Iproto -DHAVE_CONFIG_H     -g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1     -I/usr
    /include/tcl8.6  -D_REENTRANT=1  -D_THREAD_SAFE=1  -D_LARGEFILE64_SOURCE=1
    Linken: gcc   -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -L/build/ruby2.1-_3OTYb/ruby2.1-2.1.5/debian/lib -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-E  -Wl,-Bsy
    mbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim        -lm -ltinfo -lnsl  -lselinux  -lacl -lattr -lgpm -ldl  -L/usr/lib -llua5.2 -Wl,-E  -fst
    ack-protector -L/usr/local/lib  -L/usr/lib/x86_64-linux-gnu/perl/5.20/CORE -lperl -ldl -lm -lpthread -lcrypt -L/usr/lib/python2.7/config-x86_64-linux-gnu -lpython2.7 -lp
    thread -ldl -lutil -lm -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions  -L/usr/lib/x86_64-linux-gnu -ltcl8.6 -ldl -lz -lpthread -lieee -lm -lruby-2.1 -lpthread
     -lgmp -ldl -lcrypt -lm
    Betätigen Sie die EINGABETASTE oder geben Sie einen Befehl ein

br lukas

@StephenHesperus
Copy link

After digging into the source code for a while, I actually found the problem: it's in davidhalter/jedi.
See https://github.com/davidhalter/jedi/blob/master/jedi/api/classes.py#L388-L389.

def _complete(self, like_name):
    dot = '.' if self._needs_dot else ''
    append = ''
    if settings.add_bracket_after_function \
            and self.type == 'Function':
        append = '('

    if settings.add_dot_after_module:
        if isinstance(self._definition, tree.Module):
            append += '.'
    if isinstance(self._definition, tree.Param):
        append += '='

    name = str(self._name)
    if like_name:
        name = name[self._like_name_length:]
    return dot + name + append

Those two lines literally add the '=' sign after a param: completion. Remove it should eliminate the bug.

@davidhalter
Copy link
Owner

Fixed it in jedi (dev branch).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants