zsh-workers
 help / color / mirror / code / Atom feed
* Vim yodl syntax highlighting
@ 2015-07-06 14:12 Daniel Shahaf
  2015-07-06 18:46 ` Jason Spiro
  2015-07-06 22:31 ` Bart Schaefer
  0 siblings, 2 replies; 10+ messages in thread
From: Daniel Shahaf @ 2015-07-06 14:12 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 956 bytes --]

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.

[-- Attachment #2: zyodl.vim --]
[-- Type: text/plain, Size: 2335 bytes --]


"" 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


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2015-07-13 23:28 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-06 14:12 Vim yodl syntax highlighting Daniel Shahaf
2015-07-06 18:46 ` Jason Spiro
2015-07-06 19:02   ` Jason Spiro
2015-07-10 17:57   ` Daniel Shahaf
2015-07-06 22:31 ` Bart Schaefer
2015-07-10 18:14   ` Daniel Shahaf
2015-07-11  0:01     ` Bart Schaefer
2015-07-12  6:51       ` [PATCH] " Daniel Shahaf
2015-07-13 15:08         ` Bart Schaefer
2015-07-13 23:16           ` Daniel Shahaf

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).