Add api blueprint support, closes #182

This commit is contained in:
Adam Stankiewicz 2017-03-23 13:21:01 +01:00
parent c2a7f363c6
commit ef4435cffc
No known key found for this signature in database
GPG Key ID: A62480DCEAC884DF
4 changed files with 47 additions and 0 deletions

View File

@ -37,6 +37,7 @@ If you need full functionality of any plugin, please use it directly with your p
## Language packs ## Language packs
- [ansible](https://github.com/pearofducks/ansible-vim) (syntax, indent, ftplugin) - [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) - [applescript](https://github.com/vim-scripts/applescript.vim) (syntax)
- [arduino](https://github.com/sudar/vim-arduino-syntax) (syntax, indent) - [arduino](https://github.com/sudar/vim-arduino-syntax) (syntax, indent)
- [blade](https://github.com/jwalton512/vim-blade) (syntax, indent, ftplugin) - [blade](https://github.com/jwalton512/vim-blade) (syntax, indent, ftplugin)

1
build
View File

@ -104,6 +104,7 @@ EOF
} }
PACKS=" PACKS="
apiblueprint:sheerun/apiblueprint.vim
applescript:vim-scripts/applescript.vim applescript:vim-scripts/applescript.vim
yaml:stephpy/vim-yaml yaml:stephpy/vim-yaml
ansible:pearofducks/ansible-vim ansible:pearofducks/ansible-vim

View File

@ -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 augroup filetypedetect
" applescript:vim-scripts/applescript.vim " applescript:vim-scripts/applescript.vim
augroup END augroup END

38
syntax/apiblueprint.vim Normal file
View File

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