Skip to content

Commit

Permalink
Add api blueprint support, closes #182
Browse files Browse the repository at this point in the history
  • Loading branch information
sheerun committed Mar 23, 2017
1 parent c2a7f36 commit ef4435c
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions build
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ EOF
}

PACKS="
apiblueprint:sheerun/apiblueprint.vim
applescript:vim-scripts/applescript.vim
yaml:stephpy/vim-yaml
ansible:pearofducks/ansible-vim
Expand Down
7 changes: 7 additions & 0 deletions ftdetect/polyglot.vim
Original file line number Diff line number Diff line change
@@ -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
Expand Down
38 changes: 38 additions & 0 deletions syntax/apiblueprint.vim
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit ef4435c

Please sign in to comment.