Add basic Syntax highlighting for VIM

This commit is contained in:
Fabrice Reix 2022-06-01 11:18:09 +02:00 committed by jcamiel
parent b0ff7d9521
commit 6edd7f9852
4 changed files with 85 additions and 0 deletions

16
contrib/vim/README.md Normal file
View File

@ -0,0 +1,16 @@
Install vim syntaxt highlighting for Hurl
```
mkdir -p ~/.vim/{ftdetect,syntax}
cp ftdetect/hurl.vim ~/.vim/ftdetect
cp syntax/hurl.vim ~/.vim/syntax
```
Activate syntax highlighting in your ~/.vimrc
```
syntax on
```

View File

@ -0,0 +1,2 @@
autocmd BufRead,BufNewFile *.hurl set filetype=hurl

View File

@ -0,0 +1,38 @@
" Vim syntax file
" Language: Hurl (https://hurl.dev)
if exists("b:current_syntax")
finish
endif
syntax match Method "^GET"
syntax match Method "^POST"
syntax match Method "^PUT"
syntax match Method "^DELETE"
syntax match Method "^CONNECT"
syntax match Method "^OPTIONS"
syntax match Method "^TRACE"
syntax match Method "^PATCH"
syntax match Comment "#.*$"
syntax match EscapeNumberSign "\\#"
syntax match EscapeQuote "\\\""
syntax match Section "\[[A-Za-z]*\]"
syntax match Number "\s[0-9]*"
syntax region String start='"' end='"' contains=EscapeQuote
syntax region String start='```' end='```'
syntax region Json start='{' end='}'
" colors
highlight Comment ctermfg=grey
highlight Method ctermfg=yellow
highlight Section ctermfg=magenta
highlight String ctermfg=green
highlight Json ctermfg=green
highlight Number ctermfg=lightblue
highlight EscapeNumberSign ctermfg=white
highlight EscapeQuote ctermfg=green

29
contrib/vim/test.hurl Normal file
View File

@ -0,0 +1,29 @@
# This is a comment
GET http://example.com
Header1: Value1
Header2: a\# # value with \#
Header3: GET
HTTP/1.1 200
[Asserts]
body not contains "#" # Other comment
body not contains "[Asserts]"
body not contains "200"
body not contains "GET"
body not contains "\"\#"
POST http://example.com
{
"id": 123,
"message": "Hello"
}
POST http://example.com
```
Hello
```