@@ -59,9 +59,15 @@ local panes = {
59
59
if data .response then
60
60
table.insert (lines , (" %d %s %s" ):format (data .response .status .code , data .response .status .version , data .response .status .text ))
61
61
local content_type = data .response .headers [" content-type" ]
62
- local body = res .try_format_body (content_type and content_type [1 ], data .response .body )
63
62
table.insert (lines , " " )
64
63
table.insert (lines , " #+RES" )
64
+ --- @type string[]
65
+ local body
66
+ if config .response .hooks .format then
67
+ body = res .try_format_body (content_type and content_type [1 ], data .response .body )
68
+ else
69
+ body = vim .split (data .response .body , " \n " )
70
+ end
65
71
vim .list_extend (lines , body )
66
72
table.insert (lines , " #+END" )
67
73
else
@@ -138,6 +144,9 @@ winbar = winbar .. "%=%<"
138
144
winbar = winbar .. " %{%v:lua.require('rest-nvim.ui.result').stat_winbar()%}"
139
145
winbar = winbar .. " %#RestText#|%#Normal# "
140
146
winbar = winbar .. " %#RestText#Press %#Keyword#?%#RestText# for help%#Normal# "
147
+
148
+ --- Winbar component showing response statistics
149
+ --- @return string
141
150
function ui .stat_winbar ()
142
151
local content = " "
143
152
if not data .response then
@@ -169,7 +178,9 @@ local group = paneui.create_pane_group("rest_nvim_result", panes, {
169
178
end , { buffer = self .bufnr })
170
179
vim .keymap .set (" n" , " ?" , help .open , { buffer = self .bufnr })
171
180
vim .bo [self .bufnr ].filetype = " rest_nvim_result"
172
- utils .nvim_lazy_set_wo (self .bufnr , " winbar" , winbar )
181
+ if config .ui .winbar then
182
+ utils .nvim_lazy_set_wo (self .bufnr , " winbar" , winbar )
183
+ end
173
184
end ,
174
185
})
175
186
@@ -189,6 +200,7 @@ vim.api.nvim_set_hl(0, "RestPaneTitle", {
189
200
underline = true ,
190
201
})
191
202
203
+ --- Check if UI window is shown in current tabpage
192
204
--- @return boolean
193
205
function ui .is_open ()
194
206
local winnr = vim .iter (vim .api .nvim_tabpage_list_wins (0 )):find (function (id )
@@ -203,11 +215,13 @@ function ui.enter(winnr)
203
215
group :enter (winnr )
204
216
end
205
217
218
+ --- Clear the UI
206
219
function ui .clear ()
207
220
data = {}
208
221
group :render ()
209
222
end
210
223
224
+ --- Update data and rerender the UI
211
225
--- @param new_data rest.UIData
212
226
function ui .update (new_data )
213
227
data = vim .tbl_deep_extend (" force" , data , new_data )
0 commit comments