From 9197c69900514524a0101d88e663b452de09a98d Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Wed, 17 May 2017 11:18:30 +0200 Subject: [PATCH] Add asciidoc, closes #207 --- README.md | 1 + build | 1 + ftdetect/polyglot.vim | 6 ++ syntax/asciidoc.vim | 187 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 195 insertions(+) create mode 100644 syntax/asciidoc.vim diff --git a/README.md b/README.md index 3029b84..0f3e988 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,7 @@ If you need full functionality of any plugin, please use it directly with your p - [apiblueprint](https://github.com/sheerun/apiblueprint.vim) (syntax) - [applescript](https://github.com/vim-scripts/applescript.vim) (syntax) - [arduino](https://github.com/sudar/vim-arduino-syntax) (syntax, indent) +- [asciidoc](https://github.com/asciidoc/vim-asciidoc) (syntax) - [blade](https://github.com/jwalton512/vim-blade) (syntax, indent, ftplugin) - [c++11](https://github.com/octol/vim-cpp-enhanced-highlight) (syntax) - [c/c++](https://github.com/vim-jp/vim-cpp) (syntax) diff --git a/build b/build index 713368f..1c4cbb5 100755 --- a/build +++ b/build @@ -109,6 +109,7 @@ EOF PACKS=" apiblueprint:sheerun/apiblueprint.vim applescript:vim-scripts/applescript.vim + asciidoc:asciidoc/vim-asciidoc yaml:stephpy/vim-yaml ansible:pearofducks/ansible-vim arduino:sudar/vim-arduino-syntax diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index d8be268..b00f0f8 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -20,6 +20,12 @@ augroup filetypedetect " applescript:vim-scripts/applescript.vim augroup END +augroup filetypedetect +" asciidoc:asciidoc/vim-asciidoc +autocmd BufNewFile,BufRead *.asciidoc,*.adoc + \ set ft=asciidoc +augroup END + augroup filetypedetect " yaml:stephpy/vim-yaml augroup END diff --git a/syntax/asciidoc.vim b/syntax/asciidoc.vim new file mode 100644 index 0000000..eec6529 --- /dev/null +++ b/syntax/asciidoc.vim @@ -0,0 +1,187 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'asciidoc') == -1 + +" Vim syntax file +" Language: AsciiDoc +" Author: Stuart Rackham (inspired by Felix +" Obenhuber's original asciidoc.vim script). +" URL: http://asciidoc.org/ +" Licence: GPL (http://www.gnu.org) +" Remarks: Vim 6 or greater +" Limitations: +" +" - Nested quoted text formatting is highlighted according to the outer +" format. +" - If a closing Example Block delimiter may be mistaken for a title +" underline. A workaround is to insert a blank line before the closing +" delimiter. +" - Lines within a paragraph starting with equals characters are +" highlighted as single-line titles. +" - Lines within a paragraph beginning with a period are highlighted as +" block titles. + + +if exists("b:current_syntax") + finish +endif + +syn clear +syn sync fromstart +syn sync linebreaks=100 + +" Run :help syn-priority to review syntax matching priority. +syn keyword asciidocToDo TODO FIXME CHECK TEST XXX ZZZ DEPRECATED +syn match asciidocBackslash /\\/ +syn region asciidocIdMarker start=/^\$Id:\s/ end=/\s\$$/ +syn match asciidocCallout /\\\@/ +syn match asciidocOpenBlockDelimiter /^--$/ +syn match asciidocLineBreak /[ \t]+$/ containedin=asciidocList +syn match asciidocRuler /^'\{3,}$/ +syn match asciidocPagebreak /^<\{3,}$/ +syn match asciidocEntityRef /\\\@\?[0-9A-Za-z_]\@!/ +syn match asciidocAttributeRef /\\\@.]\{,3}\)\?\([a-z]\)\?\)\?|/ containedin=asciidocTableBlock contained +syn region asciidocTableBlock matchgroup=asciidocTableDelimiter start=/^|=\{3,}$/ end=/^|=\{3,}$/ keepend contains=ALL +syn match asciidocTablePrefix /\(\S\@.]\{,3}\)\?\([a-z]\)\?\)\?!/ containedin=asciidocTableBlock contained +syn region asciidocTableBlock2 matchgroup=asciidocTableDelimiter2 start=/^!=\{3,}$/ end=/^!=\{3,}$/ keepend contains=ALL + +syn match asciidocListContinuation /^+$/ +syn region asciidocLiteralBlock start=/^\.\{4,}$/ end=/^\.\{4,}$/ contains=asciidocCallout,asciidocToDo keepend +syn region asciidocListingBlock start=/^-\{4,}$/ end=/^-\{4,}$/ contains=asciidocCallout,asciidocToDo keepend +syn region asciidocCommentBlock start="^/\{4,}$" end="^/\{4,}$" contains=asciidocToDo +syn region asciidocPassthroughBlock start="^+\{4,}$" end="^+\{4,}$" + +" Allowing leading \w characters in the filter delimiter is to accomodate +" the pre version 8.2.7 syntax and may be removed in future releases. +syn region asciidocFilterBlock start=/^\w*\~\{4,}$/ end=/^\w*\~\{4,}$/ + +syn region asciidocMacroAttributes matchgroup=asciidocRefMacro start=/\\\@>\)\|^$/ contains=asciidocQuoted.* keepend +syn region asciidocMacroAttributes matchgroup=asciidocAnchorMacro start=/\\\@