From ef4435cffcc6e30d51feb76d34b9061b0f2e5550 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Thu, 23 Mar 2017 13:21:01 +0100 Subject: [PATCH] Add api blueprint support, closes #182 --- README.md | 1 + build | 1 + ftdetect/polyglot.vim | 7 +++++++ syntax/apiblueprint.vim | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 47 insertions(+) create mode 100644 syntax/apiblueprint.vim diff --git a/README.md b/README.md index eb6dd18..40ceb02 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,7 @@ If you need full functionality of any plugin, please use it directly with your p ## Language packs - [ansible](https://github.com/pearofducks/ansible-vim) (syntax, indent, ftplugin) +- [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) - [blade](https://github.com/jwalton512/vim-blade) (syntax, indent, ftplugin) diff --git a/build b/build index fb77b26..6cb99f5 100755 --- a/build +++ b/build @@ -104,6 +104,7 @@ EOF } PACKS=" + apiblueprint:sheerun/apiblueprint.vim applescript:vim-scripts/applescript.vim yaml:stephpy/vim-yaml ansible:pearofducks/ansible-vim diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index 6ff0957..63248b9 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -1,3 +1,10 @@ +augroup filetypedetect +" apiblueprint:sheerun/apiblueprint.vim +autocmd BufReadPost,BufNewFile *.apib set filetype=apiblueprint +autocmd FileType apiblueprint set syntax=apiblueprint +autocmd FileType apiblueprint set makeprg=drafter\ -l\ % +augroup END + augroup filetypedetect " applescript:vim-scripts/applescript.vim augroup END diff --git a/syntax/apiblueprint.vim b/syntax/apiblueprint.vim new file mode 100644 index 0000000..90d3638 --- /dev/null +++ b/syntax/apiblueprint.vim @@ -0,0 +1,38 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'apiblueprint') == -1 + +runtime! syntax/markdown.vim +unlet! b:current_syntax + +" Metadata +syntax region apibMarkdownMetadata start=/\%^.*:.*$/ end=/^$/ contains=apibMarkdownMetadataKey,apibMarkdownMetadataValue fold +syntax match apibMarkdownMetadataKey /^[^:]*\ze:/ contained +syntax match apibMarkdownMetadataValue /:.*/ contained + +syntax region apibHTTPStatusCode start=/\d\d\d/ end=// contained containedin=apibResponseSection +syntax region apibHTTPContentType start=/(.*)/ end=// contained containedin=apibResponseSection + +syntax region apibModelSection start=/^+ Model/ end=/$/ oneline +syntax region apibRequestSection start=/^[-+*] Request.*/ end=/^$/ contains=apibHTTPContentType +syntax region apibResponseSection start=/^[-+*] Response \d\d\d/ end=/^$/ contains=apibHTTPStatusCode,apibHTTPContentType +syntax region apibHeadersSection start=/^+ Headers$/ end=/^\S.*$/ contains=apibHeadersSectionKey,apibHeadersSectionValue + +syntax region apibActionRelationKey start=/: .*/ end=/$/ contained +syntax region apibActionRelation start=/^[-+*] Relation: .*$/ end=/$/ oneline contains=apibActionRelationKey + +syntax match apibHeadersSectionKey /^[^:]*\ze:/ contained +syntax match apibHeadersSectionValue /:.*/ contained + +highlight default link apibMarkdownMetadataKey Function +highlight default link apibRequestSection Function +highlight default link apibResponseSection Function +highlight default link apibModelSection Function +highlight default link apibHeadersSectionKey Function +highlight default link apibHTTPStatusCode Delimiter +highlight default link apibHTTPContentType Comment +highlight default link apibActionRelation Function +highlight default link apibActionRelationKey Identifier + +let b:current_syntax = 'apiblueprint' + + +endif