quick fix goes to a more sane place now
This commit is contained in:
@ -1,17 +1,32 @@
|
||||
---@diagnostic disable: param-type-mismatch
|
||||
|
||||
local misc = require("core.misc")
|
||||
local map, auto = misc.map, misc.auto
|
||||
local popup_opts, hover_opts, signature_opts, list_opts, location_opts
|
||||
|
||||
-- TODO: find a way to make the qflist current item be the one closest to the
|
||||
-- cursor whenever we open it
|
||||
local function on_list(opts)
|
||||
vim.fn.setqflist({}, "r", opts)
|
||||
if #opts.items > 1 then
|
||||
vim.cmd.copen()
|
||||
|
||||
-- get to the closest reference to the cursor (likely the one gr or gd was
|
||||
-- called on)
|
||||
local closest, distance = 1, false
|
||||
for i, item in ipairs(opts.items) do
|
||||
if item.filename and vim.fn.expand("%:p") == item.filename then
|
||||
local lnum = vim.api.nvim_win_get_cursor(0)[1]
|
||||
if item.lnum then
|
||||
local new_distance = math.abs(lnum - item.lnum)
|
||||
if not distance or new_distance < distance then
|
||||
distance = new_distance
|
||||
closest = i
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
vim.cmd(".cc! "..closest)
|
||||
end
|
||||
else
|
||||
vim.cmd(".cc! 1")
|
||||
end
|
||||
vim.cmd(".cc! 1")
|
||||
end
|
||||
|
||||
-- disable the default keybinds (they're bad)
|
||||
|
Reference in New Issue
Block a user