66---
77--- @brief ]]
88
9- --- @type RestConfig
10- local config = {}
9+ --- @type rest.Config
10+ local config
1111
1212--- @alias RestResultFormatters string | fun ( body : string ): string,table
1313
14- --- @class RestOptsHighlight
14+ --- @class rest.Opts.Highlight
1515--- Whether current request highlighting is enabled or not (Default: `true`)
1616--- @field enable ? boolean
1717--- Duration time of the request highlighting in milliseconds (Default: `250`)
1818--- @field timeout ? number
1919
20- --- @class RestOptsResult
21- --- @field window ? RestOptsResultWindow
22- --- @field behavior ? RestOptsResultBehavior
23- --- @field keybinds ? RestOptsResultKeybinds
20+ --- @class rest.Opts.Result
21+ --- @field window ? rest.Opts.Result.Window
22+ --- @field behavior ? rest.Opts.Result.Behavior
23+ --- @field keybinds ? rest.Opts.Result.Keybinds
2424
25- --- @class RestOptsResultWindow
25+ --- @class rest.Opts.Result.Window
2626--- Open request results in a horizontal split (Default: `false`)
2727--- @field horizontal ? boolean
2828--- @field enter ? boolean
2929
30- --- @class RestOptsResultBehavior
30+ --- @class rest.Opts.Result.Behavior
3131--- @field decode_url boolean
32- --- @field statistics RestOptsStatistics
32+ --- @field statistics rest.Opts.Statistics
3333--- @field formatters table<string,RestResultFormatters>
3434
35- --- @class RestOptsStatistics
35+ --- @class rest.Opts.Statistics
3636--- @field enable boolean
37- --- @field stats table<string,RestOptsResultStatStyle >
37+ --- @field stats table<string,rest.Opts.Result.Stat.Style >
3838
39- --- @class RestOptsResultKeybinds
39+ --- @class rest.Opts.Result.Keybinds
4040--- Mapping for cycle to previous result pane (Default: `"H"`)
4141--- @field prev ? string
4242--- Mapping for cycle to next result pane (Default: `"L"`)
4343--- @field next ? string
4444
45- --- @class RestOptsResultStatStyle
45+ --- @class rest.Opts.Result.Stat.Style
4646--- Title used on result pane
4747--- @field title ? string
4848--- Winbar title. Set to `false` or `nil` to not show for winbar, set to empty string
4949--- to hide title If true, rest.nvim will use lowered `title` field
5050--- @field winbar ? string | boolean
5151
52- --- @class RestOpts
52+ --- @class rest.Opts
5353--- Environment variables file pattern for telescope.nvim
5454--- (Default: `".*env.*$"`)
5555--- @field env_pattern ? string
@@ -60,15 +60,15 @@ local config = {}
6060--- Table of custom dynamic variables
6161--- @field custom_dynamic_variables ? table<string , fun (): string>
6262--- Request highlighting config
63- --- @field highlight ? RestOptsHighlight
63+ --- @field highlight ? rest.Opts.Highlight
6464--- Result view config
65- --- @field result ? RestOptsResult
65+ --- @field result ? rest.Opts.Result
6666
67- --- @type RestOpts
67+ --- @type rest.Opts
6868vim .g .rest_nvim = vim .g .rest_nvim
6969
7070--- rest.nvim default configuration
71- --- @class RestConfig
71+ --- @class rest.Config
7272local default_config = {
7373 --- @type string Environment variables file pattern for telescope.nvim
7474 env_pattern = " .*env.*$" ,
@@ -80,9 +80,9 @@ local default_config = {
8080 --- @type table<string , fun (): string> Table of custom dynamic variables
8181 custom_dynamic_variables = {},
8282
83- --- @class RestConfigResult
83+ --- @class rest.Config.Result
8484 result = {
85- --- @class RestConfigResultWindow
85+ --- @class rest.Cnofig.Result.Window
8686 window = {
8787 -- TODO: use `:horizontal` instead. see `:h command-modifiers` and opts.smods
8888 --- @type boolean Open request results in a horizontal split
@@ -94,17 +94,17 @@ local default_config = {
9494 --- @type boolean
9595 cookies = true ,
9696 },
97- --- @class RestConfigResultBehavior
97+ --- @class rest.Config.Result.Behavior
9898 behavior = {
9999 --- @type boolean Whether to decode the request URL query parameters to improve readability
100100 decode_url = true ,
101- --- @class RestConfigResultStats
101+ --- @class rest.Config.Result.Stats
102102 statistics = {
103103 --- @type boolean Whether enable statistics or not
104104 enable = true ,
105105 --- Statistics to be shown, takes cURL's easy getinfo constants name
106106 --- @see https ://curl.se /libcurl /c /curl_easy_getinfo.html
107- --- @type table<string,RestOptsResultStatStyle >
107+ --- @type table<string,rest.Opts.Result.Stat.Style >
108108 stats = {
109109 total_time = { winbar = " take" , title = " Time taken" },
110110 size_download_t = { winbar = " size" , title = " Download size" },
@@ -133,15 +133,15 @@ local default_config = {
133133 end ,
134134 },
135135 },
136- --- @class RestConfigResultKeybinds
136+ --- @class rest.Config.Result.Keybinds
137137 keybinds = {
138138 --- @type string Mapping for cycle to previous result pane
139139 prev = " H" ,
140140 --- @type string Mapping for cycle to next result pane
141141 next = " L" ,
142142 },
143143 },
144- --- @class RestConfigHighlight
144+ --- @class rest.Config.Highlight
145145 highlight = {
146146 --- @type boolean Whether current request highlighting is enabled or not
147147 enable = true ,
@@ -151,7 +151,7 @@ local default_config = {
151151 --- @see vim.log.levels
152152 --- @type integer log level
153153 _log_level = vim .log .levels .WARN ,
154- --- @class RestConfigDebugInfo
154+ --- @class rest.Config.DebugInfo
155155 _debug_info = {
156156 -- NOTE: default option is `nil` to prevent overwriting as empty array
157157 --- @type string[]
@@ -166,7 +166,7 @@ config = vim.tbl_deep_extend("force", {
166166 unrecognized_configs = check .get_unrecognized_keys (opts , default_config ),
167167 },
168168}, default_config , opts )
169- --- @cast config RestConfig
169+ --- @cast config rest.Config
170170local ok , err = check .validate (config )
171171
172172if not ok then
0 commit comments