summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
authortheprimeagain <the.primeagen@gmail.com>2026-02-08 19:41:34 -0700
committertheprimeagain <the.primeagen@gmail.com>2026-02-08 19:41:34 -0700
commit7ac6779cade4b6bb6a7e01f0101df799113e9b05 (patch)
tree1ce0dcb698115c5c6bd4c94f50273a856933f33e /lua
parent3424c33c84964effeb4cf5ff2cb11e0b03a08e7f (diff)
downloada4-7ac6779cade4b6bb6a7e01f0101df799113e9b05.tar.xz
a4-7ac6779cade4b6bb6a7e01f0101df799113e9b05.zip
search with quickfix
Diffstat (limited to 'lua')
-rw-r--r--lua/99/init.lua15
-rw-r--r--lua/99/ops/search.lua55
-rw-r--r--lua/99/ops/throbber.lua24
3 files changed, 88 insertions, 6 deletions
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<number, _99.RequestEntry>
+--- @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