From 16053ff8789288e5cb74852d5fe6514a13659c76 Mon Sep 17 00:00:00 2001 From: theprimeagain Date: Sun, 8 Feb 2026 18:26:48 -0700 Subject: showing inflight requests --- lua/99/init.lua | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'lua/99/init.lua') diff --git a/lua/99/init.lua b/lua/99/init.lua index eb580c6..134236a 100644 --- a/lua/99/init.lua +++ b/lua/99/init.lua @@ -12,6 +12,7 @@ local Extensions = require("99.extensions") local Agents = require("99.extensions.agents") local Providers = require("99.providers") local time = require("99.time") +local Throbber = require("99.ops.throbber") ---@param path_or_rule string | _99.Agents.Rule ---@return _99.Agents.Rule | string @@ -60,6 +61,7 @@ end --- @field md_files string[] --- @field prompts _99.Prompts --- @field ai_stdout_rows number +--- @field show_in_flight_requests boolean --- @field languages string[] --- @field display_errors boolean --- @field auto_add_skills boolean @@ -76,6 +78,7 @@ local function create_99_state() md_files = {}, prompts = require("99.prompt-settings"), ai_stdout_rows = 3, + show_in_flight_requests = false, languages = { "lua", "go", "java", "elixir", "cpp", "ruby" }, display_errors = false, provider_override = nil, @@ -94,6 +97,7 @@ end --- @class _99.Options --- @field logger _99.Logger.Options? --- @field model string? +--- @field show_in_flight_requests boolean? --- @field md_files string[]? --- @field provider _99.Providers.BaseProvider? --- @field debug_log_prefix string? @@ -111,6 +115,9 @@ end --- @field ai_stdout_rows number --- @field languages string[] --- @field display_errors boolean +--- @field show_in_flight_requests boolean +--- @field show_in_flight_requests_window _99.window.Window | nil +--- @field show_in_flight_requests_throbber _99.Throbber | nil --- @field provider_override _99.Providers.BaseProvider? --- @field auto_add_skills boolean --- @field rules _99.Agents.Rules @@ -433,11 +440,48 @@ function _99.__get_state() return _99_state end +local function shut_down_in_flight_requests_window() + if _99_state.show_in_flight_requests_throbber then + _99_state.show_in_flight_requests_throbber:stop() + end + + _99_state.show_in_flight_requests_window = nil + _99_state.show_in_flight_requests_throbber = nil +end + +local function show_in_flight_requests() + if _99_state.show_in_flight_requests == false then + return + end + + if Window.has_active_windows() then + return + end + + if _99_state.show_in_flight_requests_window == nil then + local win = Window.status_window() + _99_state.show_in_flight_requests_window = win + _99_state.show_in_flight_requests_throbber = Throbber.new(function(throb) + local count = _99_state:active_request_count() + if count == 0 or not Window.valid(win) then + return shut_down_in_flight_requests_window() + end + + vim.api.nvim_buf_set_lines(win.buf_id, 0, 1, { + throb .. " " .. tostring(count), + }) + end) + end + + vim.defer_fn(show_in_flight_requests, 1000) +end + --- @param opts _99.Options? function _99.setup(opts) opts = opts or {} _99_state = _99_State.new() + _99_state.show_in_flight_requests = opts.show_in_flight_requests or false _99_state.provider_override = opts.provider _99_state.completion = opts.completion or { @@ -483,6 +527,10 @@ function _99.setup(opts) _99_state:refresh_rules() Languages.initialize(_99_state) Extensions.init(_99_state) + + if _99_state.show_in_flight_requests then + show_in_flight_requests() + end end --- @param md string -- cgit v1.3-3-g829e From 6cd4bc2c6c50145c05045a7d87780f61c7c9ca3a Mon Sep 17 00:00:00 2001 From: theprimeagain Date: Sun, 8 Feb 2026 18:38:21 -0700 Subject: show in flight response --- lua/99/init.lua | 17 +++++++++++++---- lua/99/ops/clean-up.lua | 5 +++-- lua/99/ops/over-range.lua | 2 +- lua/99/ops/search.lua | 2 +- lua/99/window/init.lua | 29 +++++++++++++++++++++++++++++ 5 files changed, 47 insertions(+), 8 deletions(-) (limited to 'lua/99/init.lua') 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 -- cgit v1.3-3-g829e From 8fb374c71a5f797f3689bc3ef5c0ee1b4a21d3d6 Mon Sep 17 00:00:00 2001 From: theprimeagain Date: Sun, 8 Feb 2026 18:38:54 -0700 Subject: chore: lint --- lua/99/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lua/99/init.lua') diff --git a/lua/99/init.lua b/lua/99/init.lua index fa3b269..5b4c67a 100644 --- a/lua/99/init.lua +++ b/lua/99/init.lua @@ -477,7 +477,7 @@ local function show_in_flight_requests() table.insert(lines, r.name) end - Window.vertical_resize(win, #lines) + Window.vertical_resize(win, #lines) vim.api.nvim_buf_set_lines(win.buf_id, 0, 1, lines) end) end -- cgit v1.3-3-g829e From 116acb9108886505a17af360a8226e6a6d72a8a5 Mon Sep 17 00:00:00 2001 From: theprimeagain Date: Sun, 8 Feb 2026 19:10:19 -0700 Subject: throbber and window playing nicely --- lua/99/init.lua | 27 ++++++++++--- lua/99/ops/throbber.lua | 2 + lua/99/window/init.lua | 105 +++++++++++++++++++++++++----------------------- 3 files changed, 79 insertions(+), 55 deletions(-) (limited to 'lua/99/init.lua') diff --git a/lua/99/init.lua b/lua/99/init.lua index 5b4c67a..0cc35fc 100644 --- a/lua/99/init.lua +++ b/lua/99/init.lua @@ -444,10 +444,16 @@ function _99.__get_state() end local function shut_down_in_flight_requests_window() + print("shut_down_in_flight_requests_window") + print(debug.traceback()) if _99_state.show_in_flight_requests_throbber then _99_state.show_in_flight_requests_throbber:stop() end + local win = _99_state.show_in_flight_requests_window + if win ~= nil then + Window.close(win) + end _99_state.show_in_flight_requests_window = nil _99_state.show_in_flight_requests_throbber = nil end @@ -456,15 +462,22 @@ local function show_in_flight_requests() if _99_state.show_in_flight_requests == false then return end + vim.defer_fn(show_in_flight_requests, 1000) - if Window.has_active_windows() then + Window.refresh_active_windows() + local current_win = _99_state.show_in_flight_requests_window + if current_win ~= nil and not Window.is_active_window(current_win) then + shut_down_in_flight_requests_window() + end + + if Window.has_active_windows() or _99_state:active_request_count() == 0 then return end if _99_state.show_in_flight_requests_window == nil then local win = Window.status_window() - _99_state.show_in_flight_requests_window = win - _99_state.show_in_flight_requests_throbber = Throbber.new(function(throb) + print("created throbber") + local throb = Throbber.new(function(throb) local count = _99_state:active_request_count() if count == 0 or not Window.valid(win) then return shut_down_in_flight_requests_window() @@ -478,11 +491,15 @@ local function show_in_flight_requests() end Window.vertical_resize(win, #lines) + print("vertical_resize", #lines) vim.api.nvim_buf_set_lines(win.buf_id, 0, 1, lines) end) - end + _99_state.show_in_flight_requests_window = win + _99_state.show_in_flight_requests_throbber = throb - vim.defer_fn(show_in_flight_requests, 1000) + print("created throbber") + throb:start() + end end --- @param opts _99.Options? diff --git a/lua/99/ops/throbber.lua b/lua/99/ops/throbber.lua index b994fcd..79cdbe1 100644 --- a/lua/99/ops/throbber.lua +++ b/lua/99/ops/throbber.lua @@ -58,6 +58,7 @@ function Throbber.new(cb) end function Throbber:_run() + print("throbbing", self.state) if self.state ~= "throbbing" and self.state ~= "cooldown" then return end @@ -73,6 +74,7 @@ function Throbber:_run() end self.cb(icon) + print("throbbing", self.state, icon) vim.defer_fn(function() self:_run() end, 75) diff --git a/lua/99/window/init.lua b/lua/99/window/init.lua index cbe2d7e..8258aab 100644 --- a/lua/99/window/init.lua +++ b/lua/99/window/init.lua @@ -15,6 +15,8 @@ local nvim_buf_is_valid = vim.api.nvim_buf_is_valid --- @field row number? --- @field col number? --- @field anchor string? +--- @field border nil | string | string[] +--- @field zindex number? --- @class _99.window.Window --- @field config _99.window.Config @@ -48,16 +50,21 @@ local function create_window_top_config() width = width - 2, height = 3, anchor = "NE", + border = "rounded", } end +--- @param zindex number --- @return _99.window.Config -local function create_window_top_right_config() +local function create_transparent_top_right_config(zindex) local width, _ = get_ui_dimensions() return { width = math.floor(width / 3), height = 3, + col = width, anchor = "NE", + border = nil, + zindex = zindex, } end @@ -68,6 +75,7 @@ local function create_window_full_screen() width = width - 2, height = height - 2, anchor = "NE", + border = "rounded", } end @@ -97,16 +105,17 @@ local function create_centered_window() height = win_height, row = math.floor((height - win_height) / 2), col = math.floor((width - win_width) / 2), + border = "rounded", } end --- @param config _99.window.Config ----@diagnostic disable-next-line: undefined-doc-name ---- @param win_config vim.api.keyset.win_config +--- @param title string +--- @param enter boolean --- @return _99.window.Window -local function create_floating_window(config, win_config) +local function create_floating_window(config, title, enter) local buf_id = vim.api.nvim_create_buf(false, true) - local win_id = vim.api.nvim_open_win(buf_id, true, { + local win_id = vim.api.nvim_open_win(buf_id, enter, { relative = "editor", width = config.width, height = config.height, @@ -114,13 +123,10 @@ local function create_floating_window(config, win_config) col = config.col or 0, anchor = config.anchor, style = "minimal", - ---@diagnostic disable-next-line: undefined-field - border = win_config.border, - ---@diagnostic disable-next-line: undefined-field - title = win_config.title, + border = config.border, + title = title, title_pos = "center", - ---@diagnostic disable-next-line: undefined-field - zindex = win_config.zindex, + zindex = config.zindex or 1, }) local window = { config = config, @@ -157,10 +163,8 @@ end --- @param error_text string --- @return _99.window.Window function M.display_error(error_text) - local window = create_floating_window(create_window_top_config(), { - title = " 99 Error ", - border = "rounded", - }) + local window = + create_floating_window(create_window_top_config(), " 99 Error ", false) local lines = vim.split(error_text, "\n") table.insert(lines, 1, "") @@ -193,11 +197,8 @@ end --- @param text string function M.display_cancellation_message(text) - local config = create_window_top_right_config() - local window = create_floating_window(config, { - title = " 99 Cancelled ", - border = "rounded", - }) + local config = create_transparent_top_right_config(100) + local window = create_floating_window(config, " 99 Cancelled ", false) local lines = vim.split(text, "\n") vim.api.nvim_buf_set_lines(window.buf_id, 0, -1, false, lines) @@ -226,10 +227,8 @@ function M.display_full_screen_message(lines) --- but i just want this to work and then later... ohh much later, ill fix --- this basic nonsense M.clear_active_popups() - local window = create_floating_window(create_window_full_screen(), { - title = " 99 ", - border = "rounded", - }) + local window = + create_floating_window(create_window_full_screen(), " 99 ", true) local display_lines = ensure_no_new_lines(lines) vim.api.nvim_buf_set_lines(window.buf_id, 0, -1, false, display_lines) end @@ -239,10 +238,7 @@ end function M.create_centered_window() M.clear_active_popups() local config = create_centered_window() - local window = create_floating_window(config, { - title = " 99 ", - border = "rounded", - }) + local window = create_floating_window(config, " 99 ", true) return window, config end @@ -250,10 +246,7 @@ end function M.display_centered_message(message) M.clear_active_popups() local config = create_centered_window() - local window = create_floating_window(config, { - title = " 99 ", - border = "rounded", - }) + local window = create_floating_window(config, " 99 ", true) local display_lines = ensure_no_new_lines(message) vim.api.nvim_buf_set_lines(window.buf_id, 0, -1, false, display_lines) @@ -349,10 +342,8 @@ function M.capture_input(name, opts) M.clear_active_popups() local config = create_centered_window() - local win = create_floating_window(config, { - title = string.format(" 99 %s ", name), - border = "rounded", - }) + local win = + create_floating_window(config, string.format(" 99 %s ", name), true) set_defaul_win_options(win, "99-prompt") vim.api.nvim_set_current_win(win.win_id) @@ -431,12 +422,8 @@ end --- @return _99.window.Window function M.status_window() M.clear_active_popups() - local config = create_window_top_right_config() - local window = create_floating_window(config, { - title = " 99 - Status ", - border = "rounded", - zindex = 100, - }) + local config = create_transparent_top_right_config(100) + local window = create_floating_window(config, " 99 - Status ", false) return window end @@ -448,14 +435,7 @@ function M.vertical_resize(win, height) 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, - }) + vim.api.nvim_win_set_config(win.win_id, win.config) end --- @return boolean @@ -463,6 +443,17 @@ function M.has_active_windows() return #M.active_windows > 0 end +function M.refresh_active_windows() + --- @type _99.window.Window[] + local actives = {} + for _, w in ipairs(M.active_windows) do + if M.valid(w) then + table.insert(actives, w) + end + end + M.active_windows = actives +end + --- @param win _99.window.Window --- @return boolean function M.is_active_window(win) @@ -474,4 +465,18 @@ function M.is_active_window(win) return false end +--- @param win _99.window.Window +function M.close(win) + if not M.valid(win) then + return + end + window_close(win) + for i, active_win in ipairs(M.active_windows) do + if active_win.win_id == win.win_id then + table.remove(M.active_windows, i) + break + end + end +end + return M -- cgit v1.3-3-g829e From 8baa8ee97fe87805ab200d0a53d949a2c5d636ac Mon Sep 17 00:00:00 2001 From: theprimeagain Date: Sun, 8 Feb 2026 19:17:35 -0700 Subject: working-ish throbber --- lua/99/init.lua | 10 +++------- lua/99/window/init.lua | 40 ++++++++++++++++++++++++++-------------- 2 files changed, 29 insertions(+), 21 deletions(-) (limited to 'lua/99/init.lua') diff --git a/lua/99/init.lua b/lua/99/init.lua index 0cc35fc..c781e2a 100644 --- a/lua/99/init.lua +++ b/lua/99/init.lua @@ -444,8 +444,6 @@ function _99.__get_state() end local function shut_down_in_flight_requests_window() - print("shut_down_in_flight_requests_window") - print(debug.traceback()) if _99_state.show_in_flight_requests_throbber then _99_state.show_in_flight_requests_throbber:stop() end @@ -476,7 +474,6 @@ local function show_in_flight_requests() if _99_state.show_in_flight_requests_window == nil then local win = Window.status_window() - print("created throbber") local throb = Throbber.new(function(throb) local count = _99_state:active_request_count() if count == 0 or not Window.valid(win) then @@ -491,13 +488,11 @@ local function show_in_flight_requests() end Window.vertical_resize(win, #lines) - print("vertical_resize", #lines) - vim.api.nvim_buf_set_lines(win.buf_id, 0, 1, lines) + vim.api.nvim_buf_set_lines(win.buf_id, 0, 1, false, lines) end) _99_state.show_in_flight_requests_window = win _99_state.show_in_flight_requests_throbber = throb - print("created throbber") throb:start() end end @@ -593,5 +588,6 @@ function _99.__debug() end _99.Providers = Providers - return _99 + + diff --git a/lua/99/window/init.lua b/lua/99/window/init.lua index 8258aab..da02558 100644 --- a/lua/99/window/init.lua +++ b/lua/99/window/init.lua @@ -1,3 +1,5 @@ +--- TODO: I need to refactor a lot of this file +--- it really sucks local Agents = require("99.extensions.agents") --- @class _99.window.Module @@ -17,6 +19,8 @@ local nvim_buf_is_valid = vim.api.nvim_buf_is_valid --- @field anchor string? --- @field border nil | string | string[] --- @field zindex number? +--- @field relative string? +--- @field title string --- @class _99.window.Window --- @field config _99.window.Config @@ -55,8 +59,9 @@ local function create_window_top_config() end --- @param zindex number +--- @param title string --- @return _99.window.Config -local function create_transparent_top_right_config(zindex) +local function create_transparent_top_right_config(zindex, title) local width, _ = get_ui_dimensions() return { width = math.floor(width / 3), @@ -65,6 +70,7 @@ local function create_transparent_top_right_config(zindex) anchor = "NE", border = nil, zindex = zindex, + title = title, } end @@ -110,13 +116,10 @@ local function create_centered_window() end --- @param config _99.window.Config ---- @param title string ---- @param enter boolean ---- @return _99.window.Window -local function create_floating_window(config, title, enter) - local buf_id = vim.api.nvim_create_buf(false, true) - local win_id = vim.api.nvim_open_win(buf_id, enter, { - relative = "editor", +--- @param title string? +local function full_config(config, title) + return { + relative = config.relative or "editor", width = config.width, height = config.height, row = config.row or 0, @@ -124,10 +127,20 @@ local function create_floating_window(config, title, enter) anchor = config.anchor, style = "minimal", border = config.border, - title = title, + title = title or config.title, title_pos = "center", zindex = config.zindex or 1, - }) + } +end + +--- @param config _99.window.Config +--- @param title string +--- @param enter boolean +--- @return _99.window.Window +local function create_floating_window(config, title, enter) + local buf_id = vim.api.nvim_create_buf(false, true) + local win_id = + vim.api.nvim_open_win(buf_id, enter, full_config(config, title)) local window = { config = config, win_id = win_id, @@ -197,7 +210,7 @@ end --- @param text string function M.display_cancellation_message(text) - local config = create_transparent_top_right_config(100) + local config = create_transparent_top_right_config(100, " 99 Cancelled ") local window = create_floating_window(config, " 99 Cancelled ", false) local lines = vim.split(text, "\n") @@ -422,7 +435,7 @@ end --- @return _99.window.Window function M.status_window() M.clear_active_popups() - local config = create_transparent_top_right_config(100) + local config = create_transparent_top_right_config(100, " 99 - Status ") local window = create_floating_window(config, " 99 - Status ", false) return window end @@ -435,7 +448,7 @@ function M.vertical_resize(win, height) 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, win.config) + vim.api.nvim_win_set_config(win.win_id, full_config(win.config)) end --- @return boolean @@ -478,5 +491,4 @@ function M.close(win) end end end - return M -- cgit v1.3-3-g829e From 3424c33c84964effeb4cf5ff2cb11e0b03a08e7f Mon Sep 17 00:00:00 2001 From: theprimeagain Date: Sun, 8 Feb 2026 19:19:50 -0700 Subject: very experimental search feature --- lua/99/init.lua | 2 +- lua/99/ops/throbber.lua | 6 ++---- lua/99/window/init.lua | 4 +++- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'lua/99/init.lua') diff --git a/lua/99/init.lua b/lua/99/init.lua index c781e2a..0032ad3 100644 --- a/lua/99/init.lua +++ b/lua/99/init.lua @@ -487,7 +487,7 @@ local function show_in_flight_requests() table.insert(lines, r.name) end - Window.vertical_resize(win, #lines) + Window.resize(win, #lines[1], #lines) vim.api.nvim_buf_set_lines(win.buf_id, 0, 1, false, lines) end) _99_state.show_in_flight_requests_window = win diff --git a/lua/99/ops/throbber.lua b/lua/99/ops/throbber.lua index 79cdbe1..b266a6b 100644 --- a/lua/99/ops/throbber.lua +++ b/lua/99/ops/throbber.lua @@ -33,8 +33,8 @@ local function ease_in_ease_out_cubic(percent) end end -local throb_time = 1000 -local cooldown_time = 500 +local throb_time = 1200 +local cooldown_time = 200 --- @class _99.Throbber --- @field start_time number @@ -58,7 +58,6 @@ function Throbber.new(cb) end function Throbber:_run() - print("throbbing", self.state) if self.state ~= "throbbing" and self.state ~= "cooldown" then return end @@ -74,7 +73,6 @@ function Throbber:_run() end self.cb(icon) - print("throbbing", self.state, icon) vim.defer_fn(function() self:_run() end, 75) diff --git a/lua/99/window/init.lua b/lua/99/window/init.lua index da02558..b4b1cb4 100644 --- a/lua/99/window/init.lua +++ b/lua/99/window/init.lua @@ -441,13 +441,15 @@ function M.status_window() end --- @param win _99.window.Window +--- @param width number --- @param height number -function M.vertical_resize(win, height) +function M.resize(win, width, 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 + win.config.width = width vim.api.nvim_win_set_config(win.win_id, full_config(win.config)) end -- cgit v1.3-3-g829e From 7ac6779cade4b6bb6a7e01f0101df799113e9b05 Mon Sep 17 00:00:00 2001 From: theprimeagain Date: Sun, 8 Feb 2026 19:41:34 -0700 Subject: search with quickfix --- lua/99/init.lua | 15 ++++++++++++-- lua/99/ops/search.lua | 55 ++++++++++++++++++++++++++++++++++++++++++++++--- lua/99/ops/throbber.lua | 24 ++++++++++++++++++++- 3 files changed, 88 insertions(+), 6 deletions(-) (limited to 'lua/99/init.lua') diff --git a/lua/99/init.lua b/lua/99/init.lua index 0032ad3..386022d 100644 --- a/lua/99/init.lua +++ b/lua/99/init.lua @@ -126,6 +126,7 @@ end --- @field __view_log_idx number --- @field __request_history _99.RequestEntry[] --- @field __request_by_id table +--- @field __active_marks _99.Mark[] local _99_State = {} _99_State.__index = _99_State @@ -227,6 +228,11 @@ function _99_State:add_active_request(clean_up, request_id, name) return _active_request_id end +--- @param mark _99.Mark +function _99_State:add_mark(mark) + table.insert(self.__active_marks, mark) +end + function _99_State:active_request_count() local count = 0 for _ in pairs(self.__active_requests) do @@ -419,6 +425,13 @@ function _99.stop_all_requests() _99_state.__active_requests = {} end +function _99.clear_all_marks() + for _, mark in ipairs(_99_state.__active_marks or {}) do + mark:delete() + end + _99_state.__active_marks = {} +end + function _99.previous_requests_to_qfix() local items = {} for _, entry in ipairs(_99_state.__request_history) do @@ -589,5 +602,3 @@ end _99.Providers = Providers return _99 - - diff --git a/lua/99/ops/search.lua b/lua/99/ops/search.lua index f494734..da5a777 100644 --- a/lua/99/ops/search.lua +++ b/lua/99/ops/search.lua @@ -1,11 +1,60 @@ local Request = require("99.request") local make_clean_up = require("99.ops.clean-up") local Agents = require("99.extensions.agents") +local Mark = require("99.ops.marks") +local Point = require("99.geo").Point +--- @class _99.Search.Result +--- @field filename string +--- @field lnum number +--- @field col number +--- @field text string + +--- @return _99.Search.Result | nil +local function parse_line(line) + local parts = vim.split(line, ":", { plain = true }) + if #parts ~= 3 then + return nil + end + + local filepath = parts[1] + local lnum = parts[2] + local comma_parts = vim.split(parts[3], ",", { plain = true }) + local col = comma_parts[1] + local notes = nil + + if #comma_parts >= 2 then + notes = table.concat(comma_parts, ",", 2) + end + + return { + filename = filepath, + lnum = tonumber(lnum) or 1, + col = tonumber(col) or 1, + text = notes or "", + } +end + +--- @param _99 _99.State --- @param response string -local function create_search_locations(response) +local function create_search_locations(_99, response) + _ = _99 local lines = vim.split(response, "\n") - print(vim.inspect(lines)) + local qf_list = {} + + for _, line in ipairs(lines) do + local res = parse_line(line) + if res then + table.insert(qf_list, res) + end + end + + if #qf_list > 0 then + vim.fn.setqflist(qf_list, "r") + vim.cmd("copen") + else + vim.notify("No search results found", vim.log.levels.INFO) + end end --- @param context _99.RequestContext @@ -54,7 +103,7 @@ local function search(context, opts) response or "no response provided" ) elseif status == "success" then - create_search_locations(response) + create_search_locations(context._99, response) end end, on_stdout = function(line) diff --git a/lua/99/ops/throbber.lua b/lua/99/ops/throbber.lua index b266a6b..a686ebb 100644 --- a/lua/99/ops/throbber.lua +++ b/lua/99/ops/throbber.lua @@ -24,6 +24,28 @@ local function create_throbber(ease_fn) end end +--- @param percent number +--- @return number +--- @diagnostic disable-next-line +local function linear(percent) + return percent +end + +--- @param percent number +--- @return number +--- @diagnostic disable-next-line +local function ease_in_ease_out_quadratic(percent) + if percent < 0.5 then + return 2 * percent * percent + else + local f = percent - 1 + return 1 - 2 * f * f + end +end + +--- @param percent number +--- @return number +--- @diagnostic disable-next-line local function ease_in_ease_out_cubic(percent) if percent < 0.5 then return 4 * percent * percent * percent @@ -53,7 +75,7 @@ function Throbber.new(cb) start_time = 0, section_time = 0, cb = cb, - throb_fn = create_throbber(ease_in_ease_out_cubic), + throb_fn = create_throbber(linear), }, Throbber) end -- cgit v1.3-3-g829e