Skip to content

Commit cd45acc

Browse files
fix(markdown-preview-nvim): build using yarn when possible (#1187)
fix(markdown-preview-nvim): build using yarn when possible, else throw
1 parent 07ff0d8 commit cd45acc

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

lua/astrocommunity/markdown-and-latex/markdown-preview-nvim/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# markdown-preview.nvim
22

3+
> This plugin requires Node.js to be installed on your system.
4+
> Without it, the installation process will fail, and the plugin won't work.
5+
36
markdown preview plugin for (neo)vim
47

58
**Repository:** <https://github.com/iamcco/markdown-preview.nvim>

lua/astrocommunity/markdown-and-latex/markdown-preview-nvim/init.lua

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
11
---@type LazySpec
22
return {
33
"iamcco/markdown-preview.nvim",
4-
build = function() vim.fn["mkdp#util#install"]() end,
4+
build = function(plugin)
5+
local package_manager = vim.fn.executable "yarn" and "yarn" or vim.fn.executable "npx" and "npx -y yarn" or false
6+
7+
--- HACK: Use `yarn` or `npx` when possible, otherwise throw an error
8+
---@see https://github.com/iamcco/markdown-preview.nvim/issues/690
9+
---@see https://github.com/iamcco/markdown-preview.nvim/issues/695
10+
if not package_manager then error "Missing `yarn` or `npx` in the PATH" end
11+
12+
local cmd = string.format(
13+
"!cd %s && cd app && COREPACK_ENABLE_AUTO_PIN=0 %s install --frozen-lockfile",
14+
plugin.dir,
15+
package_manager
16+
)
17+
18+
vim.cmd(cmd)
19+
end,
520
ft = { "markdown", "markdown.mdx" },
621
cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" },
722
init = function()

0 commit comments

Comments
 (0)