diff --git a/contrib/vim/README.md b/contrib/vim/README.md new file mode 100644 index 000000000..6784bfc1c --- /dev/null +++ b/contrib/vim/README.md @@ -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 +``` + + + + diff --git a/contrib/vim/ftdetect/hurl.vim b/contrib/vim/ftdetect/hurl.vim new file mode 100644 index 000000000..41849536d --- /dev/null +++ b/contrib/vim/ftdetect/hurl.vim @@ -0,0 +1,2 @@ +autocmd BufRead,BufNewFile *.hurl set filetype=hurl + diff --git a/contrib/vim/syntax/hurl.vim b/contrib/vim/syntax/hurl.vim new file mode 100644 index 000000000..6c27e8161 --- /dev/null +++ b/contrib/vim/syntax/hurl.vim @@ -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 + + diff --git a/contrib/vim/test.hurl b/contrib/vim/test.hurl new file mode 100644 index 000000000..024c1ccbd --- /dev/null +++ b/contrib/vim/test.hurl @@ -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 +``` + + +