diff options
| author | theprimeagain <the.primeagen@gmail.com> | 2026-02-08 18:38:21 -0700 |
|---|---|---|
| committer | theprimeagain <the.primeagen@gmail.com> | 2026-02-08 18:38:21 -0700 |
| commit | 6cd4bc2c6c50145c05045a7d87780f61c7c9ca3a (patch) | |
| tree | 877f1dafad8cdef12443418027d7ca7f47cdbe65 /lua | |
| parent | 16053ff8789288e5cb74852d5fe6514a13659c76 (diff) | |
| download | a4-6cd4bc2c6c50145c05045a7d87780f61c7c9ca3a.tar.xz a4-6cd4bc2c6c50145c05045a7d87780f61c7c9ca3a.zip | |
show in flight response
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/99/init.lua | 17 | ||||
| -rw-r--r-- | lua/99/ops/clean-up.lua | 5 | ||||
| -rw-r--r-- | lua/99/ops/over-range.lua | 2 | ||||
| -rw-r--r-- | lua/99/ops/search.lua | 2 | ||||
| -rw-r--r-- | lua/99/window/init.lua | 29 |
5 files changed, 47 insertions, 8 deletions
diff --git a/lua/99/init.lua b/lua/99/init.lua index 134236a..fa3b269 100644 --- a/lua/99/init.lua +++ b/lua/99/init.lua @@ -55,6 +55,7 @@ end --- @class _99.ActiveRequest --- @field clean_up _99.Cleanup --- @field request_id number +--- @field name string --- @class _99.StateProps --- @field model string @@ -213,13 +214,15 @@ end local _active_request_id = 0 ---@param clean_up _99.Cleanup ---@param request_id number +---@param name string ---@return number -function _99_State:add_active_request(clean_up, request_id) +function _99_State:add_active_request(clean_up, request_id, name) _active_request_id = _active_request_id + 1 Logger:debug("adding active request", "id", _active_request_id) self.__active_requests[_active_request_id] = { clean_up = clean_up, request_id = request_id, + name = name, } return _active_request_id end @@ -467,9 +470,15 @@ local function show_in_flight_requests() return shut_down_in_flight_requests_window() end - vim.api.nvim_buf_set_lines(win.buf_id, 0, 1, { - throb .. " " .. tostring(count), - }) + local lines = { + throb .. " requests(" .. tostring(count) .. ") " .. throb, + } + for _, r in pairs(_99_state.__active_requests) do + table.insert(lines, r.name) + end + + Window.vertical_resize(win, #lines) + vim.api.nvim_buf_set_lines(win.buf_id, 0, 1, lines) end) end diff --git a/lua/99/ops/clean-up.lua b/lua/99/ops/clean-up.lua index 1522d61..ba76f01 100644 --- a/lua/99/ops/clean-up.lua +++ b/lua/99/ops/clean-up.lua @@ -1,7 +1,8 @@ ---@param context _99.RequestContext +---@param name string ---@param clean_up_fn fun(): nil ---@return fun(): nil -return function(context, clean_up_fn) +return function(context, name, clean_up_fn) local called = false local request_id = -1 local function clean_up() @@ -13,7 +14,7 @@ return function(context, clean_up_fn) clean_up_fn() context._99:remove_active_request(request_id) end - request_id = context._99:add_active_request(clean_up, context.xid) + request_id = context._99:add_active_request(clean_up, context.xid, name) return clean_up end diff --git a/lua/99/ops/over-range.lua b/lua/99/ops/over-range.lua index 209be9f..b5c0f24 100644 --- a/lua/99/ops/over-range.lua +++ b/lua/99/ops/over-range.lua @@ -37,7 +37,7 @@ local function over_range(context, range, opts) top_mark ) local bottom_status = RequestStatus.new(250, 1, "Implementing", bottom_mark) - local clean_up = make_clean_up(context, function() + local clean_up = make_clean_up(context, "Visual", function() top_status:stop() bottom_status:stop() context:clear_marks() diff --git a/lua/99/ops/search.lua b/lua/99/ops/search.lua index a4017c0..f494734 100644 --- a/lua/99/ops/search.lua +++ b/lua/99/ops/search.lua @@ -27,7 +27,7 @@ local function search(context, opts) -- "Implementing", -- top_mark -- ) - local clean_up = make_clean_up(context, function() + local clean_up = make_clean_up(context, "Search", function() request:cancel() end) diff --git a/lua/99/window/init.lua b/lua/99/window/init.lua index 65f375c..cbe2d7e 100644 --- a/lua/99/window/init.lua +++ b/lua/99/window/init.lua @@ -440,9 +440,38 @@ function M.status_window() return window end +--- @param win _99.window.Window +--- @param height number +function M.vertical_resize(win, height) + if win.config.height == height then + return + end + assert(M.is_active_window(win), "you cannot pass in an inactive window") + win.config.height = height + vim.api.nvim_win_set_config(win.win_id, { + relative = "editor", + width = win.config.width, + height = height, + row = win.config.row or 0, + col = win.config.col or 0, + anchor = win.config.anchor, + }) +end + --- @return boolean function M.has_active_windows() return #M.active_windows > 0 end +--- @param win _99.window.Window +--- @return boolean +function M.is_active_window(win) + for _, active_win in ipairs(M.active_windows) do + if active_win.win_id == win.win_id then + return true + end + end + return false +end + return M |
