mirror of
https://github.com/NotAShelf/direnv.nvim.git
synced 2025-11-25 15:02:55 +00:00
direnv: init and populate 'integrations' namespace; add TS highlighting
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I78cd545cb9c3b85d7405e9f4723f15066a6a6964
This commit is contained in:
parent
4dfc8758a1
commit
691bcef684
4 changed files with 418 additions and 18 deletions
41
lua/direnv/integrations/statusline.lua
Normal file
41
lua/direnv/integrations/statusline.lua
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue