aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorAriel D'Alessandro <dalessandro.ariel@gmail.com>2023-01-09 20:55:56 +0100
committerAriel D'Alessandro <dalessandro.ariel@gmail.com>2023-01-09 20:55:56 +0100
commit5b6c5ca5b0f081c799fa870dec3a88178c1e28e6 (patch)
tree9d512d3d2abe6518efe3dd15a11b92d5c4e1af79 /lua
parent6dc01b561fa6cb53d25096641a73df8b7c337f0d (diff)
downloadnvim-conf-5b6c5ca5b0f081c799fa870dec3a88178c1e28e6.tar.gz
nvim-conf-5b6c5ca5b0f081c799fa870dec3a88178c1e28e6.zip
feat: move rest to lazy loading
Diffstat (limited to 'lua')
-rw-r--r--lua/alpha/plugins.lua4
-rw-r--r--lua/alpha/rest.lua35
2 files changed, 39 insertions, 0 deletions
diff --git a/lua/alpha/plugins.lua b/lua/alpha/plugins.lua
index c0a4f82..42843e7 100644
--- a/lua/alpha/plugins.lua
+++ b/lua/alpha/plugins.lua
@@ -232,6 +232,10 @@ return require("packer").startup(function(use)
use({
"NTBBloodbath/rest.nvim",
requires = { "nvim-lua/plenary.nvim" },
+ ft = "http",
+ config = function ()
+ require("alpha.rest")
+ end,
})
use({
diff --git a/lua/alpha/rest.lua b/lua/alpha/rest.lua
new file mode 100644
index 0000000..a5838ff
--- /dev/null
+++ b/lua/alpha/rest.lua
@@ -0,0 +1,35 @@
+local rest_nvim = require("rest-nvim")
+
+rest_nvim.setup({
+ -- Open request results in a horizontal split
+ result_split_horizontal = false,
+ -- Skip SSL verification, useful for unknown certificates
+ skip_ssl_verification = false,
+ -- Highlight request on run
+ highlight = {
+ enabled = true,
+ timeout = 150,
+ },
+ result = {
+ -- toggle showing URL, HTTP info, headers at top the of result window
+ show_url = true,
+ show_http_info = true,
+ show_headers = true,
+ },
+ -- Jump to request line on run
+ jump_to_request = false,
+ env_file = ".env",
+ custom_dynamic_variables = {},
+ yank_dry_run = true,
+})
+
+vim.api.nvim_create_autocmd("FileType", {
+ pattern = "http",
+ callback = function ()
+ local buff = tonumber(vim.fn.expand("<abuf>"), 10)
+ vim.keymap.set("n", "<leader>rn", rest_nvim.run, { noremap = true, buffer = buff })
+ vim.keymap.set("n", "<leader>rl", rest_nvim.last, { noremap = true, buffer = buff })
+ vim.keymap.set("n", "<leader>rp", function () rest_nvim.run(true) end, { noremap = true, buffer = buff })
+ end
+})
+