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

Re: Syntax File - Using two languages in one file

Expand Messages
  • Francois Leblanc
    This might not answer your question but there s nothing to lose perhaps providing an alternative. There is a syntax file for doxygen on the vim web site:
    Message 1 of 2 , Nov 20, 2004
    • 0 Attachment
      This might not answer your question but there's nothing to lose perhaps
      providing an alternative. There is a syntax file for doxygen on the vim
      web site: http://www.vim.org/scripts/script.php?script_id=5

      Doxygen supports JavaDoc-style syntax and so this script can also
      highlight javadoc in c and c++ files. As far as how it does this, it is
      simply included inside the .c and .cpp syntax files. If it doesn't
      provide what you want at least it could provide some insight on how to
      highlight within comments and how to include a syntax file from another
      (ie: two syntaxes in one mapping).



      On 20-Nov-04, at 18:35, Max Baker wrote:

      > Hi vimmers,
      >
      > I am maintaining a syntax file for an obscure C variant.
      >
      > This variant has some javadoc constructs and some C++ constructs.
      > What I'ld
      > like to do is use the C and Java syntax types on different parts of the
      > file, and add a couple c++ style keywords.
      >
      > The problem I'm having is that if I'm in a comment section ,the code
      > and
      > comments are parsed as java. If I'm in a code section the code and
      > comments
      > are parsed like C. It seems to do with how far back it looks and what
      > it
      > decides at the moment. I'm a newbie at this.
      >
      > Inline at the bottom is what I have so far, any clues would be greatly
      > appreciated.
      >
      > Thanks,
      > -m
      >
      > ---------------------------------------------------------------
      > " Vim syntax file
      > " Language: NesC
      > " Original Author: Eric Osterweil http://nescc.sourceforge.net/
      > " Last change: 2003 Jul 02
      >
      > " For version 5.x: Clear all syntax items
      > " For version 6.x: Quit when a syntax file was already loaded
      > if version < 600
      > syntax clear
      > elseif exists("b:current_syntax")
      > finish
      > endif
      >
      > syn region ncCommentL start="/\*" end="\*/" contained
      > syn region ncCodeGroup start="\%^" end="\%$" contains=@ncCommentL
      >
      > " Read the C syntax to default
      > if version < 600
      > syn include @ncCodeGroup <sfile>:p:h/c.vim
      > else
      > syn include @ncCodeGroup syntax/c.vim
      > unlet b:current_syntax
      > endif
      >
      > " Read in Java to treat comments like Javadoc
      > if version < 600
      > syn include @ncCommentL <sfile>:p:h/java.vim
      > else
      > syn include @ncCommentL syntax/java.vim
      > unlet b:current_syntax
      > endif
      >
      > " getting both but weird. TODO
      >
      > " C++ extentions
      > syn keyword cppStatement new delete this friend using
      > syn keyword cppAccess public protected private
      > syn keyword cppType inline virtual explicit export bool wchar_t
      > syn keyword cppExceptions throw try catch
      > syn keyword cppOperator operator typeid
      > syn match cppCast
      > "\<\(const\|static\|dynamic\|reinterpret\)_cast\s*<"me=e-1
      > syn match cppCast
      > "\<\(const\|static\|dynamic\|reinterpret\)_cast\s*$"
      > syn keyword cppStorageClass mutable
      > syn keyword cppStructure class typename template namespace
      > syn keyword cppNumber NPOS
      > syn keyword cppBoolean true false
      >
      > " NesC extensions
      > syn keyword ncFunction command event task interface
      > syn keyword ncCall call post fire as
      > syn keyword ncPreProc includes
      > syn keyword ncInterface module implementation configuration
      > syn keyword ncWiring provides uses components
      >
      > " The minimum and maximum operators in GNU C++
      > syn match cppMinMax "[<>]?"
      >
      > " Default highlighting
      > if version >= 508 || !exists("did_nc_syntax_inits")
      > if version < 508
      > let did_nc_syntax_inits = 1
      > command -nargs=+ HiLink hi link <args>
      > else
      > command -nargs=+ HiLink hi def link <args>
      > endif
      > HiLink cppAccess cppStatement
      > HiLink cppCast cppStatement
      > HiLink cppExceptions cppStatement
      > HiLink cppOperator cppStatement
      > HiLink cppStatement Statement
      > HiLink cppType Type
      > HiLink cppStorageClass StorageClass
      > HiLink cppStructure Structure
      > HiLink cppNumber Number
      > HiLink cppBoolean Boolean
      > HiLink ncFunction Type
      > HiLink ncCall Statement
      > HiLink ncPreProc Structure
      > HiLink ncInterface cppStructure
      > HiLink ncWiring cppStatement
      > delcommand HiLink
      > endif
      >
      > let b:current_syntax = "nc"
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.