On 13-Aug-2013 18:46 +0200, ZyX wrote: > I see that all g:vimsyn_embed flags say things like “embed … **(but > only if vim supports it)**”. This is ridiculous: you don’t have to > have vim lua support to code in lua and have syntax highlighting; you > specifically don’t have to have vim lua support to write or watch > lua<<EOF sections; and it is completely possible for oneself to want > to review {interp}<<EOF sections in foreign plugins before deciding > whether he needs to obtain Vim with {interp} support or (my case) to > watch correct highlighting of his own vimrc on machine without > specific interpreter support. > > I thus see no reason for using `(g:vimsyn_embed =~ 'p' && > has("perl"))` checks without any option to always highlight embedded > perl code. If the intention is to indicate that interpreter is not > supported then the only place where `has("perl")` should be present is > the section where `g:vimsyn_embed` default value is computed: those > (almost every vim user) who do not set `g:vimsyn_embed` will not > notice any change in behavior, those who care will always receive > correct highlighting.
I came to the same conclusion: While it is noble that the Vim syntax plugin notifies the user that the used script interpreter is not available in the current editor, having huge blocks of red error highlighting is certainly overdoing it and counterproductive, because, as we all know, reality isn't either black or white, and situations like these do happen. When I encountered this "wall of red", I pragmatically patched my syntax/vim.vim (7.4a-03 ASTRO-ONLY) to only highlight the interpreter command itself, not the whole block, and as warning in place of error. The following patch is for Perl and Python (the two languages I'm concerned with) only, but I'd be trivial to extend to all languages. Charles, would you please consider including something like that? (Maybe conditionally with a config variable, if there are indeed purists that prefer the status quo, though none have spoken up so far in this thread.) -- regards, ingo -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
--- syntax/vim.vim.orig 2013-07-16 22:41:58.000000000 +0200 +++ syntax/vim.vim 2013-07-22 09:06:54.952012300 +0200 @@ -588,31 +588,24 @@ unlet s:luapath " [-- perl --] {{{3 -let s:perlpath= fnameescape(expand("<sfile>:p:h")."/perl.vim") -if !filereadable(s:perlpath) - for s:perlpath in split(globpath(&rtp,"syntax/perl.vim"),"\n") - if filereadable(fnameescape(s:perlpath)) - let s:perlpath= fnameescape(s:perlpath) - break - endif - endfor -endif -if (g:vimsyn_embed =~ 'p' && has("perl")) && filereadable(s:perlpath) +if g:vimsyn_embed =~ 'p' unlet! b:current_syntax - exe "syn include @vimPerlScript ".s:perlpath + syn include @vimPerlScript syntax/perl.vim + let s:perlgroup = 'vimScriptDelim' + if !has("perl") + let s:perlgroup = 'vimEmbedWarning' + syn keyword vimEmbedWarning pe[rl] perld[o] contained containedin=vimIsCommand + endif if exists("g:vimsyn_folding") && g:vimsyn_folding =~ 'p' - syn region vimPerlRegion fold matchgroup=vimScriptDelim start=+pe\%[rl]\s*<<\s*\z(.*\)$+ end=+^\z1$+ contains=@vimPerlScript - syn region vimPerlRegion fold matchgroup=vimScriptDelim start=+pe\%[rl]\s*<<\s*$+ end=+\.$+ contains=@vimPerlScript + exe 'syn region vimPerlRegion fold matchgroup=' . s:perlgroup 'start=+pe\%[rl]\s*<<\s*\z(.*\)$+ end=+^\z1$+ contains=@vimPerlScript' + exe 'syn region vimPerlRegion fold matchgroup=' . s:perlgroup 'start=+pe\%[rl]\s*<<\s*$+ end=+\.$+ contains=@vimPerlScript' else - syn region vimPerlRegion matchgroup=vimScriptDelim start=+pe\%[rl]\s*<<\s*\z(.*\)$+ end=+^\z1$+ contains=@vimPerlScript - syn region vimPerlRegion matchgroup=vimScriptDelim start=+pe\%[rl]\s*<<\s*$+ end=+\.$+ contains=@vimPerlScript + exe 'syn region vimPerlRegion matchgroup=' . s:perlgroup 'start=+pe\%[rl]\s*<<\s*\z(.*\)$+ end=+^\z1$+ contains=@vimPerlScript' + exe 'syn region vimPerlRegion matchgroup=' . s:perlgroup 'start=+pe\%[rl]\s*<<\s*$+ end=+\.$+ contains=@vimPerlScript' endif + unlet s:perlgroup syn cluster vimFuncBodyList add=vimPerlRegion -else - syn region vimEmbedError start=+pe\%[rl]\s*<<\s*\z(.*\)$+ end=+^\z1$+ - syn region vimEmbedError start=+pe\%[rl]\s*<<\s*$+ end=+\.$+ endif -unlet s:perlpath " [-- ruby --] {{{3 let s:rubypath= fnameescape(expand("<sfile>:p:h")."/ruby.vim") @@ -641,18 +634,19 @@ unlet s:rubypath " [-- python --] {{{3 -let s:pythonpath= fnameescape(expand("<sfile>:p:h")."/python.vim") -if !filereadable(s:pythonpath) - for s:pythonpath in split(globpath(&rtp,"syntax/python.vim"),"\n") - if filereadable(fnameescape(s:pythonpath)) - let s:pythonpath= fnameescape(s:pythonpath) - break - endif - endfor -endif -if g:vimsyn_embed =~ 'P' && (has("python") || has("python3")) && filereadable(s:pythonpath) +if g:vimsyn_embed =~ 'P' && (has("python") || has("python3")) unlet! b:current_syntax - exe "syn include @vimPythonScript ".s:pythonpath + syn include @vimPythonScript syntax/python.vim + let s:pythongroup = 'vimScriptDelim' + if ! has("python") + let s:pythongroup = 'vimEmbedWarning' + syn keyword vimEmbedWarning py[thon] contained containedin=vimIsCommand + endif + let s:python3group = 'vimScriptDelim' + if ! has("python3") + let s:python3group = 'vimEmbedWarning' + syn keyword vimEmbedWarning py3 python3 contained containedin=vimIsCommand + endif if exists("g:vimsyn_folding") && g:vimsyn_folding =~ 'P' syn region vimPythonRegion fold matchgroup=vimScriptDelim start=+py\%[thon]3\=\s*<<\s*\z(.*\)$+ end=+^\z1$+ contains=@vimPythonScript syn region vimPythonRegion fold matchgroup=vimScriptDelim start=+py\%[thon]3\=\s*<<\s*$+ end=+\.$+ contains=@vimPythonScript @@ -665,7 +659,6 @@ syn region vimEmbedError start=+py\%[thon]3\=\s*<<\s*\z(.*\)$+ end=+^\z1$+ syn region vimEmbedError start=+py\%[thon]3\=\s*<<\s*$+ end=+\.$+ endif -unlet s:pythonpath " [-- tcl --] {{{3 if has("win32") || has("win95") || has("win64") || has("win16") @@ -794,6 +787,7 @@ hi def link vimEchoHL vimCommand hi def link vimElseIfErr Error hi def link vimElseif vimCondHL +hi def link vimEmbedWarning vimWarn hi def link vimEnvvar PreProc hi def link vimError Error hi def link vimFBVar vimVar