89 lines · 2.6 KB
---@brief [[
--- glaze.nvim health check
--- Run with :checkhealth glaze
---@brief ]]

local M = {}

function M.check()
  vim.health.start("glaze.nvim")

  -- Check Neovim version
  if vim.fn.has("nvim-0.9") == 1 then
    vim.health.ok("Neovim >= 0.9")
  else
    vim.health.error("Neovim >= 0.9 required", { "Upgrade Neovim to 0.9 or later" })
  end

  -- Check Go (required)
  if vim.fn.executable("go") == 1 then
    local go_version = vim.fn.system("go version"):gsub("%s+$", "")
    vim.health.ok(go_version)
  elseif vim.fn.executable("goenv") == 1 then
    local go_version = vim.fn.system("goenv exec go version 2>/dev/null"):gsub("%s+$", "")
    if go_version ~= "" and not go_version:match("not found") then
      vim.health.ok(go_version .. " (via goenv)")
    else
      vim.health.error("goenv found but no Go version installed", {
        "Run: goenv install <version>",
        "Or install Go directly: https://go.dev/dl/",
      })
    end
  else
    vim.health.error("Go not found", {
      "Go is required for installing and updating binaries",
      "Install from: https://go.dev/dl/",
    })
  end

  -- Check GOBIN / GOPATH
  local gobin = vim.env.GOBIN