0

I am using a pluging ctrlp-py-matcher, which is using the python interface to vim. My VIM is compiled with python3 support

VIM - Vi IMproved 8.1 (2018 May 17, compiled Jul  1 2018 10:45:10) Included
patches: 1-42 Compiled by username@username-VirtualBox Huge version with GTK2
GUI.  Features included (+) or not (-): +acl               +farsi
+mouse_sgr         -tag_any_white +arabic            +file_in_path
-mouse_sysmouse    -tcl +autocmd           +find_in_path      +mouse_urxvt
+termguicolors -autoservername    +float             +mouse_xterm
+terminal +balloon_eval      +folding           +multi_byte        +terminfo
+balloon_eval_term -footer            +multi_lang        +termresponse +browse
+fork()            -mzscheme          +textobjects ++builtin_terms    +gettext
+netbeans_intg     +timers +byte_offset       -hangul_input      +num64
+title +channel           +iconv             +packages          +toolbar
+cindent           +insert_expand     +path_extra        +user_commands
+clientserver      +job               +perl              +vertsplit +clipboard
+jumplist          +persistent_undo   +virtualedit +cmdline_compl     +keymap
+postscript        +visual +cmdline_hist      +lambda            +printer
+visualextra +cmdline_info      +langmap           +profile           +viminfo
+comments          +libcall           -python            +vreplace +conceal
+linebreak         +python3           +wildignore +cryptv
+lispindent        +quickfix          +wildmenu +cscope            +listcmds
+reltime           +windows +cursorbind        +localmap          +rightleft
+writebackup +cursorshape       +lua               +ruby              +X11
+dialog_con_gui    +menu              +scrollbind        -xfontset +diff
+mksession         +signs             +xim +digraphs          +modify_fname
+smartindent       +xpm +dnd               +mouse             +startuptime
+xsmp_interact -ebcdic            +mouseshape        +statusline
+xterm_clipboard +emacs_tags        +mouse_dec         -sun_workshop
-xterm_save +eval              -mouse_gpm         +syntax +ex_extra
-mouse_jsbterm     +tag_binary +extra_search      +mouse_netterm
+tag_old_static 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" defaults file: "$VIMRUNTIME/defaults.vim" system menu file:
"$VIMRUNTIME/menu.vim" fall-back for $VIM: "/usr/local/share/vim" f-b for
$VIMRUNTIME: "/usr/local/share/vim/vim81" Compilation: gcc -c -I. -Iproto
-DHAVE_CONFIG_H -DFEAT_GUI_GTK  -pthread -I/usr/include/gtk-2.0
-I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/include/gio-unix-2.0/
-I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/atk-1.0
-I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libpng12
-I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng12 -I/usr/include/pango-1.0
-I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/glib-2.0
-I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/freetype2   -g -O2
-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1     Linking: gcc   -L.
-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic
-Wl,-export-dynamic -Wl,-E   -L/usr/local/lib -Wl,--as-needed -o vim
-lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0
-lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig
-lfreetype -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo -lnsl
-lselinux  -ldl  -L/usr/lib -llua5.1 -Wl,-E  -fstack-protector-strong
-L/usr/local/lib  -L/usr/lib/x86_64-linux-gnu/perl/5.22/CORE -lperl -ldl -lm
-lpthread -lcrypt  -L/usr/lib/python3.5/config-3.5m-x86_64-linux-gnuconfig
-lpython3.5m  -lruby-2.3 -lpthread -lgmp -ldl -lcrypt -lm

I have this file in my folder: https://github.com/pallets/jinja/blob/master/jinja2/_identifier.py

Now I try to use ctrlp, ctrlp-py-matcher to navigate tags. I use ctags to generate the tags files.

However, I found that even though the correct tags were being generated, :CtrlPTags wasn't showing any tags.

I have traced it down to the file above
https://github.com/pallets/jinja/blob/master/jinja2/_identifier.py

which contains BOM UTF-8 header, vim.eval in the ctrlp-py-matcher fails. vim.eval('a:items'): https://github.com/FelikZ/ctrlp-py-matcher/blob/cf63fd546f1e80dd4db3db96afbeaad301d21f13/autoload/pymatcher.py#L7

Other people such as @ludovicchabant also found a similar problem and had to work around it as shown in his fork of the ctrlp-py-matcher repo, and also post process the tags file(https://ludovic.chabant.com/devblog/2017/02/25/aaa-gamedev-with-vim/) :

https://github.com/ludovicchabant/ctrlp-py-matcher/blob/2f6947480203b734b069e5d9f69ba440db6b4698/autoload/pymatcher.py#L22

Further, I have verfied that I if I do remove the BOM headers using the following commands: https://unix.stackexchange.com/a/381263/242983 from the file, :CtrlPTag works fine again.

Currently, I basically excluded the entire python env folder to prevent these issues. I can ofcourse, do some post-processing of tags file after ctags generates the tags file and remove the BOM header, but it seems a bit hacky.

The best way would be if vim.eval('a:items') doesn't error out, even if its argument contains BOM headers, or if there exists another function other than vim.eval which won't crash when the string it contains has BOM headers.

Is there another way or another function other than vim.eval which can take in strings which contain BOM headers` and not error out?

Is this by design, or a bug?

  • Relevant Vim ticket: #3213 – Christian Brabandt Aug 23 '18 at 9:02
  • @ChristianBrabandt.. thanks.. yeah.. I created that.. – alpha_989 Aug 24 '18 at 17:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.