@@ -51,44 +51,44 @@ FEATURES *rest-nvim-features*
5151QUICK START *rest-nvim-quick-start*
5252
5353After installing `rest.nvim` you will need to configure it using a `setup`
54- function, it looks like this by default:
55-
56- ` require (" rest-nvim" ).setup ({`
57- ` -- Open request results in a horizontal split`
58- ` result_split_horizontal = false,`
59- ` -- Keep the http file buffer above| left when split horizontal | vertical
60- ` result_split_in_place = false,
61- ` -- Skip SSL verification, useful for unknown certificates`
62- ` skip_ssl_verification = false,`
63- ` -- Highlight request on run`
64- ` highlight = {`
65- ` enabled = true,`
66- ` timeout = 150,`
67- ` },`
68- ` -- Jump to request line on run`
69- ` jump_to_request = false,`
70- ` env_file = '.env',`
71- ` yank_dry_run = true,`
72- `})`
54+ function, it looks like this by default: >lua
55+
56+ require("rest-nvim").setup({
57+ -- Open request results in a horizontal split
58+ result_split_horizontal = false,
59+ -- Keep the http file buffer above| left when split horizontal | vertical
60+ result_split_in_place = false,
61+ -- Skip SSL verification, useful for unknown certificates
62+ skip_ssl_verification = false,
63+ -- Highlight request on run
64+ highlight = {
65+ enabled = true,
66+ timeout = 150,
67+ },
68+ -- Jump to request line on run
69+ jump_to_request = false,
70+ env_file = '.env',
71+ yank_dry_run = true,
72+ })
7373
7474In this section we will be using `https: // reqres.in /` for requests.
7575
7676Let's say we want to create a new user and send our body as a JSON, so we
7777will do the following:
7878
79- 1. We declare the HTTP method to use followed by the URL.
80- ` POST https://reqres.in/api/users `
81-
79+ 1. We declare the HTTP method to use followed by the URL. >lua
80+ POST https://reqres.in/api/users
81+ <
8282 2. Since we want to send our body as a JSON object, we set the
83- Content-Type header.
84- ` Content-Type: application/json`
85-
86- 3. Now, we set the body of our request.
87- `{`
88- ` "name": "morpheus",`
89- ` "job": "leader"`
90- `}`
91-
83+ Content-Type header. >http
84+ Content-Type: application/json
85+ <
86+ 3. Now, we set the body of our request. >json
87+ {
88+ "name": "morpheus",
89+ "job": "leader"
90+ }
91+ <
9292 4. Finally, we place the cursor over or below the method of our request
9393 and call `rest.nvim` with `:lua require('rest-nvim').run()`.
9494
@@ -175,25 +175,25 @@ the body and wrapped in {% script %}. A context table is avaliable in the
175175response script. The context table can be used to read the response and set
176176environment variables.
177177
178- The context table:
179- `{`
180- ` result = res,`
181- ` pretty_print = vim.pretty_print,`
182- ` json_decode = vim.fn.json_decode,`
183- ` set_env = utils.set_env,`
184- `}`
185-
178+ The context table: >lua
179+ {
180+ result = res,
181+ pretty_print = vim.pretty_print,
182+ json_decode = vim.fn.json_decode,
183+ set_env = utils.set_env,
184+ }
185+ <
186186Now environment variables can be set like so:
187-
188- ` GET https://jsonplaceholder.typicode.com/posts/3 `
189- ` `
190- `{ % `
191- ` `
192- ` local body = context.json_decode(context.result.body)`
193- ` context.set_env("postId", body.id)`
194- ` `
195- ` % }`
196-
187+ >
188+ GET https://jsonplaceholder.typicode.com/posts/3
189+
190+ {%
191+
192+ local body = context.json_decode(context.result.body)
193+ context.set_env("postId", body.id)
194+
195+ %}
196+ <
197197===============================================================================
198198DYNAMIC VARIABLES *rest-nvim-usage-dynamic-variables*
199199
@@ -207,40 +207,39 @@ The following dynamic variables are currently supported:
207207To use dynamic variables, the following syntax is used: `{{DYNAMIC_VARIABLE}}` ,
208208e.g. `{{$uuid }}`
209209
210- You can extend or overwrite built-in dynamic variables, with the config key
211- `custom_dynamic_variables` :
212-
213- ` require (" rest-nvim" ).setup ({`
214- ` custom_dynamic_variables = {`
215- ` -- overwrite built-in`
216- ` ['$uuid'] = function()`
217- ` return "{{$uuid}}"`
218- ` end,`
219- ` -- add new dynamic variable function`
220- ` ["$date"] = function()`
221- ` local os_date = os.date('%Y-%m-%d')`
222- ` return os_date`
223- ` end,`
224- ` },`
225- `})`
210+ You can extend or overwrite built-in dynamic variables, with the config key >lua
211+
212+ -- custom_dynamic_variables:
213+ require("rest-nvim").setup({
214+ custom_dynamic_variables = {
215+ -- overwrite built-in
216+ ['$uuid'] = function()
217+ return "{{$uuid}}"
218+ end,
219+ -- add new dynamic variable function
220+ ["$date"] = function()
221+ local os_date = os.date('%Y-%m-%d')
222+ return os_date
223+ end,
224+ },
225+ })
226226
227227===============================================================================
228228CALLBACKS *rest-nvim-usage-callbacks*
229229
230230rest.nvim fires different events upon requests:
231231 - a User RestStartRequest event when launching the request
232- - a User RestStopRequest event when the requests finishes or errors out
233-
234- vim.api.nvim_create_autocmd("User", {
235- pattern = "RestStartRequest",
236- once = true,
237- callback = function(opts)
238- print("IT STARTED")
239- vim.pretty_print(opts)
240- end,
241- })
242-
243-
232+ - a User RestStopRequest event when the requests finishes or errors out >lua
233+
234+ vim.api.nvim_create_autocmd("User", {
235+ pattern = "RestStartRequest",
236+ once = true,
237+ callback = function(opts)
238+ print("IT STARTED")
239+ vim.pretty_print(opts)
240+ end,
241+ })
242+ <
244243===============================================================================
245244KNOWN ISSUES *rest-nvim-issues*
246245
0 commit comments