File tree 1 file changed +8
-22
lines changed
1 file changed +8
-22
lines changed Original file line number Diff line number Diff line change 1
1
-- Simple string cache with fast saving and loading from file
2
2
local M = {}
3
3
4
- local cache_path = vim .fn .stdpath (" state" ) .. " /lazy/plugins.state"
5
- --- @type string
6
- local cache_hash = nil
7
- local dirty = false
4
+ M .dirty = false
8
5
6
+ local cache_path = vim .fn .stdpath (" state" ) .. " /lazy.state"
7
+ --- @type string
8
+ local cache_hash = " "
9
9
--- @type table<string,boolean>
10
10
local used = {}
11
-
12
11
--- @type table<string,string>
13
12
local cache = {}
14
13
23
22
function M .set (key , value )
24
23
cache [key ] = value
25
24
used [key ] = true
26
- dirty = true
25
+ M . dirty = true
27
26
end
28
27
29
28
function M .del (key )
30
29
cache [key ] = nil
31
- dirty = true
32
- end
33
-
34
- function M .dirty ()
35
- dirty = true
36
- end
37
-
38
- function M .use (pattern )
39
- for key , _ in pairs (cache ) do
40
- if key :find (pattern ) then
41
- used [key ] = true
42
- end
43
- end
30
+ M .dirty = true
44
31
end
45
32
46
33
function M .hash (file )
@@ -56,7 +43,7 @@ function M.setup()
56
43
callback = function ()
57
44
vim .api .nvim_create_autocmd (" VimLeavePre" , {
58
45
callback = function ()
59
- if dirty then
46
+ if M . dirty then
60
47
local hash = M .hash (cache_path )
61
48
-- abort when the file was changed in the meantime
62
49
if hash == nil or cache_hash == hash then
@@ -70,10 +57,9 @@ function M.setup()
70
57
end
71
58
72
59
function M .save ()
73
- require (" lazy.core.state " ).save ()
60
+ require (" lazy.core.plugin " ).save ()
74
61
require (" lazy.core.module" ).save ()
75
62
76
- vim .fn .mkdir (vim .fn .fnamemodify (cache_path , " :p:h" ), " p" )
77
63
local f = assert (io.open (cache_path , " wb" ))
78
64
for key , value in pairs (cache ) do
79
65
if used [key ] then
You can’t perform that action at this time.
0 commit comments