Lazy update constantly fails
Every time runniing lazy Update I get the output below. pressing x does not remove the plugin. I need to go into .local/share/lazy and rm -fr the plugin and let it reinstall. Any suggestions here?
Failed (1)
○ markdown-preview.nvim MarkdownPreviewToggle MarkdownPreview MarkdownPreviewStop markdown
You have local changes in /home/bkelly/.local/share/nvim/lazy/markdown-preview.nvim:
* app/yarn.lock
Please remove them to update.
You can also press x to remove the plugin and then I to install it again.
app/yarn.lock
You have local changes in /home/bkelly/.local/share/nvim/lazy/markdown-preview.nvim:
* app/yarn.lock
Please remove them to update.
You can also press x to remove the plugin and then I to install it again.
In #612 thread the solution is given here. Basically, change your plugin install file to:
{
"iamcco/markdown-preview.nvim",
cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" },
build = "cd app && npm install && git restore .",
-- or if you use yarn: (I have not checked this, I use npm)
-- build = "cd app && yarn install && git restore .",
init = function()
vim.g.mkdp_filetypes = { "markdown" }
end,
ft = { "markdown" },
},
build = "cd app && yarn install && git restore ."
Thanks! It works for me.
For someone who still encounters the error when :Lazy update:
Delete ~/.local/share/nvim/lazy/markdown-preview.nvim and try again.
Here is my workaround, I hope it helps
https://github.com/ThorstenRhau/neovim/blob/main/lua/optional/markdown-preview.lua
build = function(plugin)
-- Define commands
local install_cmd = { "npx", "--yes", "yarn", "install" }
local restore_cmd = { "git", "restore", "package.json" } -- Add restore command
-- Potentially add yarn.lock if it's also modified:
-- local restore_cmd = { "git", "restore", "package.json", "yarn.lock" }
local app_dir = plugin.dir .. "/app"
local plugin_dir = plugin.dir -- Plugin root directory for git restore
-- Run install command
if vim.fn.executable("npx") == 1 then
vim.system(install_cmd, { cwd = app_dir }, function(res)
if res.code ~= 0 then
vim.notify("markdown-preview.nvim: yarn install failed", vim.log.levels.ERROR)
else
-- Run restore command AFTER successful install
vim.system(restore_cmd, { cwd = plugin_dir }, function(restore_res)
if restore_res.code ~= 0 then
vim.notify(
"markdown-preview.nvim: git restore failed for package.json",
vim.log.levels.WARN
)
end
end)
end
end)
else
-- Fallback install method
vim.fn["mkdp#util#install"]()
-- Also run restore command after fallback install
vim.system(restore_cmd, { cwd = plugin_dir }, function(restore_res)
if restore_res.code ~= 0 then
vim.notify("markdown-preview.nvim: git restore failed for package.json", vim.log.levels.WARN)
end
end)
end
end