Open sontungexpt opened 3 months ago
+1 Also faced this error on Mac OS 12.7.5 Intel Based
Hi peeps,
Seems like iamcco isn’t watching this one anymore, so it’s unlikely this will get merged here. A few of us are looking at possibly reviving the project elsewhere if there is enough interest in helping maintain it.
Alternatively a couple of previous users started a new project https://github.com/jannis-baum/Vivify as a potential replacement
Hi, before executing the functin, Lazy load
the plugin.
This is my resulting lazy configuration, that uses npx is available:
{
-- Install markdown preview, use npx if available.
"iamcco/markdown-preview.nvim",
cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" },
ft = { "markdown" },
build = function(plugin)
if vim.fn.executable "npx" then
vim.cmd("!cd " .. plugin.dir .. " && cd app && npx --yes yarn install")
else
vim.cmd [[Lazy load markdown-preview.nvim]]
vim.fn["mkdp#util#install"]()
end
end,
init = function()
if vim.fn.executable "npx" then vim.g.mkdp_filetypes = { "markdown" } end
end,
},
thanks @Kamilcuk this also worked for nixos (adding commend to allow other people to find this solution)
Please excuse my dumb question but I'm somewhat new to LazyVim and even Neovim for that matter. In what file should I place the above configuration from @Kamilcuk ?
This goes where ever you are specifying your plugins.
So for me, that would be ~/.config/nvim/lua/plugins/markdown-preview.lua
and the file contents would be:-
return {
-- Install markdown preview, use npx if available.
"iamcco/markdown-preview.nvim",
cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" },
ft = { "markdown" },
build = function(plugin)
if vim.fn.executable "npx" then
vim.cmd("!cd " .. plugin.dir .. " && cd app && npx --yes yarn install")
else
vim.cmd [[Lazy load markdown-preview.nvim]]
vim.fn["mkdp#util#install"]()
end
end,
init = function()
if vim.fn.executable "npx" then vim.g.mkdp_filetypes = { "markdown" } end
end,
}
Looks like Kamilcuk might be using a single file setup so he probably has his in ~/.config/nvim/lua/config/lazy.lua
or ~/.config/nvim/init.lua
in the spec = {...
section
It all depends on what you are using and how exactly you've set it up, which is why its so hard to get good help on the topic, there are many variables.
I'm using:-
If you let me know what you are using and I can be a bit more specific.
Here is a screenshot of my plugins folder if that helps.
I'm using the lazyvim "distro" w/structured setup on linux. Your fix seems to be working for me. Thanks so much for your help!
This goes where ever you are specifying your plugins.
So for me, that would be
~/.config/nvim/lua/plugins/markdown-preview.lua
and the file contents would be:-
return { -- Install markdown preview, use npx if available. "iamcco/markdown-preview.nvim", cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" }, ft = { "markdown" }, build = function(plugin) if vim.fn.executable "npx" then vim.cmd("!cd " .. plugin.dir .. " && cd app && npx --yes yarn install") else vim.cmd [[Lazy load markdown-preview.nvim]] vim.fn["mkdp#util#install"]() end end, init = function() if vim.fn.executable "npx" then vim.g.mkdp_filetypes = { "markdown" } end end, }
Looks like Kamilcuk might be using a single file setup so he probably has his in
~/.config/nvim/lua/config/lazy.lua
or~/.config/nvim/init.lua
in thespec = {...
sectionIt all depends on what you are using and how exactly you've set it up, which is why its so hard to get good help on the topic, there are many variables.
I'm using:-
- NeoVim with the lazy.nvim plugin manager (instead of the LazyVim 'distro')
- On Linux
- With a Structured Setup
If you let me know what you are using and I can be a bit more specific.
Here is a screenshot of my plugins folder if that helps.
Thanks so much, this works well for me.
==Yarn is needed==, make sure npm install -g yarn
first.
~/.config/nvim/init.lua
config code:
-- install markdown-preview.nvim without yarn or npm
{
'iamcco/markdown-preview.nvim',
cmd = { 'MarkdownPreviewToggle', 'MarkdownPreview', 'MarkdownPreviewStop' },
ft = { 'markdown' },
build = function()
vim.fn['mkdp#util#install']()
end,
},
I found I needed to run
:Lazy build markdown-preview.nvim
Just once before :MarkdownPreview
would work, after which it would work fine without having to run the build command. I am very unfamiliar with lua, but surely there's a way to run this build command on install?
Also, I'd be keen to help @Tweekism !
Hi peeps,
Seems like iamcco isn’t watching this one anymore, so it’s unlikely this will get merged here. A few of us are looking at possibly reviving the project elsewhere if there is enough interest in helping maintain it.
Alternatively a couple of previous users started a new project https://github.com/jannis-baum/Vivify as a potential replacement
Hey @viscount-monty, that'd be awesome.
I'm actually away for a couple days attending a funeral, but if you are interested check out that Vivify project. I'm helping them out at the moment as it's seeing a lot of active development. Let me know what you think, and I'll chat more later in the week when I get back.
Hi, before executing the functin,
Lazy load
the plugin.This is my resulting lazy configuration, that uses npx is available:
{ -- Install markdown preview, use npx if available. "iamcco/markdown-preview.nvim", cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" }, ft = { "markdown" }, build = function(plugin) if vim.fn.executable "npx" then vim.cmd("!cd " .. plugin.dir .. " && cd app && npx --yes yarn install") else vim.cmd [[Lazy load markdown-preview.nvim]] vim.fn["mkdp#util#install"]() end end, init = function() if vim.fn.executable "npx" then vim.g.mkdp_filetypes = { "markdown" } end end, },
This works for me, many thanks :D
Just to add the full contents of init.lua
(if the single-file method is used), for others who are as new to lua scripting as me:
require("config.lazy") -- already present in the default init.lua
spec = {
{
"iamcco/markdown-preview.nvim",
cmd = { 'MarkdownPreviewToggle', 'MarkdownPreview', 'MarkdownPreviewStop' },
ft = { 'markdown' },
build = function()
vim.cmd [[Lazy load markdown-preview.nvim]]
vim.fn['mkdp#util#install']()
end,
},
}
@viscount-monty Hey mate, soz I've been away, things got a little busy here.
I'll be at https://github.com/jannis-baum/Vivify If ya keen, drop a new thread in the discussions over there, no need to spam all the subscribers here. 😅
This fixed the error for me:
-- install markdown-preview.nvim without yarn or npm
{
'iamcco/markdown-preview.nvim',
event = "VeryLazy",
cmd = { 'MarkdownPreviewToggle', 'MarkdownPreview', 'MarkdownPreviewStop' },
ft = { 'markdown' },
build = function()
vim.fn['mkdp#util#install']()
end,
},
This fixed the error for me:
-- install markdown-preview.nvim without yarn or npm { 'iamcco/markdown-preview.nvim', event = "VeryLazy", cmd = { 'MarkdownPreviewToggle', 'MarkdownPreview', 'MarkdownPreviewStop' }, ft = { 'markdown' }, build = function() vim.fn['mkdp#util#install']() end, },
There is a slight problem with this. In this config, plugin will be loaded on the VeryLazy event each time, not just when you open a markdown file or enter a cmd. I wrote a solution that respects the lazy loading of the plugin:
return {
"iamcco/markdown-preview.nvim",
cmd = { "MarkdownPreviewToggle", "MarkdownPreview"},
build = function()
vim.opt.rtp:prepend(vim.fn.stdpath('data') .. '/lazy/markdown-preview.nvim')
vim.fn["mkdp#util#install"]()
end,
}
My two cents on fixing this, while keeping the default lazy.nvim config
Config for reference:
return {
-- markdown preview from nvim
'iamcco/markdown-preview.nvim',
cmd = { 'MarkdownPreviewToggle', 'MarkdownPreview', 'MarkdownPreviewStop' },
ft = { 'markdown' },
build = function()
vim.fn['mkdp#util#install']()
end,
}
The plugin will need to be loaded first, currently its tied to cmd
and ft
:Lazy load markdown-preview.nvim
Then call the build
command:
:Lazy build markdown-preview.nvim
Describe the bug
I use lazy.nvim to install this plugin followed the instructions but it seems the build failed. { "iamcco/markdown-preview.nvim", cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" }, ft = { "markdown" }, build = function() vim.fn["mkdp#util#install"]() end, config = function() vim.g.mkdp_auto_close = 1 end, },
So i fixed it by this #691, is it the right way?
To Reproduce Steps to reproduce the behavior:
Expected behavior Build successfully
Screenshots
Desktop (please complete the following information):