lib.nvim · Foundation · vimdoc
:help lib.nvim-store
Project-scoped persistent state
doc/lib.nvim-store.txt — rendered from the plugin's own vimdoc
*lib.nvim-store.txt* Project-scoped persistent state
lib.nvim.store *lib.nvim-store*
Persistent-storage namespace. Currently ships one submodule, project.
CONTENTS
1. Design ...................................... |lib.nvim-store-design| 2. Usage ........................................ |lib.nvim-store-usage| 3. Functions .................................... |lib.nvim-store-functions| project.root ......................... |lib.nvim-store-project.root| project.save ......................... |lib.nvim-store-project.save| project.load ......................... |lib.nvim-store-project.load| project.clear ........................ |lib.nvim-store-project.clear| project.stats ........................ |lib.nvim-store-project.stats|
1. DESIGN
projectpersists state **keyed by project**, so reopening the same project — even on a different machine, via synced dotfiles/config — finds the same state again. This is whatlib.nvim.cache.diskdoes not provide: it is keyed by a caller-chosen namespace with no notion of "which project is this".projectadds nothing but root resolution on top of two existing primitives: -lib.nvim.fs.project_key— git root of the given/current path (falls back to the path itself outside a work-tree), normalized, cached. -lib.nvim.cache.disk— namespaced JSON persistence with TTL,pcall-guarded read/write. All actual IO is delegated here unchanged.
2. USAGE
local store = require("lib.nvim.store.project")
store.save("cascade/anchors", { version = 1, files = {} })
local data = store.load("cascade/anchors")
store.clear("cascade/anchors")
Also reachable via the namespace table:
local store = require("lib.nvim.store")
store.project.save("cascade/anchors", { version = 1 })
3. FUNCTIONS
project.root({opts})
The resolved, normalized project root backingkey's storage for the current (oropts.path) project. Exposed for diagnostics/tests.
local root = store.root()
project.save({key}, {data}, {opts})
Persistdataunderkey, namespaced to the current project. Returnsok, err.
local ok, err = store.save("settings", { theme = "dark" })
project.load({key}, {opts})
Load the value saved underkeyfor the current project, ornilif missing, unreadable, or expired (peropts.ttl_seconds).
local data = store.load("settings", { ttl_seconds = 3600 })
project.clear({key}, {opts})
Remove the stored value forkeyin the current project. Returnsok.
store.clear("settings")
project.stats({key}, {opts})
Report on-disk state forkeywithout decoding the full payload — same shape aslib.nvim.cache.disk'sstats.
local st = store.stats("settings")
-- { exists, saved_at, age_seconds, size_bytes }
Options
path string path to resolve the project root from (default
cwd); affects WHICH project's storage is used
dir string override the parent storage directory (default
stdpath("cache") .. "/lib.nvim/store/project")
ttl_seconds integer load only: treat entries older than this as
expired