388 lines · 10.0 KB
---@brief [[
--- glaze.nvim view/UI
--- Lazy.nvim-style floating window with Charmbracelet aesthetic
---@brief ]]

local M = {}

---@type GlazeFloat?
M._float = nil

---@type number?
M._timer = nil

---@type table<string, boolean>
M._expanded = {}

---Line-to-binary mapping for cursor-aware actions.
---@type table<number, string>
M._line_map = {}

local SPINNERS = { "◐", "◓", "◑", "◒" }
local SPINNER_IDX = 1

---Get the binary name under the cursor.
---@return string? name Binary name or nil
function M._get_cursor_binary()
  if not M._float or not M._float:valid() then
    return nil
  end
  local line = vim.api.nvim_win_get_cursor(M._float.win)[1]
  return M._line_map[line]
end

---Open the Glaze UI.
function M.open()
  local Float = require("glaze.float").Float

  if M._float and M._float:valid() then
    M._float:close()
  end