Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Vim yodl syntax highlighting
- X-seq: zsh-workers 35703
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Vim yodl syntax highlighting
- Date: Mon, 6 Jul 2015 14:12:33 +0000
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=content-type:date:from:message-id :mime-version:subject:to:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=uEr JtjpP+n+k/UbVhvQy3wzcFW0=; b=PU3SLeLvLxijYJswSGOIQrLr5nL1vAZDAMg uOzoQPoxrDhVamWeJkWQ2h5XWLUT+c3tYlSPLN+krWPegs6g/eboHWG4SViTImPt FKa9B/JWvCBBbVLwIrrBAKxVvChb2kEU2DN9bJAfR0U3G1o1gNNxa6in3UUj6q24 NMriRs74=
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:message-id :mime-version:subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=uE rJtjpP+n+k/UbVhvQy3wzcFW0=; b=e/IY2d5qk25TNNgvX5D673RfjkwCXXuR+y 8JBQU2E0kUupD6uoJDbK81njkT5WdQ3Ti8TwRPN8txP82g8tZcN77PmloJDZNev0 llBqp3bMTd7Po0WLqoeKqbOpAgbuh7x8IY9yId6ikbNFZMdoYgYfbiBkXEK8QFhH sGDe2oCF8=
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
I've sketched a Vim syntax file for zsh yodl files. Not perfect yet but
better than no highlighting at all.
At this time there are two known issues:
- Parentheses that aren't part of a yodl macro confuse the parsing; example:
chapter(foo (bar) baz)
- Macros nested within an underlined thing don't get underlined; example:
sitem(foo)(bar tt(baz))
---
To test this, source it after opening a yodl file.
To install it permanently, save the attachment as ~/.vim/syntax/zyodl.vim
and put
autocmd! BufRead,BufNewFile **/Doc/Zsh/*.yo setfiletype zyodl
somewhere. Putting it in vimrc is good enough, see ':help new-filetype'
for the official way.
---
I think all these macros are zsh specific (even 'chapter' and 'bf' are
defined in ztexi.yo), as opposed to yodl builtins.
Should this live in the zsh repository? If it's useful to people it
should live alongside the code, but if it's just me, I'll throw it on my
personal github account.
"" Test case:
" if 0
" i
" texinode()()()()
" chapter(foo)
" chapter(foo (foo) foo)
" vindex(foo)
" foo tt(foo) var(foo) bf(foo) em(foo) foo
" xitem(foo)
" item(foo)(foo)
" sitem(foo)(foo tt(foo) foo)
" example(print *.c+LPAR()#q:s/#%+LPAR()#b+RPAR()s+LPAR()*+RPAR().c/'S${match[1]}.C'/+RPAR())
" ifzman(zmanref(zshmisc))ifnzman(noderef(Redirection))
" LPAR()foo 42 foo+RPAR()
" .
" endif
"" Syntax groups:
syn clear
syn cluster zyodlInline contains=zyodlTt,zyodlVar,zyodlBold,zyodlEmph,zyodlCond
syn region zyodlTt start="\<tt(" end=")" contains=zyodlSpecial
syn region zyodlVar start="\<var(" end=")" contains=zyodlSpecial
syn region zyodlBold start="\<bf(" end=")" contains=zyodlSpecial
syn region zyodlEmph start="\<em(" end=")" contains=zyodlSpecial
syn region zyodlIndex start="\<.index(" end=")" contains=zyodlSpecial
syn match zyodlSpecial "+\?\<\(LPAR\|RPAR\|PLUS\)()"
syn match zyodlNumber "\d\+"
syn region zyodlItem start="\<xitem(" end=")" contains=zyodlSpecial,@zyodlInline
syn region zyodlItem start="\<item(" end=")" contains=zyodlSpecial,@zyodlInline
syn region zyodlExample start="\<example(" end=")" contains=zyodlSpecial
syn region zyodlTitle start="\<\(chapter\|subsect\|sect\)(" end=")" contains=zyodlSpecial,@zyodlInline
syn match zyodlTitle "^texinode\%x28.*$"
syn region zyodlCond start="\<\(ifzman\|ifnzman\)(" end=")" contains=zyodlRef,zyodlSpecial,@zyodlInline
syn region zyodlRef start="\<\(zmanref\|noderef\)(" end=")"
syn keyword zyodlKeyword sitem nextgroup=zyodlSItemArg1
syn region zyodlSItemArg1 oneline start="(" end=")" contains=zyodlSpecial,@zyodlInline nextgroup=zyodlSItemArg2 contained
syn region zyodlSItemArg2 start="(" end=")" contains=zyodlSpecial,@zyodlInline contained
"" Highlight groups:
hi def link zyodlTt Constant
hi def link zyodlVar Identifier
" Not ':hi def link zyodlBold Bold' since there's no such group.
hi def zyodlBold gui=bold cterm=bold
hi def link zyodlEmph Type
hi def link zyodlIndex Comment
hi def link zyodlSpecial Special
hi def link zyodlNumber Number
hi def link zyodlItem Keyword
hi def link zyodlExample String
hi def link zyodlTitle Title
hi def link zyodlCond Conditional
hi def link zyodlRef Include
hi def link zyodlSItemArg1 Macro
hi def link zyodlSItemArg2 Underlined
Messages sorted by:
Reverse Date,
Date,
Thread,
Author