Skip to content
This repository has been archived by the owner on May 18, 2021. It is now read-only.

Commit

Permalink
Adds request syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
Jab2870 committed Jan 4, 2020
1 parent 2ba1ff0 commit 7102523
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions syntax/request.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
if exists("b:current_syntax")
finish
endif

runtime! syntax/html.vim
runtime! after/syntax/html.vim

let s:cpo_save = &cpo
set cpo&vim

syn keyword httpMethod OPTIONS GET HEAD POST PUT DELETE TRACE CONNECT PATCH contained

syn match httpProto 'HTTP/[0-9.]\+' contained
syn match httpStatusCode '[0-9]\{3\}' contained
syn match httpStatus '[0-9]\{3\} .*$' contained contains=httpStatusCode
syn match httpHeaderKey '^[A-Z][A-Za-z0-9\-]*:' contained
syn match httpURILine '^\(OPTIONS\|GET\|HEAD\|POST\|PUT\|DELETE\|TRACE\|CONNECT\|PATCH\)\( .*\)\?\(HTTP/[0-9.]\+\)\?$' contains=httpMethod,httpProto contained
syn match httpResponseLine '^HTTP/[0-9.]\+ [0-9]\{3\}.*$' contains=httpProto,httpStatus contained
syn match httpHeaderLine '^[A-Z][A-Za-z0-9\-]*: .*$' contains=httpHeaderKey contained

syn region httpHeader start='^\(OPTIONS\|GET\|HEAD\|POST\|PUT\|DELETE\|TRACE\|CONNECT\|PATCH\)\( .*\)\?\(HTTP/[0-9.]\+\)\?$' end='\n\s*\n' contains=httpURILine,httpHeaderLine
syn region httpHeader start='^HTTP/[0-9.]\+ [0-9]\{3\}.*$' end='\n\s*\n' contains=httpResponseLine,httpHeaderLine

hi link httpMethod Type
hi link httpProto Statement
hi link httpHeaderKey Identifier
hi link httpStatus String
hi link httpStatusCode Number

let b:current_syntax = 'request'

let &cpo = s:cpo_save
unlet s:cpo_save

0 comments on commit 7102523

Please sign in to comment.