iamcco / iamcco/markdown-preview.nvim

Plugin loads only on first time

Open
#674 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
8k
Forks
411
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
I managed to load the plugin, but it fails to load when `nvim` is opened at any given time after the first time. Only when the plugin just got installed, it will load properly.

**To Reproduce**
I'm using NvChad which uses Lazy.nvim internally. Part of my `plugins` table is this plugin file:

```lua
local M = { "iamcco/markdown-preview.nvim" }

M.name = "markdown_preview_nvim"
M.lazy = true
M.cond = true

M.init = function()
vim.g.mkdp_filetypes = { "markdown" }
end

M.config = function()
end

M.build = "cd app && yarn install"

M.cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" }

return M
```

I require the above file and `table.insert` this into `M.plugins` in my `chadrc.lua`.

**Expected behavior**
I can confirm this works just fine after adding my code. `:MarkdownPreview` opens the browser and I can see everything gets synced properly.

However, if I close `nvim` and reopen it, despite the plugin being load again, it will not work anymore.

The expected behavior is that this should work. If it works in the first session, it should also work in the 2nd session and so on.

> "Command `MarkdownPreview` not found after loading `markdown_preview_nvim`"

**Desktop (please complete the following information):**
- OS: macos

Log:

```
mkdp: health#mkdp#check

- Platform: macos
- Nvim Version: NVIM v0.10.0
Build type: Release
LuaJIT 2.1.1716656478
Run "nvim -V1 -v" for more info
- Node version: v20.14.0
- Script: /Users/marty/.local/share/nvim/lazy/markdown_preview_nvim/app/server.js
- Script exists: 1
- OK Using node
```

v20.14.0

**Additional comments**

- I tried different methods, such as using the `vim.fn` build method, but this wouldn't work at all, not even at the first time, although I get no errors and everything looks alright
- I noticed this plugin also updates the syntax highlighting of markdowns, well not so much from the 2nd session on, which is on par with the fact that the plugin doesn't get load anymore
- I can reproduce the issue by removing the plugin from my configuration and adding it back in
- The plugin gets loaded, but it's still not working:

image

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.