AstroNvim / template

AstroNvim template (v4+)
https://astronvim.com/
77 stars 152 forks source link

feat(ui): add example file #4

Closed manuuurino closed 6 months ago

manuuurino commented 7 months ago

📑 Description

adds an example file how to modify the icons

manuuurino commented 7 months ago

initially i thought of something like this, but it might make it harder to understand

if true then return {} end -- REMOVE THIS LINE TO ACTIVATE THIS FILE

---@param kind string
---@param frames string[]
---@return StringMap
local function build_frames(kind, frames)
  local kinds = {}
  for index, frame in ipairs(frames) do
    kinds[kind .. index] = frame
  end
  return kinds
end

return {
  "AstroNvim/astroui",
  ---@type AstroUIOpts
  opts = function(_, opts)
    local icons = {}
    -- configure the loading of the lsp in the status line
    icons = vim.tbl_deep_extend("force", icons, build_frames("LSPLoading", { "⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏" }))

    local text_icons = {
      -- configure neotree
      FolderClosed = "+",
      FolderEmpty = "-",
      FolderOpen = "-",
    }
    -- configure the loading of the lsp in the status line
    text_icons = vim.tbl_deep_extend("force", text_icons, build_frames("LSPLoading", { "|", "/", "-", "\\" }))

    return vim.tbl_deep_extend("force", opts, {
      icons = icons,
      text_icons = text_icons,
    })
  end,
}

also why does a type frame of string[] not exist? IMO it would be easier to work with and calling the spinner kind could be a bit faster.