@@ -15,7 +15,7 @@ CONTENTS *rest-nvim-contents*
1515 4. Environment Variables........| rest-nvim-usage-environment-variables |
1616 5. Dynamic Variables................| rest-nvim-usage-dynamic-variables |
1717 6. Script Variables..................| rest-nvim-usage-script-variables |
18- 6. Callbacks ................................| rest-nvim-usage-callbacks |
18+ 7. Hooks ........................................ | rest-nvim-usage-hooks |
1919 6. License..............................................| rest-nvim-license |
2020 7. Contributing....................................| rest-nvim-contributing |
2121
@@ -64,6 +64,7 @@ function, it looks like this by default:
6464 stay_in_current_window_after_split = true,
6565 },
6666 behavior = {
67+ decode_url = true,
6768 show_info = {
6869 url = true,
6970 headers = true,
@@ -301,19 +302,24 @@ You can extend or overwrite built-in dynamic variables, with the config key
301302
302303
303304===============================================================================
304- CALLBACKS *rest-nvim-usage-callbacks *
305+ HOOKS *rest-nvim-usage-hooks *
305306
306307`rest.nvim` fires different events upon requests:
307- - a User `RestStartRequest` event when launching the request
308- - a User `RestStopRequest` event when the requests finishes or errors out
308+ - a User `RestStartRequest` event when launching the request.
309+ - a User `RestStopRequest` event when the requests finishes.
309310
310311>lua
311312 vim.api.nvim_create_autocmd("User", {
312313 pattern = "RestStartRequest",
313- once = true,
314- callback = function(opts)
315- print("IT STARTED")
316- vim.pretty_print(opts)
314+ once = true, -- This is optional, only if you want the hook to run once
315+ callback = function()
316+ print("Started request")
317+ -- You can access and modify the request data (body, headers, etc) by
318+ -- using the following temporal global variable
319+ vim.print(_G._rest_nvim_req_data)
320+ -- You can also access environment variables from both your current
321+ -- shell session and your environment file by using 'vim.env'
322+ _G._rest_nvim_req_data.headers["USER"] = vim.env.USERNAME
317323 end,
318324 })
319325<
0 commit comments