Embedded languages in Vimscript highlighted as error?

20 views
Skip to first unread message

Matt

unread,
Dec 5, 2008, 3:24:17 PM12/5/08
to vim_use
Working with some Python code inside a pugin (python << EOF ...). In
GVim 7.2 it appears at though the entire block of code is highlighted
according to the Highlight Error section of the current color scheme.

Knowing that I will not likely get Python syntax highlighting inside a
Vimscript file, is there a configuration that will not make the
embedded code highlight as an error?

Tony Mechelynck

unread,
Dec 5, 2008, 4:03:10 PM12/5/08
to vim...@googlegroups.com

See ":help g:vimsyn_embed".

Apparently, by default the vim.vim syntax supports MzScheme, Python,
Perl and Ruby embedded scripts, *but only if your current Vim is
compiled with support for them*. I don't see how to mark as other than
error an embedded syntax not supported by your current Vim version, except:

Possibility 1) by extracting $VIMRUNTIME/syntax/vim.vim to (on Unix)
~/.vim/syntax/vim.vim or (on Windows) ~/vimfiles/syntax/vim.vim and
modifying the copy. Probably not worth the trouble.

Possibility 2) by availing yourself of a more poverful version of gvim.
See the following:

- Windows (pre-compiled installers with support for all 5 languages)
https://sourceforge.net/project/showfiles.php?group_id=43866&package_id=39721
Click the clipboard-like icon next to any download link to see which
features are compiled-in.

- Unix/Linux: how to compile Vim for yourself with the latest bugfixes
and the features you want:
http://users.skynet.be/antoine.mechelynck/vim/compunix.htm


Best regards,
Tony.
--
better !pout !cry
better watchout
lpr why
santa claus <north pole >town

cat /etc/passwd >list
ncheck list
ncheck list
cat list | grep naughty >nogiftlist
cat list | grep nice >giftlist
santa claus <north pole > town

who | grep sleeping
who | grep awake
who | egrep 'bad|good'
for (goodness sake) {
be good
}

Matt

unread,
Dec 5, 2008, 5:41:48 PM12/5/08
to vim_use
I am building current version 7.2 from source, with Python support
enabled (see :version from the console version output below, same
config for GUI). I have also verified that g:vimsyn_embed contains the
Python flag (g:vimsyn_embed = mpPr)

:version
VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Nov 28 2008 17:21:58)
MS-Windows 32-bit console version
Included patches: 1-49
Compiled by ___
Big version without GUI. Features included (+) or not (-):
-arabic +autocmd -balloon_eval -browse ++builtin_terms +byte_offset
+cindent +clientserver +clipboard +cmdline_compl
+cmdline_hist +cmdline_info +comments +cryptv +cscope +cursorshape
+dialog_con +diff +digraphs -dnd -ebcdic +emacs_tags
+eval +ex_extra +extra_search -farsi +file_in_path +find_in_path
+float +folding -footer +gettext/dyn -hangul_input
+iconv/dyn +insert_expand +jumplist +keymap +langmap +libcall
+linebreak +lispindent +listcmds +localmap +menu
+mksession +modify_fname +mouse -mouseshape +multi_byte +multi_lang -
mzscheme -netbeans_intg -osfiletype +path_extra
-perl -postscript +printer -profile +python/dyn +quickfix +reltime -
rightleft -ruby +scrollbind +signs +smartindent
-sniff +statusline -sun_workshop +syntax +tag_binary +tag_old_static -
tag_any_white -tcl -tgetent -termresponse
+textobjects +title -toolbar +user_commands +vertsplit +virtualedit
+visual +visualextra +viminfo +vreplace +wildignore
+wildmenu +windows +writebackup -xfontset -xim -xterm_save -xpm_w32
system vimrc file: "$VIM\vimrc"
user vimrc file: "$HOME\_vimrc"
2nd user vimrc file: "$VIM\_vimrc"
user exrc file: "$HOME\_exrc"
2nd user exrc file: "$VIM\_exrc"
Compilation: cl -c /W3 /nologo -I. -Iproto -DHAVE_PATHDEF -DWIN32 -
DFEAT_CSCOPE -DWINVER=0x0400 -D_WIN32_WINNT=0x0400 /Fo.\ObjCY/ /
Ox /GL -DNDEBUG /Zl /MT -DDYNAMIC_ICONV -DDYNAMIC_GETTEXT -
DFEAT_PYTHON -DDYNAMIC_PYTHON -DDYNAMIC_PYTHON_DLL=\"python26.dll\" -
DFEAT_BIG /Fd.\ObjCY/ /Zi
Linking: link /RELEASE /nologo /subsystem:console /LTCG:STATUS
oldnames.lib kernel32.lib advapi32.lib shell32.lib gdi32.lib
comdlg32.lib ole32.lib uuid.lib /machine:i386 /nodefaultlib
libcmt.lib user32.lib /nodefaultlib:python26.lib /
PDB:vim.pdb -debug

Tony Mechelynck

unread,
Dec 5, 2008, 6:39:29 PM12/5/08
to vim...@googlegroups.com
On 05/12/08 23:41, Matt wrote:
> I am building current version 7.2 from source, with Python support
> enabled (see :version from the console version output below, same
> config for GUI). I have also verified that g:vimsyn_embed contains the
> Python flag (g:vimsyn_embed = mpPr)
>
> :version
> VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Nov 28 2008 17:21:58)
> MS-Windows 32-bit console version
> Included patches: 1-49
> Compiled by ___
> Big version without GUI. Features included (+) or not (-):
[...]

> -perl -postscript +printer -profile +python/dyn +quickfix +reltime -
[...]

> Compilation: cl -c /W3 /nologo -I. -Iproto -DHAVE_PATHDEF -DWIN32 -
> DFEAT_CSCOPE -DWINVER=0x0400 -D_WIN32_WINNT=0x0400 /Fo.\ObjCY/ /
> Ox /GL -DNDEBUG /Zl /MT -DDYNAMIC_ICONV -DDYNAMIC_GETTEXT -
> DFEAT_PYTHON -DDYNAMIC_PYTHON -DDYNAMIC_PYTHON_DLL=\"python26.dll\" -
> DFEAT_BIG /Fd.\ObjCY/ /Zi
[...]

- This is a console version; in your previous post you talked about gvim
(a GUI version).
- Even if g:vimsyn_embed includes P it won't highlight Python code
embedded in vim scripts if Vim doesn't support Python _now_ (see below).
- This version is compiled with _dynamic_ Python support, which means it
will or won't support Python embedding depending on whether the file
python26.dll can be found at run-time.
- To know whether it has found the required DLL, type

:echo has('python')

in a running Vim. If the answer is zero, support of Python is not
included now (either because not compiled-in or because the required DLL
wasn't found).
- In particular, if your installed Python version is other than 2.6,
this version of Vim won't be able to use it.


Best regards,
Tony.
--
The real problem with fucking a sheep is that you have to walk around
in front every time you want to kiss her.

David Fishburn

unread,
Dec 5, 2008, 11:21:22 PM12/5/08
to vim...@googlegroups.com
On 12/5/08, Tony Mechelynck <antoine.m...@gmail.com> wrote:
>
> On 05/12/08 21:24, Matt wrote:
>> Working with some Python code inside a pugin (python<< EOF ...). In
>> GVim 7.2 it appears at though the entire block of code is highlighted
>> according to the Highlight Error section of the current color scheme.
>>
>> Knowing that I will not likely get Python syntax highlighting inside a
>> Vimscript file, is there a configuration that will not make the
>> embedded code highlight as an error?
>
> See ":help g:vimsyn_embed".
>
> Apparently, by default the vim.vim syntax supports MzScheme, Python,
> Perl and Ruby embedded scripts, *but only if your current Vim is
> compiled with support for them*. I don't see how to mark as other than
> error an embedded syntax not supported by your current Vim version, except:
>

I don't see this working, but I found out why.

I have a .vim file with embedded Perl.

:echo has('perl')
1

Specifically:
+perl/dyn


Looking and using:
breakadd file vim.vim

Stepping through I see this line:
if (g:vimsyn_embed =~ 'p' && has("perl")) &&
filereadable(expand("<sfile>:p:h")."/perl.vim")

:echo expand("<sfile>:p:h")."/perl.vim"

If by chance, you have an updated copy of vim.vim and it is sourced from:
\vim\vimfiles\syntax\vim.vim

Then the above expands to:
\vim\vimfiles\syntax\perl.vim

I don't have an "updated" copy of this file, I just have the regular
distribution file:
\vim\vim72\syntax\perl.vim

So this was never loading my file.

I think Charles is the maintainer of this file.

What happens if we just do a runtime syntax/perl.vim instead or
something that will test both locations, vim72 and vimfiles?

Once I deleted the updated copy, I starting getting highlighting as I wanted.

Tony, I am glad you mentioned this option, it has always bugged me
that the Perl code I have embedded was never highlighted.

Dave

Tony Mechelynck

unread,
Dec 6, 2008, 10:12:57 AM12/6/08
to vim...@googlegroups.com
On 06/12/08 05:21, David Fishburn wrote:
[...]

> Tony, I am glad you mentioned this option, it has always bugged me
> that the Perl code I have embedded was never highlighted.
>
> Dave

I had to search for it. First,

:help vim<Ctrl-D>

showed that there were many helptags named <filetype>.vim, or probably
more exactly <syntax>.vim. Examining the (big) list more closely showed
that vim.vim was one of them. So I did

:help vim.vim

and the needed info was there, half a page below that helptag.


Best regards,
Tony.
--
It's a good thing we don't get all the government we pay for.

Charles E. Campbell, Jr.

unread,
Dec 6, 2008, 10:39:18 AM12/6/08
to vim...@googlegroups.com
If for some reason you can't get your vim to be perl-enabled, you can
shut down error highlighting:

let g:vimsyn_noerror = 1

As Tony pointed out, the documentation for vimL (vim-Language) syntax
highlighting is available under
:help vim.vim
Its also available under
:help ft-vim-syntax

I'm not sure why you'd want to have embedded perl script in a vimL
script that your vim can't handle, though. Is it for use on a different
machine?

Regards,
Chip Campbell

Matt

unread,
Dec 8, 2008, 1:14:21 PM12/8/08
to vim_use
The console version was supplied as GVim on Windows does not let me
copy the results of the command, and I did not want to post a
screenshot. The compilation options are the same in my console and GUI
versions. :echo has('python') does return 1, Python 2.6 is the only
version installed, and it is in the path.


On Dec 5, 6:39 pm, Tony Mechelynck <antoine.mechely...@gmail.com>
wrote:

Matt

unread,
Dec 8, 2008, 1:33:37 PM12/8/08
to vim_use
It also looks like I made the boneheaded mistake of not updating my
runtime with updated .vim files when building new versions from
source. Following the path suggested by David, I discovered that some
of the source scripts were not current, and simply updating them
solved the problem (* smacks forehead *).

Tony Mechelynck

unread,
Dec 8, 2008, 7:42:00 PM12/8/08
to vim...@googlegroups.com
On 08/12/08 19:14, Matt wrote:
> The console version was supplied as GVim on Windows does not let me
> copy the results of the command, and I did not want to post a
> screenshot. The compilation options are the same in my console and GUI
> versions. :echo has('python') does return 1, Python 2.6 is the only
> version installed, and it is in the path.

[...]

To copy the ":version" text to the clipboard in gvim:

:redir @+
:version
:redir END

then paste into your mailer and snip away what (if anything) isn't needed

See ":help :redir"

This is how I got the following (not on Windows, but it works on Windows
too):


VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Dec 3 2008 14:54:30)
Included patches: 1-64
Extra patches: Extra float functions (Bill McCarthy)
Compiled by antoine.m...@skynet.be
Huge version with GTK2-GNOME GUI. Features included (+) or not (-):
+arabic +autocmd +balloon_eval +browse ++builtin_terms +byte_offset

+cindent +clientserver +clipboard +cmdline_compl +cmdline_hist
+cmdline_info +comments +cryptv

+cscope +cursorshape +dialog_con_gui +diff +digraphs +dnd -ebcdic
+emacs_tags +eval +ex_extra +extra_search +farsi +file_in_path
+find_in_path +float +folding
-footer +fork() +gettext -hangul_input +iconv +insert_expand +jumplist

+keymap +langmap +libcall +linebreak +lispindent +listcmds +localmap
+menu +mksession

+modify_fname +mouse +mouseshape +mouse_dec +mouse_gpm -mouse_jsbterm
+mouse_netterm -mouse_sysmouse +mouse_xterm +multi_byte +multi_lang
-mzscheme +netbeans_intg
-osfiletype +path_extra +perl +postscript +printer +profile +python
+quickfix +reltime +rightleft +ruby +scrollbind +signs +smartindent
-sniff +statusline
-sun_workshop +syntax +tag_binary -tag_old_static -tag_any_white +tcl
+terminfo +termresponse +textobjects +title +toolbar +user_commands

+vertsplit +virtualedit
+visual +visualextra +viminfo +vreplace +wildignore +wildmenu +windows

+writebackup +X11 -xfontset +xim +xsmp_interact +xterm_clipboard
+xterm_save
system vimrc file: "$VIM/vimrc"
user vimrc file: "$HOME/.vimrc"
user exrc file: "$HOME/.exrc"
system gvimrc file: "$VIM/gvimrc"
user gvimrc file: "$HOME/.gvimrc"
system menu file: "$VIMRUNTIME/menu.vim"
fall-back for $VIM: "/usr/local/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK
-I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0
-I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0
-I/usr/lib/glib-2.0/include -I/usr/include/pixman-1
-I/usr/include/freetype2 -I/usr/include/libpng12 -DORBIT2=1 -pthread
-I/usr/include/libgnomeui-2.0 -I/usr/include/libart-2.0
-I/usr/include/gconf/2 -I/usr/include/gnome-keyring-1
-I/usr/include/libgnome-2.0 -I/usr/include/libbonoboui-2.0
-I/usr/include/libgnomecanvas-2.0 -I/usr/include/gtk-2.0
-I/usr/include/gnome-vfs-2.0 -I/usr/lib/gnome-vfs-2.0/include
-I/usr/include/orbit-2.0 -I/usr/include/dbus-1.0
-I/usr/lib/dbus-1.0/include -I/usr/include/glib-2.0
-I/usr/lib/glib-2.0/include -I/usr/include/libbonobo-2.0
-I/usr/include/bonobo-activation-2.0 -I/usr/include/libxml2
-I/usr/include/pango-1.0 -I/usr/include/gail-1.0
-I/usr/include/freetype2 -I/usr/include/atk-1.0
-I/usr/lib/gtk-2.0/include -I/usr/include/cairo -I/usr/include/pixman-1
-I/usr/include/libpng12 -O2 -fno-strength-reduce -Wall
-D_FORTIFY_SOURCE=1 -D_REENTRANT -D_GNU_SOURCE -DPERL_USE_SAFE_PUTENV
-DDEBUGGING -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
-I/usr/lib/perl5/5.10.0/i586-linux-thread-multi/CORE
-I/usr/include/python2.6 -pthread -I/usr/include
-D_LARGEFILE64_SOURCE=1 -I/usr/lib/ruby/1.8/i586-linux
Linking: gcc -L. -rdynamic -Wl,-export-dynamic -Wl,-E
-Wl,-rpath,/usr/lib/perl5/5.10.0/i586-linux-thread-multi/CORE
-L/usr/local/lib -o vim -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0
-lgio-2.0 -lpangoft2-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lcairo
-lpango-1.0 -lfreetype -lz -lfontconfig -lgobject-2.0 -lgmodule-2.0
-lglib-2.0 -lgnomeui-2 -lbonoboui-2 -lgnomevfs-2 -lgnomecanvas-2
-lgnome-2 -lpopt -lbonobo-2 -lbonobo-activation -lORBit-2 -lart_lgpl_2
-lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0
-lgdk_pixbuf-2.0 -lpangocairo-1.0 -lcairo -lpango-1.0 -lfreetype -lz
-lfontconfig -lgconf-2 -lgthread-2.0 -lrt -lgmodule-2.0 -lgobject-2.0
-lglib-2.0 -lXt -lncurses -lacl -lgpm -Wl,-E
-Wl,-rpath,/usr/lib/perl5/5.10.0/i586-linux-thread-multi/CORE
-L/usr/lib/perl5/5.10.0/i586-linux-thread-multi/CORE -lperl -lutil -lc
-L/usr/lib/python2.6/config -lpython2.6 -lutil -Xlinker -export-dynamic
-L/usr/lib -ltcl8.5 -lieee -Wl,-R -Wl,/usr/lib -L/usr/lib -lruby -lm

Best regards,
Tony.
--
CONCORDE: Message for you, sir.
He falls forward revealing the arrow with the note.
"Monty Python and the Holy Grail" PYTHON (MONTY)
PICTURES LTD

Reply all
Reply to author
Forward
0 new messages