direnv.nvim/lua/direnv/integrations/statusline.lua
NotAShelf 691bcef684
direnv: init and populate 'integrations' namespace; add TS highlighting
Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I78cd545cb9c3b85d7405e9f4723f15066a6a6964
2025-10-22 13:18:57 +03:00

41 lines
No EOL
988 B
Lua

local M = {}
-- Cache for statusline data
local cache = {
status = nil,
last_check = 0,
}
-- Get direnv status for statusline integration
--- @param config table Direnv configuration
--- @return string status_string
M.statusline = function(config)
local statusline_config = config.integrations and config.integrations.statusline or config.statusline
if not statusline_config or not statusline_config.enabled then
return ""
end
if cache.status == 0 then
return statusline_config.icon .. " active"
elseif cache.status == 1 then
return statusline_config.icon .. " pending"
elseif cache.status == 2 then
return statusline_config.icon .. " blocked"
else
return ""
end
end
-- Update the cached status from the main module
--- @param status number|nil The direnv status
M.update_status = function(status)
cache.status = status
end
-- Refresh the statusline cache
M.refresh = function()
cache.last_check = 0
end
return M