From: Simon Ruderich Date: Sun, 26 Apr 2009 10:40:27 +0000 (+0200) Subject: asciidoc: Add syntax and ftdetect file, version 8.4.4. X-Git-Url: https://ruderich.org/simon/gitweb/?a=commitdiff_plain;h=1a38d5256b9a89106ab9361328fa907055427420;p=config%2Fdotfiles.git asciidoc: Add syntax and ftdetect file, version 8.4.4. AsciiDoc is a simple but powerful text markup. --- diff --git a/ftdetect/asciidoc_filetype.vim b/ftdetect/asciidoc_filetype.vim new file mode 100644 index 0000000..4180ab0 --- /dev/null +++ b/ftdetect/asciidoc_filetype.vim @@ -0,0 +1,53 @@ +" Vim filetype detection file +" Language: AsciiDoc +" Author: Stuart Rackham +" Last Change: AsciiDoc 8.2.0 +" URL: http://www.methods.co.nz/asciidoc/ +" Licence: GPL (http://www.gnu.org) +" Remarks: Vim 6 or greater + +" COMMENT OUT ONE OF THE TWO FOLLOWING COMMANDS +" The first sets asciidoc syntax highlighting on all .txt files, the second +" only existing files *.txt that appear to be AsciiDoc files. + +au BufNewFile,BufRead *.txt,README,TODO,CHANGELOG,NOTES setfiletype asciidoc +"au BufRead *.txt,README,TODO,CHANGELOG,NOTES call s:FTasciidoc() + +" This function checks for a valid AsciiDoc document title after first +" skipping any leading comments. +function! s:FTasciidoc() + let in_comment_block = 0 + let n = 1 + while n < 50 + let line = getline(n) + let n = n + 1 + if line =~ '^/\{4,}$' + if ! in_comment_block + let in_comment_block = 1 + else + let in_comment_block = 0 + endif + continue + endif + if in_comment_block + continue + endif + if line !~ '\(^//\)\|\(^\s*$\)' + break + endif + endwhile + if line !~ '.\{3,}' + return + endif + let len = len(line) + let line = getline(n) + if line !~ '[-=]\{3,}' + return + endif + if len < len(line) - 3 || len > len(line) + 3 + return + endif + setfiletype asciidoc +endfunction + +" vim: et sw=2 ts=2 sts=2: diff --git a/syntax/asciidoc.vim b/syntax/asciidoc.vim new file mode 100644 index 0000000..0bf51f0 --- /dev/null +++ b/syntax/asciidoc.vim @@ -0,0 +1,166 @@ +" Vim syntax file +" Language: AsciiDoc +" Author: Stuart Rackham (inspired by Felix +" Obenhuber's original asciidoc.vim script). +" URL: http://www.methods.co.nz/asciidoc/ +" Licence: GPL (http://www.gnu.org) +" Remarks: Vim 6 or greater +" Limitations: See 'Appendix E: Vim Syntax Highlighter' in the AsciiDoc 'User +" Guide'. + +if exists("b:current_syntax") + finish +endif + +syn clear +syn sync fromstart +syn sync linebreaks=1 + +" Run :help syn-priority to review syntax matching priority. +syn keyword asciidocToDo TODO FIXME XXX ZZZ +syn match asciidocBackslash /\\/ +syn region asciidocIdMarker start=/^\$Id:\s/ end=/\s\$$/ +syn match asciidocCallout /\\\@/ +syn match asciidocListBlockDelimiter /^--$/ +syn match asciidocLineBreak /[ \t]+$/ +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 keepend +syn region asciidocOpenBlock start=/^-\{4,}$/ end=/^-\{4,}$/ contains=asciidocCallout 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=/\\\@