Something went wrong. Try again.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142---@mod rest-nvim.config rest.nvim configuration------@brief [[------ rest.nvim configuration options------ You can set rest.nvim configuration options via `vim.g.rest_nvim`.------>lua--- ---@type rest.Opts--- vim.g.rest_nvim---<------@brief ]]
---@type rest.Configlocal config
---@tag vim.g.rest_nvim---@tag g:rest_nvim---@class rest.Opts--- Table of custom dynamic variables---@field custom_dynamic_variables? table<string, fun():string>---@field request? rest.Opts.Request---@field response? rest.Opts.Response---@field clients? rest.Opts.Clients---@field cookies? rest.Opts.Cookies---@field env? rest.Opts.Env---@field ui? rest.Opts.UI---@field highlight? rest.Opts.Highlight
---@class rest.Opts.Request--- Skip SSL verification, useful for unknown certificates (Default: `false`)---@field skip_ssl_verification? boolean--- Default request hooks (aka. pre-request scripts) configuration---@field hooks? rest.Opts.Request.Hooks
---@class rest.Opts.Request.Hooks--- Encode URL before making request (Default: `true`)---@field encode_url? boolean--- Set `User-Agent` header when it is empty. Set as empty string to disable.--- (Default: `rest.nvim {version}`)---@field user_agent? string--- Set `Content-Type` header when it is empty but request body is provided---@field set_content_type? boolean
---@class rest.Opts.Response--- Default response hooks (aka. request handlers) configuration---@field hooks? rest.Opts.Response.Hooks
---@class rest.Opts.Response.Hooks--- Decode url segments on response UI too improve readability (Default: `true`)---@field decode_url? boolean--- Format the response body with |'formatexpr'| or |'formatprg'| (Default: `true`)--- NOTE: |vim.lsp.formatexpr()| won't work (see--- <https://github.com/rest-nvim/rest.nvim/issues/414#issuecomment-2308910953>)---@field format? boolean
---@class rest.Opts.Clients---@field curl? rest.Opts.Clients.Curl
---@class rest.Opts.Clients.Curl--- Statistics to parse from curl request output---@field statistics? RestStatisticsStyle[]--- Curl-specific options---@field opts? rest.Opts.Clients.Curl.Opts
---@class rest.Opts.Clients.Curl.Opts--- Add `--compressed` argument when `Accept-Encoding` header includes `gzip`--- (Default: `false`)---@field set_compressed? boolean--- Add `--cert`, `--key` or `--pem` to the `curl` command when required with specific domains--- (default: `nil`)---@field certificates? table<string, Certificate>
---@class Certificate---@field set_certificate_crt string---@field set_certificate_key string
---@class RestStatisticsStyle--- Identifier used used in curl's `--write-out` option--- See `man curl` for more info---@field id string--- Title used on Statistics pane---@field title? string--- Winbar title. Set to `false` or `nil` to not show for winbar, set to empty string--- to hide title If true, rest.nvim will use lowered `title` field---@field winbar? string|boolean
---@class rest.Opts.Cookies--- Enable the cookies support (Default: `true`)---@field enable? boolean--- File path to save cookies file--- (Default: `"stdpath("data")/rest-nvim.cookies"`)---@field path? string
---@class rest.Opts.Env--- Enable the `.env` files support (Default: `true`)---@field enable? boolean--- Environment variables file pattern for telescope.nvim (Default: `"%.env.*"`)---@field pattern? string--- Function lists environment files (used for `:Rest env select`)--- Searches for file matching *rest.Opts.Env.pattern* under same directory by--- default---@field find? fun():string[]
---@class rest.Opts.UI--- Set winbar in result pane (Default: `true`)---@field winbar? boolean--- Default mappings for result pane---@field keybinds? rest.Opts.UI.Keybinds
---@class rest.Opts.UI.Keybinds--- Mapping for cycle to previous result pane (Default: `"H"`)---@field prev? string--- Mapping for cycle to next result pane (Default: `"L"`)---@field next? string
---@class rest.Opts.Highlight--- Enable highlight-on-request (Default: `true`)---@field enable? boolean--- Duration time of the request highlighting in milliseconds (Default: `750`)---@field timeout? number
---@type rest.Optsvim.g.rest_nvim = vim.g.rest_nvim
local default_config = require("rest-nvim.config.default")
local check = require("rest-nvim.config.check")local opts = vim.g.rest_nvim or {}config = vim.tbl_deep_extend("force", default_config, opts)---@cast config rest.Configlocal ok, err = check.validate(config)
if not ok then ---@cast err string vim.notify(err, vim.log.levels.ERROR, { title = "rest.nvim" })end
return config