1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
return {
{
"rest-nvim/rest.nvim",
event = "VeryLazy",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-neotest/nvim-nio",
},
build = ":UpdateRemotePlugins",
config = function()
require("rest-nvim").setup({
-- Open request results in a horizontal split
split = {
horizontal = false, -- split horizontally
width = 0.4, -- split width, number represents percentage of screen
},
-- Skip SSL verification
skip_ssl_verification = false,
-- Encode URL characters
encode_url = true,
-- Highlight response
highlight = {
enabled = true,
timeout = 200,
},
-- Dynamic URL variable interpolation
dynamic_variables = {},
-- Default headers
default_headers = {
["Content-Type"] = "application/json",
},
-- Custom curl arguments
curl_args = {
["--max-time"] = 30,
},
-- Format response body using gq command
response = {
hooks = {
format = true,
},
},
})
-- Set formatprg for JSON formatting
vim.api.nvim_create_autocmd({ "FileType" }, {
pattern = "json",
callback = function(args)
vim.bo[args.buf].formatprg = "jq --indent 4"
end,
})
end,
keys = {
{
"<leader>rr",
":Rest run<CR>",
desc = "Run HTTP request",
},
{
"<leader>rl",
":Rest last<CR>",
desc = "Run HTTP request (last)",
},
},
},
}
|