2828---
2929--- @brief ]]
3030
31+ -- HACK: what is the type of opts here?
32+
3133--- @class RestCmd
32- --- @field impl fun ( args : string[] , opts : vim.api.keyset.user_command ? ) The command implementation
34+ --- @field impl fun ( args : string[] , opts : any ) The command implementation
3335--- @field complete ? fun ( subcmd_arg_lead : string ): string[] Command completions callback , taking the lead of the subcommand ' s argument
3436
3537local commands = {}
@@ -43,7 +45,7 @@ local logger = require("rest-nvim.logger")
4345local rest_command_tbl = {
4446 run = {
4547 -- TODO: run request by name
46- impl = function (args )
48+ impl = function (args , opts )
4749 if # args > 1 then
4850 vim .notify (" Running request by name isn't supported yet" , vim .log .levels .INFO )
4951 return
@@ -53,17 +55,25 @@ local rest_command_tbl = {
5355 end ,
5456 },
5557 last = {
56- impl = function (_ )
58+ impl = function (_ , _ )
5759 request .run_last ()
5860 end ,
5961 },
6062 logs = {
61- impl = function (_ )
62- vim .cmd .e (logger .get_logfile ())
63+ impl = function (_ , opts )
64+ local is_split = opts .smods .vertiacal or opts .smods .horizontal
65+ local is_tab = opts .smods .tab ~= - 1
66+ if is_split or is_tab then
67+ --- @diagnostic disable-next-line : invisible
68+ vim .cmd (opts .mods .. " split " .. logger .get_logfile ())
69+ else
70+ --- @diagnostic disable-next-line : invisible
71+ vim .cmd .edit (logger .get_logfile ())
72+ end
6373 end ,
6474 },
6575 env = {
66- impl = function (args )
76+ impl = function (args , _ )
6777 if not args [1 ] or args [1 ] == " show" then
6878 dotenv .show_registered_file ()
6979 return
@@ -120,7 +130,7 @@ local function rest(opts)
120130 return
121131 end
122132
123- command .impl (args )
133+ command .impl (args , opts )
124134end
125135
126136--- @package
0 commit comments