mirror of
https://github.com/NotAShelf/direnv.nvim.git
synced 2025-10-03 07:23:35 +00:00
make cache_ttl
configurable
This commit is contained in:
parent
fc17d1aa6b
commit
4dfc8758a1
2 changed files with 7 additions and 2 deletions
|
@ -3,6 +3,7 @@ local M = {}
|
||||||
--- @class DirenvConfig
|
--- @class DirenvConfig
|
||||||
--- @field bin string Path to direnv executable
|
--- @field bin string Path to direnv executable
|
||||||
--- @field autoload_direnv boolean Automatically load direnv when opening files
|
--- @field autoload_direnv boolean Automatically load direnv when opening files
|
||||||
|
--- @field cache_ttl integer Cache TTL in milliseconds for direnv status checks
|
||||||
--- @field statusline table Configuration for statusline integration
|
--- @field statusline table Configuration for statusline integration
|
||||||
--- @field statusline.enabled boolean Enable statusline integration
|
--- @field statusline.enabled boolean Enable statusline integration
|
||||||
--- @field statusline.icon string Icon to show in statusline
|
--- @field statusline.icon string Icon to show in statusline
|
||||||
|
@ -19,7 +20,6 @@ local cache = {
|
||||||
status = nil,
|
status = nil,
|
||||||
path = nil,
|
path = nil,
|
||||||
last_check = 0,
|
last_check = 0,
|
||||||
ttl = 5000, -- milliseconds before cache invalidation, then we can think about naming things
|
|
||||||
pending_request = false,
|
pending_request = false,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,8 +118,9 @@ end
|
||||||
M._get_rc_status = function(callback)
|
M._get_rc_status = function(callback)
|
||||||
local loop = vim.uv or vim.loop
|
local loop = vim.uv or vim.loop
|
||||||
local now = math.floor(loop.hrtime() / 1000000) -- ns -> ms
|
local now = math.floor(loop.hrtime() / 1000000) -- ns -> ms
|
||||||
|
local ttl = (M.config and M.config.cache_ttl) or 5000
|
||||||
|
|
||||||
if cache.status ~= nil and (now - cache.last_check) < cache.ttl then
|
if cache.status ~= nil and (now - cache.last_check) < ttl then
|
||||||
return callback(cache.status, cache.path)
|
return callback(cache.status, cache.path)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -447,6 +448,7 @@ M.setup = function(user_config)
|
||||||
M.config = vim.tbl_deep_extend("force", {
|
M.config = vim.tbl_deep_extend("force", {
|
||||||
bin = "direnv",
|
bin = "direnv",
|
||||||
autoload_direnv = false,
|
autoload_direnv = false,
|
||||||
|
cache_ttl = 5000,
|
||||||
statusline = {
|
statusline = {
|
||||||
enabled = false,
|
enabled = false,
|
||||||
icon = "",
|
icon = "",
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
indent_type = "Spaces"
|
indent_type = "Spaces"
|
||||||
indent_width = 3
|
indent_width = 3
|
||||||
column_width = 80
|
column_width = 80
|
||||||
|
|
||||||
|
[sort_requires]
|
||||||
|
enabled = true
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue