nvim-config11/lua/plugins/hurl.nvim.lua

86 lines
3 KiB
Lua

local function load_env(file)
local env_vars = {}
local env_file = io.open(file, "r")
if not env_file then return env_vars end
for line in env_file:lines() do
local key, value = line:match("([^=]+)=([^=]+)")
if key and value then
env_vars[key] = value
vim.fn.setenv(key, value) -- Optionally set it in Neovim's environment
end
end
env_file:close()
return env_vars
end
return {
"jellydn/hurl.nvim",
dependencies = {
"MunifTanjim/nui.nvim",
"nvim-lua/plenary.nvim",
"nvim-treesitter/nvim-treesitter",
-- Optional, for markdown rendering with render-markdown.nvim
{
'MeanderingProgrammer/render-markdown.nvim',
opts = {
file_types = { "markdown" },
},
ft = { "markdown" },
},
},
ft = "hurl",
opts = {
-- Show debugging info
debug = false,
-- Show notification on run
show_notification = false,
-- Show response in popup or split
mode = "split",
-- Default formatter
formatters = {
json = { 'jq' }, -- Make sure you have install jq in your system, e.g: brew install jq
html = {
'prettier', -- Make sure you have install prettier in your system, e.g: npm install -g prettier
'--parser',
'html',
},
xml = {
'tidy', -- Make sure you have installed tidy in your system, e.g: brew install tidy-html5
'-xml',
'-i',
'-q',
},
},
mappings = {
close = 'q', -- Close the response popup or split view
next_panel = '<C-n>', -- Move to the next response popup window
prev_panel = '<C-p>', -- Move to the previous response popup window
},
fixture_vars = {
{
name = 'CARBONCENTRAL_FIREBASE_TOKEN',
callback = function()
local vars = load_env("vars.env")
local firebaseUrl = vars["FIREBASE_URL"]
local firebaseKey = vars["FIREBASE_KEY"]
local email = vars["FIREBASE_EMAIL"]
local password = vars["FIREBASE_PASSWORD"]
local h = io.popen(
"curl --header \"Content-Type: application/json\" --request POST --data '{\"returnSecureToken\":true,\"email\":\"" ..
email ..
"\",\"password\":\"" ..
password ..
"\",\"clientType\":\"CLIENT_TYPE_WEB\"}' " .. firebaseUrl .. "?key=" ..
firebaseKey)
local rawdata = h:read("all")
h:close()
local t = vim.json.decode(rawdata)
return t["idToken"]
end
},
}
},
}