about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDaniel Shahaf <d.s@daniel.shahaf.name>2015-07-11 09:18:20 +0000
committerDaniel Shahaf <d.s@daniel.shahaf.name>2015-07-13 23:22:19 +0000
commitca2ab5e446bcf40e18de4390ee1b47c8295b5728 (patch)
tree660a723a9ae314d877ad32c5970d6c257a3ad1a8
parent35ffe36318955d03fca3df0d34a0997970cfc6a3 (diff)
downloadzsh-ca2ab5e446bcf40e18de4390ee1b47c8295b5728.tar.gz
zsh-ca2ab5e446bcf40e18de4390ee1b47c8295b5728.tar.xz
zsh-ca2ab5e446bcf40e18de4390ee1b47c8295b5728.zip
35775: New zsh-specific yodl vim syntax highlighting.
To try this, see the instructions at the top of Util/zyodl.vim (in the comment).

* Util/zyodl.vim: New syntax highlighting file.
* Doc/Zsh/.vimrc: New file, hooks up zyodl.vim for automatic loading.
* Etc/zsh-development-guide: Namedrop zyodl.vim for discoverability.
-rw-r--r--ChangeLog5
-rw-r--r--Doc/Zsh/.vimrc4
-rw-r--r--Etc/zsh-development-guide3
-rw-r--r--Util/zyodl.vim74
4 files changed, 86 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 38d64d458..4eefc62a1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2015-07-13  Daniel Shahaf  <d.s@daniel.shahaf.name>
 
+	* 35775: Doc/Zsh/.vimrc Etc/zsh-development-guide Util/zyodl.vim:
+	New zsh-specific yodl vim syntax highlighting.
+
+2015-07-13  Daniel Shahaf  <d.s@daniel.shahaf.name>
+
 	* 35769: Functions/Zle/edit-command-line: edit-command-line:
 	Go to the right byte offset
 
diff --git a/Doc/Zsh/.vimrc b/Doc/Zsh/.vimrc
new file mode 100644
index 000000000..6544cd450
--- /dev/null
+++ b/Doc/Zsh/.vimrc
@@ -0,0 +1,4 @@
+augroup filetypedetect
+  autocmd BufRead,BufNewFile **/Doc/Zsh/*.yo set ft=zyodl | source <sfile>:h:h:h/Util/zyodl.vim
+  "autocmd BufRead,BufNewFile **/Etc/FAQ.yo  set ft=zyodl | source <sfile>:h:h:h/Util/zyodl.vim
+augroup END
diff --git a/Etc/zsh-development-guide b/Etc/zsh-development-guide
index d92b72456..4d6cefd1e 100644
--- a/Etc/zsh-development-guide
+++ b/Etc/zsh-development-guide
@@ -920,6 +920,9 @@ Documentation
   surrounding text.  No extra newlines after the opening or before the
   closing parenthesis are required.
 
+A syntax highlighting file for Vim is included, just source tt(Doc/Zsh/.vimrc)
+before editing one of the Doc/Zsh/*.yo files.
+
 Module names
 ------------
 
diff --git a/Util/zyodl.vim b/Util/zyodl.vim
new file mode 100644
index 000000000..db2a599ca
--- /dev/null
+++ b/Util/zyodl.vim
@@ -0,0 +1,74 @@
+
+"" A Vim syntax highlighting file for Doc/Zsh/*.yo
+
+" To try this, run:
+"     cd Doc/Zsh && vim --cmd "source ./.vimrc" zle.yo
+" (This sources the file <Doc/Zsh/.vimrc>.)
+"
+" To install this permanently:
+" 1. Copy this file to ~/.vim/syntax/zyodl.vim
+" 2. Create ~/.vim/filetype.vim as explained in ":help new-filetype" case C.
+" 3. Add the following command to ~/.vim/filetype.vim:
+"      autocmd BufRead,BufNewFile **/Doc/Zsh/*.yo setfiletype zyodl
+
+"" Test case:
+"   texinode()()()()
+"   chapter(foo)
+"   vindex(foo) 
+"   foo tt(foo) var(foo) bf(foo) em(foo) foo
+"   xitem(foo)
+"   item(foo)(foo)
+"   sitem(foo)(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()
+"
+"   chapter(foo (foo) foo) # nested parentheses
+"   sitem(foo)(foo tt(foo) foo) # nested underline
+
+if exists("b:current_syntax")
+  finish
+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
+
+let b:current_syntax = "zyodl"
+