Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions vim/my.nvim/init.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
local config_root = vim.fn.fnamemodify(
vim.fn.resolve(debug.getinfo(1, "S").source:sub(2)),
":p:h"
)

vim.opt.runtimepath:prepend(config_root)

require('setup').setup()

vim.keymap.set("n", "<leader>sv", function() require('setup').setup() end, {noremap = true,silent = true})
1 change: 0 additions & 1 deletion vim/my.nvim/lazy-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" },
"quick-scope": { "branch": "master", "commit": "6cee1d9e0b9ac0fbffeb538d4a5ba9f5628fabbc" },
"rainbow": { "branch": "master", "commit": "76ca1a20aa42edb5c65c19029968aad4625790dc" },
"sidekick.nvim": { "branch": "main", "commit": "c2bdf8cfcd87a6be5f8b84322c1b5052e78e302e" },
"space-vim-dark": { "branch": "master", "commit": "0ab698bd2a3959e3bed7691ac55ba4d8abefd143" },
"stylish.nvim": { "branch": "main", "commit": "63c21552bce62175f2d067a92bf7c856e062c314" },
"switch.vim": { "branch": "main", "commit": "4017a58f7ed8a2d76a288e36130affe8eb55e83a" },
Expand Down
70 changes: 0 additions & 70 deletions vim/my.nvim/lua/setup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,75 +33,6 @@ local function ensure_plugin_manager(dir)
vim.opt.runtimepath:prepend(lazypath)
end

local function checksum_cache_path(root)
if not root then
return nil
end
return root .. "/.lazy-lock.sha256"
end

local function read_lock_checksum(lockfile)
if not lockfile or vim.fn.filereadable(lockfile) ~= 1 then
return nil
end
local ok, lines = pcall(vim.fn.readfile, lockfile)
if not ok or not lines then
return nil
end
return vim.fn.sha256(table.concat(lines, "\n"))
end

local function read_cached_checksum(root)
local path = checksum_cache_path(root)
if not path or vim.fn.filereadable(path) ~= 1 then
return nil
end
local ok, lines = pcall(vim.fn.readfile, path)
if not ok or not lines or #lines == 0 then
return nil
end
return lines[1]
end

local function write_cached_checksum(root, checksum)
local path = checksum_cache_path(root)
if not path or not checksum then
return
end
vim.fn.mkdir(root, "p")
pcall(vim.fn.writefile, {checksum}, path)
end

local function try_restore(lazy_mod, root, lockfile)
local ok_stats, stats = pcall(function()
return lazy_mod.stats()
end)
local missing = 0
if ok_stats and stats and stats.missing then
missing = stats.missing
end
local desired_checksum = read_lock_checksum(lockfile)
local cached_checksum = read_cached_checksum(root)
local needs_restore = missing > 0 or (desired_checksum and desired_checksum ~= cached_checksum)
local restore_fn = type(lazy_mod.restore) == "function" and lazy_mod.restore
or type(lazy_mod.sync) == "function" and lazy_mod.sync
or nil
if not needs_restore or not restore_fn then
return
end
local opts = {wait = true, show = false}
local restore_ok, err = pcall(restore_fn, opts)
if restore_ok then
if desired_checksum then
write_cached_checksum(root, desired_checksum)
end
elseif err then
vim.schedule(function()
vim.notify(string.format("lazy.nvim restore failed: %s", err), vim.log.levels.ERROR)
end)
end
end

local function ensure_plugins(dir)
local lazy = require("lazy")
local lazy_opts = {root = dir}
Expand Down Expand Up @@ -203,7 +134,6 @@ local function ensure_plugins(dir)
end,
},
}, lazy_opts)
try_restore(lazy, lazy_opts.root, lazy_opts.lockfile)
end

local function config_coc()
Expand Down
Loading