Reputation: 1114
I want to extend the filetype syntax and highlighting of an existing filetype. The basic structure of my new file syntax is as follows:
" Some local (new) syntax that I want to match
syn match upfOperator "[&|~><!)(*#%@+/=?:;}{,.\^\-\[\]]"
syn match upfDefines "\$\S\+"
syn match upfDefines "\${\S\+}"
syn match upfParens "[)(}{\[\]]"
" load syntax that I want to extend. This contains it's own highlight commands
runtime syntax/dtcl.vim
" New highlight statements
hi link upfOperator Statement
hi link upfDefines Constant
hi link upfParens Constant
The problem is that all the syntax contained in the dtcl.vim file is NOT highlighting. I am able to open a dctl file and the highlighting works. However, when I open the other filetype (*.upf) the upf.vim is loaded but NOT the dtcl.vim.
The dctl.vim doesn't have any "if syntax defined" type commands that would cause the file to not load.
Upvotes: 1
Views: 1069
Reputation: 172768
If dctl.vim is a proper Vim syntax script, it does clear any existing syntax items (:syntax clear
), as all syntaxes are supposed to be. Therefore, you have to move your own upf...
definitions below the :runtime
.
To properly load the existing syntax, you should use the following command:
runtime! syntax/dctl.vim syntax/dctl/*.vim
Your :runtime syntax/dctl.vim
only considers the first occurrence and no syntax extensions.
Other than that, I see no problems with your approach, as long as you only add some new syntax elements which aren't covered yet (if they are, you probably need to use containedin=...
in yours). You can use the :syn list
command to check what's actually defined.
Upvotes: 2