mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 11:06:54 -04:00
feat(http): more comprehensive highlights
This commit is contained in:
parent
eff88f4e8b
commit
2d5c122af9
3 changed files with 68 additions and 2 deletions
|
|
@ -5,9 +5,17 @@
|
|||
(header
|
||||
name: (_) @constant)
|
||||
|
||||
(header
|
||||
value: (_) @string)
|
||||
|
||||
; Variables
|
||||
(identifier) @variable
|
||||
|
||||
(variable_declaration
|
||||
name: (identifier) @variable)
|
||||
"@" @character.special)
|
||||
|
||||
(variable_declaration
|
||||
(value) @string)
|
||||
|
||||
; Operators
|
||||
(comment
|
||||
|
|
@ -25,7 +33,7 @@
|
|||
(request
|
||||
url: (_) @string.special.url)
|
||||
|
||||
(http_version) @constant
|
||||
(http_version) @string.special
|
||||
|
||||
; Response
|
||||
(status_code) @number
|
||||
|
|
@ -36,8 +44,12 @@
|
|||
[
|
||||
"{{"
|
||||
"}}"
|
||||
"{%"
|
||||
"%}"
|
||||
] @punctuation.bracket
|
||||
|
||||
">" @punctuation.special
|
||||
|
||||
(header
|
||||
":" @punctuation.delimiter)
|
||||
|
||||
|
|
|
|||
33
tests/query/highlights/http/test.http
Normal file
33
tests/query/highlights/http/test.http
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
@ENDPOINT=http://localhost:8080/api
|
||||
# <- @character.special
|
||||
# ^^^^^^^ @variable
|
||||
# ^ @operator
|
||||
# ^^^^^^^^^^^^^^^^^^^^^^^^^ @string
|
||||
|
||||
### GET USERS
|
||||
GET {{ENDPOINT}}/users HTTP/1.1
|
||||
# ^^ @punctuation.bracket
|
||||
# ^^^^^^^^ @variable
|
||||
# ^^ @punctuation.bracket
|
||||
# ^^^^^^ @string.special.url
|
||||
# ^^^^^^^^ @string.special
|
||||
|
||||
### GET USERS by Offset
|
||||
GET {{ENDPOINT}}/users?offset=30 HTTP/1.1
|
||||
# <- @function.method
|
||||
|
||||
### POST login
|
||||
POST {{ENDPOINT}}/auth/login HTTP/1.1
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"username": "admin",
|
||||
"password": "password"
|
||||
}
|
||||
|
||||
### Log Out
|
||||
POST {{ENDPOINT}}/auth/logout HTTP/1.1
|
||||
Content-Type: application/json
|
||||
# ^^^^^^^^^^ @constant
|
||||
# ^ @punctuation.delimiter
|
||||
# vim: ft=http
|
||||
21
tests/query/injections/http/injections.http
Normal file
21
tests/query/injections/http/injections.http
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
### post-request script
|
||||
GET https://jsonplaceholder.typicode.com/posts/3
|
||||
|
||||
# @lang=lua
|
||||
> {%
|
||||
local body = vim.json.decode(response.body)
|
||||
client.global.set("postId", body.id)
|
||||
-- ^ @lua
|
||||
%}
|
||||
|
||||
|
||||
### run request with variable
|
||||
|
||||
GET https://jsonplaceholder.typicode.com/posts/{{postId}}
|
||||
|
||||
> {%
|
||||
client.global.set("auth_token", response.body.jwt);
|
||||
// ^ @javascript
|
||||
%}
|
||||
|
||||
### vim: ft=http
|
||||
Loading…
Add table
Add a link
Reference in a new issue