Question about 3rd-party packaging of Vim syntax highlighting macros
Kevin B. McCarty
kmccarty at Princeton.EDU
Fri Feb 9 19:56:54 UTC 2007
Hello Vim maintainers,
hopefully this is the right list! pkg-vim-group at l.a.d.o doesn't seem to
get any traffic but spam.
I have a question about packaging Vim add-ons for syntax coloring /
highlighting of file types related to Cernlib. Please CC replies to me
as I'm not subscribed to this list.
These file formats are pretty obscure, so rather than send the syntax
macros to you guys for inclusion in the Vim packages, I thought I could
just ship them in the cernlib-base package.
However I am having a little bit of trouble figuring out where to put
things and how to get them auto-detected by Vim. I did read the Vim
policy, but please note I am not a Vim scripting expert -- I just picked
up enough info to write the syntax macros yesterday -- so probably I'm
doing something wrong.
Attached please find the files "syntax-kuip.vim" which I am trying to
install to /usr/share/vim/addons/syntax/kuip.vim and "ftplugin-kuip.vim"
which I am trying to install to /usr/share/vim/addons/ftplugin/kuip.vim
When I do put them in those locations, Vim doesn't recognize that for a
file with name ending in .cdf, it should load the kuip syntax. However
if I explicitly tell it ":set syntax=kuip" it does load the highlighting
correctly, with the caveat at [*] below. So it appears that Vim finds
the syntax file automatically but perhaps not the ftplugin file.
I tried adding a file at /usr/share/vim/registry/cernlib-base.yaml
listing the above two files, in the same format as the .yaml file
provided by vim-latexsuite, but that didn't seem to change anything. How
should I be doing this?
[*] Finally, one more minor question. In some cases CDF files include a
block of C syntax. In "syntax/kuip.vim", line 51, I try to load this via:
syn include @kuipC <sfile>:p:h/c.vim
as recommended in the Vim help documentation. This would work if
kuip.vim was installed to the same place as c.vim, in
/usr/share/vim/vim70/syntax/; but since kuip.vim is instead in
.../addons/syntax/, it doesn't work. I suppose I could do one of these
instead:
syn include @kuipC /usr/share/vim/vim70/syntax/c.vim
syn include @kuipC <sfile>:p:h/../../vim70/syntax/c.vim
but either of these will fail as soon as a new version of Vim moves to a
different versioned directory. What should I be doing instead?
Thanks in advance for any help!
best regards,
--
Kevin B. McCarty <kmccarty at princeton.edu> Physics Department
WWW: http://www.princeton.edu/~kmccarty/ Princeton University
GPG: public key ID 4F83C751 Princeton, NJ 08544
-------------- next part --------------
" Vim syntax file
" Language: Cernlib KUIPC (Kit for a User Interface Compiler) CDF files
" Maintainer: Kevin B. McCarty <kmccarty at debian.org>
" Standard syntax initialization
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
" Case doesn't matter for us
syn case ignore
" generic definitions
syn match kuipDirective contained "^>\(Name\|menu\|command\|help_item\|guidance\|user_help\|parameters\|keyword\|action\|class\|graphics\|browse\|Icon_bitmaps\|Motif_customize\|Button\)"
syn region kuipArgument contained start=" " skip="_$" end="$" contains=kuipString,kuipParameterFormat
syn region kuipDefinition start="^>[^*]" skip="_$" end="$" contains=kuipDirective,kuipArgument keepend
syn match kuipNumber contained "\m[+-]\?\([0-9]\+\(\.[0-9]*\|\)\|\.[0-9]\+\)\(e[+-]\?[0-9]\+\)\?"
syn match kuipParseError "^\s*[^>*[:space:]].*$"
syn match kuipEmpty contained "^\s*$"
syn region kuipString start="'" skip="_$" end="\('\|$\)"
" comments
syn region kuipComment start="^\*" skip="_$" end="$"
syn region kuipBlockComment start="^>\*" end="^>"me=s-1
" informational text
syn region kuipGuidanceBlock start="^>\(Guidance\|Keyword\)\s*$" end="^>"me=s-1 contains=kuipDirective,kuipComment,kuipGuidanceSpacer
syn match kuipGuidanceSpacer contained "^\.\s*$"
" block of parameters
syn region kuipParametersBlock start="^>Parameters\s*$" end="^>"me=s-1 contains=kuipDirective,kuipParameterName,kuipParameterOption,kuipComment,kuipParameterFormat,kuipEmpty keepend
syn match kuipType contained "\s[CIR]\(\s\|$\)"
syn match kuipParameterFormat contained "\(^+\(\|+\)$\|^-\|\*\|%c\)"
syn match kuipParameterDefault contained "\([DR]\|Slider\)="me=e-1
syn keyword kuipParameterKeywords contained option loop vararg separate minus
syn region kuipParameterName contained start="^[a-z]" end="\s\S"me=s-1 nextgroup=kuipParameterDef contains=kuipParameterFormat oneline
syn region kuipParameterOption contained start="^-" end="\s\S"me=s-1 nextgroup=kuipParameterOptionDesc oneline
syn region kuipParameterDef contained start="[^>+\s]" skip="_$" end="$" contains=kuipString,kuipType,kuipParameterDefault,kuipNumber,kuipParameterKeywords
syn region kuipParameterOptionDesc contained start="[^>+\s]" skip="_$" end="$"
" block of browser or class statement
syn region kuipClassBlock start="^>\(Class\|Browse\)\(\s\|$\)" end="^>"me=s-1 contains=kuipDefinition,kuipMenuItem,kuipComment,kuipEmpty keepend
syn region kuipMenuItem contained start="^[^>*]" skip="_$" end="$" contains=kuipMenuString,kuipString,kuipParameterFormat,kuipMenuSpecial
syn match kuipMenuSpecial contained "\(\s\|^\)[/!]\+"
syn region kuipMenuString contained start="^[[:space:]/!]*[']"ms=e skip="_$" end="\($\|'\)" contains=kuipMenuSpecialString
syn match kuipMenuSpecialString contained "['][/!]\+"ms=s+1
" block of xpm icon data
syn include @kuipC <sfile>:p:h/c.vim
"syn include @kuipC /usr/share/vim/vim70/syntax/c.vim
syn region kuipIconBitmapsBlock start="^>Icon_bitmaps\s*$" end="^>"me=s-1 contains=kuipDirective, at kuipC
" Associate our matches and regions with pretty colours
if version >= 508 || !exists("did_kuip_syn_inits")
if version < 508
let did_kuip_syn_inits = 1
command -nargs=+ HiLink hi link <args>
else
command -nargs=+ HiLink hi def link <args>
endif
HiLink kuipComment Comment
HiLink kuipBlockComment Comment
HiLink kuipDirective Statement
HiLink kuipArgument Identifier
HiLink kuipString String
HiLink kuipGuidanceBlock Normal
HiLink kuipGuidanceSpacer SpecialChar
HiLink kuipEmpty Normal
HiLink kuipParametersBlock Error
HiLink kuipParametersDef Normal
HiLink kuipParameterFormat SpecialChar
HiLink kuipMenuSpecial SpecialChar
HiLink kuipParameterName Identifier
HiLink kuipParameterDefault Statement
HiLink kuipParameterKeywords Statement
HiLink kuipParameterOption Special
HiLink kuipParameterOptionDesc String
HiLink kuipMenuItem Identifier
HiLink kuipMenuString String
HiLink kuipMenuSpecialString SpecialChar
HiLink kuipNumber Number
HiLink kuipType Type
HiLink kuipParseError Error
delcommand HiLink
endif
let b:current_syntax = "kuip"
" vim: ts=8 sw=2
-------------- next part --------------
augroup filetypedetect
au BufNewFile,BufRead *.cdf setf kuip
augroup END
More information about the pkg-vim-maintainers
mailing list