Loading ...
Sorry, an error occurred while loading the content.

15496Re: WSH (Windows Scripting Host) syntax file

Expand Messages
  • Bram Moolenaar
    Oct 2 1:45 PM
      Paul Moore wrote:

      > Attached is a syntax file for WSH (Windows Scripting Host) files. The file
      > extension is .wsf (not .wsh!). I wrapped a couple of syn region lines so my
      > mailer doesn't do it. You'll need to rejoin them manually.

      Looks OK, I'll include it (with a few modifications, see below).

      > It's a nice example of reusing other syntax files.
      > Some points.
      > 1. I use "runtime syntax/xml.vim" to load the base XML highlighting. Only
      > one problem, I'd like this to *fail* if xml.vim isn't available, as
      > continuing without the xml stuff is a bit meaningless. I could use :source
      > <sfile>:p:h/xml.vim, but that relies on wsh.vim being installed in the same
      > directory as xml.vim (which it won't be, unless/until it's accepted into the
      > standard distribution). It would be nice to have a version of :runtime which
      > failed if the file could not be found.

      Ehm, fail in what way? Normally it would then produce an error message, and
      your script still continues (with more errors).

      You could test if b:current_syntax has been set to "xml". If it isn't,
      something went wrong.

      > 2. Similarly, it would be nice to be able to do the "syn include" statements
      > without needing to explicitly specify the directory. In general, I suspect
      > we need a "find a file on the runtimepath" function, here... It probably
      > should be widely used (it won't be at the moment, because the runtimepath
      > stuff is new) so could do with being a builtin.

      Hmm, ":syn include" is like searching for a syntax file to include. We could
      search 'runtimepath' for the file. But previously it included the full path,
      which conflicts with using just the file name.

      I suppose adding a new :syntax sub-command will be the simplest solution.
      ":syn includepath"? Or an extra argument: ":syn include path"?

      This is the file as I would include it for Vim 5.7:

      " Vim syntax file
      " Language: Windows Scripting Host
      " Maintainer: Paul Moore <gustav@...>
      " Last Change: 01 Oct 2000

      " This reuses the XML, VB and JavaScript syntax files. While VB is not
      " VBScript, it's close enough for us. No attempt is made to handle
      " other languages.
      " Send comments, suggestions and requests to the maintainer.

      source <sfile>:p:h/xml.vim

      syn case ignore
      syn include @wshVBScript <sfile>:p:h/vb.vim
      syn include @wshJavaScript <sfile>:p:h/javascript.vim
      syn region wshVBScript matchgroup=xmlTag start="<script[^>]*VBScript[^>]*>" end="</script>" contains=@wshVBScript
      syn region wshJavaScript matchgroup=xmlTag start="<script[^>]*J\(ava\)\=Script[^>]*>" end="</script>" contains=@wshJavaScript

      if !exists("did_wsh_syntax_inits")
      let did_wsh_syntax_inits = 1
      " No type-specific highlighting -- it's all reused from other files

      let b:current_syntax = "wsh"

      hundred-and-one symptoms of being an internet addict:
      134. You consider bandwidth to be more important than carats.

      /// Bram Moolenaar Bram@... http://www.moolenaar.net \\\
      \\\ Vim: http://www.vim.org ICCF Holland: http://iccf-holland.org ///
    • Show all 7 messages in this topic