Giter Club home page Giter Club logo

Comments (9)

alfredodeza avatar alfredodeza commented on September 6, 2024

Errors in Vim are misleading :(

In this case, the two last errors E15 and E116 are the ones that are interesting. Are you able to consistently recreate this issue?

If so, could you run that failing command so that we can see what is going on? For example:

:echo bufname('%')
:execute('sign place file=' . bufname('%'))
:echo split(execute('sign place file=' . bufname('%')), '\n')

Since the ClearSigns() function doesn't take any arguments, just executing those commands above will hopefully tell us what we are missing.

from coveragepy.vim.

stringfellow avatar stringfellow commented on September 6, 2024

Ah ok, so..

:echo bufname('%')
filename.py

:execute('sign place file=' . bufname('%'))
--- Signs ---

:echo split(execute('sign place file=' . bufname('%')), '\n')
E117: Unknown function: execute
E116: Invalid arguments for function split(execute('sign place file=' . bufname('%')), '\n')
E15: Invalid expression: split(execute('sign place file=' . bufname('%')), '\n')

If I do it without echo, the result is an empty split called execute('sign place file=' . bufname('%')), '\n')...! (i.e. I ran :split(execute('sign place file=' . bufname('%')), '\n'))
So it seems like execute is invalid following echo?

Not sure if it helps but here's my vim version info:

:version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled May 17 2016 16:20:13)
MacOS X (unix) version
Included patches: 1-1830
Compiled by Homebrew
Huge version without GUI.  Features included (+) or not (-):
+acl             +clipboard       +dialog_con      +file_in_path    +job             +menu            -mouse_sysmouse  +persistent_undo +scrollbind      -tcl             +virtualedit     -xfontset
+arabic          +cmdline_compl   +diff            +find_in_path    +jumplist        +mksession       +mouse_urxvt     +postscript      +signs           +termguicolors   +visual          -xim
+autocmd         +cmdline_hist    +digraphs        +float           +keymap          +modify_fname    +mouse_xterm     +printer         +smartindent     +terminfo        +visualextra     -xsmp
-balloon_eval    +cmdline_info    -dnd             +folding         +langmap         +mouse           +multi_byte      +profile         +startuptime     +termresponse    +viminfo         -xterm_clipboard
-browse          +comments        -ebcdic          -footer          +libcall         -mouseshape      +multi_lang      +python          +statusline      +textobjects     +vreplace        -xterm_save
++builtin_terms  +conceal         +emacs_tags      +fork()          +linebreak       +mouse_dec       -mzscheme        -python3         -sun_workshop    +timers          +wildignore      -xpm
+byte_offset     +cryptv          +eval            -gettext         +lispindent      -mouse_gpm       +netbeans_intg   +quickfix        +syntax          +title           +wildmenu
+channel         +cscope          +ex_extra        -hangul_input    +listcmds        -mouse_jsbterm   +packages        +reltime         +tag_binary      -toolbar         +windows
+cindent         +cursorbind      +extra_search    +iconv           +localmap        +mouse_netterm   +path_extra      +rightleft       +tag_old_static  +user_commands   +writebackup
-clientserver    +cursorshape     +farsi           +insert_expand   -lua             +mouse_sgr       +perl            +ruby            -tag_any_white   +vertsplit       -X11
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  fall-back for $VIM: "/usr/local/share/vim"
Compilation: /usr/bin/clang -c -I. -Iproto -DHAVE_CONFIG_H   -F/usr/local/Frameworks -DMACOS_X_UNIX  -Os -w -pipe -march=native -mmacosx-version-min=10.11 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: /usr/bin/clang   -L. -L/Users/haven/.sm/pkg/active/lib -fPIC -Bstatic -lz -fstack-protector -L/usr/local/lib -F/usr/local/Frameworks -Wl,-headerpad_max_install_names -o vim        -lm  -lncurses
-liconv -framework Cocoa   -fstack-protector  -L/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE -lperl -framework Python   -lruby-static -framework CoreFoundation -lobjc -L/Users/spike/.rvm/rubi
es/ruby-2.2.1/lib

from coveragepy.vim.

stringfellow avatar stringfellow commented on September 6, 2024

And to answer your other question - yes, it always seems to happen

from coveragepy.vim.

alfredodeza avatar alfredodeza commented on September 6, 2024

@stringfellow I have a reproducer now. I think this is based on your version of Vim. There is no function execute() on Vim 7.4

If you are able to update to Vim 8, this would work there. In the meantime please allow me a few days (if not sooner) to get this fixed for 7.4 Thank you!

from coveragepy.vim.

stringfellow avatar stringfellow commented on September 6, 2024

Aha! Ok, I'll see if I can upgrade... Thank you!! :D

from coveragepy.vim.

stringfellow avatar stringfellow commented on September 6, 2024

Perfect, upgrade solved it. Now I think my issue is that the .coverage file is in the root of the project rather than the buffer file location..? (:pwd reports the directory of the python file I've got in my buffer, rather than where I ran vim from in my shell)

also the .coverage file starts with this:
!coverage.py: This is a private format, don't read it directly!{"lines": .....
Is that expected or is it different because this is a pytest-cov output?

from coveragepy.vim.

alfredodeza avatar alfredodeza commented on September 6, 2024

A bit more investigation revealed that 7.4 supports the execute() function, but specifically version 7.4-2008

Before that, execute()didn't exist. The only way to support this for older versions would be with this changeset:

diff --git a/ftplugin/python/coveragepy.vim b/ftplugin/python/coveragepy.vim
index 250a29c..05e08cb 100755
--- a/ftplugin/python/coveragepy.vim
+++ b/ftplugin/python/coveragepy.vim
@@ -84,7 +84,10 @@ endfunction


 function! s:ClearSigns() abort
-    let placements = split(execute('sign place file=' . bufname('%')), '\n')
+    redir => place_output
+    execute 'silent sign place file=' . bufname('%')
+    redir END
+    let placements = split(place_output, '\n')
     let fname = bufname('%')
     for s in placements
       let cols = split(s)

from coveragepy.vim.

alfredodeza avatar alfredodeza commented on September 6, 2024

Not sure I follow your new issue. If you are at /home and you are editing /opt/python/project/foo.py it will still work because how paths are shown in coverage output. The plugin matches the buffer name to what the coverage output is, which should work regardless of were you are at.

If that is not working, would you explain a bit more what you see? What is happening or not working?

from coveragepy.vim.

stringfellow avatar stringfellow commented on September 6, 2024

Aha.. got it - it was because I ran pytest from inside my docker test container, but I'm using vim on my host machine - a quick path substitution did the trick! Thanks very much for your help, and this awesome lib. :)

from coveragepy.vim.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.