Luigit
repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by admin

neovim/lua/std/dbg/kinds.lua

Raw
local icon = require 'std.icon'

---@class DbgKind
---@field icon string nerd font icon
---@field hl_group string neovim highlight group

---@type table<string, DbgKind>
local DBG_KINDS = {
  DEBUG = { icon = icon.search, hl_group = 'DiagnosticInfo' },
  TRACE = { icon = icon.event,   hl_group = 'DiagnosticHint' },
  ERROR = { icon = icon.error,   hl_group = 'DiagnosticError' },
}

---Returns the kind details for a given kind name.
---@param kind_name string must be one of DEBUG, TRACE, ERROR
---@return DbgKind
local function get(kind_name)
  vim.validate('kind_name', kind_name, 'string')
  local kind = DBG_KINDS[kind_name]
  if not kind then
    local available = vim.tbl_keys(DBG_KINDS)
    error('Unknown debug kind: ' .. kind_name .. '. Available: ' .. vim.inspect(available))
  end
  return kind
end

---Returns a list of all available kind names.
---@return string[]
local function list()
  return vim.tbl_keys(DBG_KINDS)
end

---Formats a kind name into a display string with icon and name.
---@param kind_name string
---@return string
local function format(kind_name)
  local kind = get(kind_name)
  return kind.icon .. ' ' .. kind_name
end

return {
  DEBUG = DBG_KINDS.DEBUG,
  TRACE = DBG_KINDS.TRACE,
  ERROR = DBG_KINDS.ERROR,
  get = get,
  list = list,
  format = format,
}