iamcco / markdown-preview.nvim

markdown preview plugin for (neo)vim
MIT License
6.48k stars 274 forks source link

Doesn't start with init.lua #356

Open augustebaum opened 3 years ago

augustebaum commented 3 years ago

Describe the bug When I use init.vim the preview starts as normal, and when I use init.lua nothing starts, with no errors.

To Reproduce

  1. Install vim-plug and paq.nvim (sorry, apparently one can't use vim-plug with init.lua so I had to change when I rewrote it).

  2. Take

    " init.vim
    set nocp
    filetype plugin on
    let g:NVIM_PLUGINS_DIR = stdpath('config') . '/plugged'
    call plug#begin(NVIM_PLUGINS_DIR)
    Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app && yarn install' }
    call plug#end()

    and

    -- init.lua
    vim.o.cp = false
    vim.cmd("filetype plugin on")
    require "paq" {
    {"iamcco/markdown-preview.nvim", as="markdown-preview", run="cd app && yarn install" };
    }

    and install the plugin (with :PlugInstall for the first and :PaqInstall for the second).

  3. Open some markdown file using nvim -u init.vim file.md. Run :MarkdownPreview. Works as expected (server starts at localhost, browser opens it).

  4. Open the markdown file using nvim -u init.lua file.md. Run :MarkdownPreview. Nothing happens (and no errors). In particular, the server doesn't seem to have started (when I use the address I have when it works, I get "not found").

Expected behavior Everything works exactly the same for the two setups.

Desktop:

Log:

checkhealth gives:

health#mkdp#check
========================================================================
  - INFO: Platform: macos
  - INFO: Nvim Version: NVIM v0.6.0-dev+9-g490615612
  - INFO: Node version: v16.4.2

  - INFO: Script: std('data')/site/pack/paqs/start/markdown-preview/app/server.js
  - INFO: Script exists: 1
  - OK: Using node

Otherwise the plugin has been working great, thanks for all your hard work!

motorto commented 3 years ago

Yeah seem to have the same issue here, cant run it with init.lua , using Fedora Silverblue:

health#mkdp#check
========================================================================
  - INFO: Platform: linux
  - INFO: Nvim Version: NVIM v0.5.0
  - INFO: Pre build: /var/home/cerqueira/.local/share/nvim/site/pack/paqs/opt/markdownPreview/app/bin/markdown-preview-linux
  - INFO: Pre build version: pkg/prelude/bootstrap.js:1254
  - OK: Using pre build

I am using paq.nvim on my init.lua

require "paq" {
    "savq/paq-nvim";                  -- Let Paq manage itself
   {"iamcco/markdown-preview.nvim", opt=true ,run=vim.fn["mkdp#util#install()"] ,as="markdownPreview"}  ;   -- Markdown Preview
}

vim.cmd([[
augroup markdown!
    autocmd!
    au FileType markdown packadd! markdownPreview
    au FileType markdown setlocal spell spelllang=pt_pt,en_us
    au FileType markdown inoremap <C-l> <c-g>u<Esc>[s1z=`]a<c-g>u
    au FileType markdown nmap <F5> <Plug>MarkdownPreviewToggle
    au FileType markdown set conceallevel=2
    augroup END
]])
logan-connolly commented 2 years ago

@augustebaum @motorto ran into this issue today. Solved it by running this for the run hook:

require "paq" {
  'savq/paq-nvim';
  { 'iamcco/markdown-preview.nvim', run = function() vim.fn['mkdp#util#install']() end };
}
terminalPoltergeist commented 12 months ago

Any updates on this? I tried @logan-connolly solution, but didn't work..