markdown-preview.nvim icon indicating copy to clipboard operation
markdown-preview.nvim copied to clipboard

Nothing happens on MarkdownPreview

Open rth opened this issue 4 years ago • 44 comments

Thanks for this plugin!

When I run MarkdownPreview on a .md in neovim v0.3.4 nothing happens for me after I install this plugin and I'm not sure how to debug it.

I have installed the package with dein and use the default config from the Readme.

Running checkhealth produces,

health#mkdp#check
========================================================================
  - INFO: Platform: linux
  - INFO: Nvim Version: NVIM v0.3.4
  - INFO: Node version: v10.15.2

  - INFO: Script: /home/rth/.cache/dein/repos/github.com/iamcco/markdown-preview.nvim/app/server.js
  - INFO: Script exists: 1
  - OK: Using node

and I also have tried adding the following to .config/nvim/init.vim

let $NVIM_MKDP_LOG_FILE = expand('~/mkdp-log.log')
let $NVIM_MKDP_LOG_LEVEL = 'debug'

but this file is not created. Same thing happens (i.e. nothing) when I set,

let g:mkdp_auto_start = 1

and try to edit/save markdown file.

Is there any other things I should try to debug it (or log files that I can look at)? Thank you!

Edit: another possibly relevant information is that

  • I am using neovim on a remote Ubuntu 19.04 server.
  • I can see that MarkdownPreview command is only available for markdown files, running it on any other file produces "E492: Not an editor command: MarkdownPreview", so at least the file type detection is working.

rth avatar May 10 '20 11:05 rth

I am on Mac Os X and it works perfectly fine in iTerm2 (I mean the :MarkdownPreview) but inside Alacritty it doesn't work.

Maybe it needs Automation access as iTerm2

image

vaklinzi avatar May 12 '20 16:05 vaklinzi

but inside Alacritty it doesn't work.

Do you also get no error messages, in that case? In my case, I ssh into a remote server, so I'm not sure to what extent the terminal might matter.

rth avatar May 12 '20 16:05 rth

I do not have any errors. After running the command nothing happens. But it works fine from iTerm2. So I think maybe the reason (on Mac) is that it tries to run the server but Mac doesn't give it access.

vaklinzi avatar May 12 '20 17:05 vaklinzi

If nothings happen mostly because open browser fail.

try config:

function g:open_browser(url) abort
  " open url here
endfunction

let g:mkdp_browserfunc = 'g:open_browser'

iamcco avatar May 13 '20 03:05 iamcco

Setting let g:mkdp_browser = 'firefox' fixed my problem. It doesn't work with chrome though. But it's ok for me.

vaklinzi avatar May 13 '20 04:05 vaklinzi

the same issue.

If nothings happen mostly because open browser fail.

try config:

function g:open_browser(url) abort
  " open url here
endfunction

let g:mkdp_browserfunc = 'g:open_browser'

@iamcco how to set url? if I don't set url value it doesn't work.

Adolf-L avatar May 13 '20 08:05 Adolf-L

@Adolf-L function g:open_browser will be call with the preview url.

iamcco avatar May 13 '20 08:05 iamcco

Setting let g:mkdp_browser = 'firefox' fixed my problem. It doesn't work with chrome though. But it's ok for me.

it doesn't work for me.

Adolf-L avatar May 13 '20 08:05 Adolf-L

If nothings happen mostly because open browser fail.

Thanks for the suggestion, adding that function doesn't change anything for me unfortunately. Still no errors (well I had to capitalize the function name to avoid E128: Function name must start with a capital or "s:": g:open_browser(url) abort)

Digging more, even calling,

call mkdp#rpc#start_server()

directly also doesn't seem to do anything for me (and no errors). Calling,

call mkdp#util#echo_messages('Error', "starting server")

works, however when I put it as the first line of mkdp#rpc#start_server in my case under,

~/.cache/dein/repos/github.com/iamcco/markdown-preview.nvim/autoload/mkdp/rpc.vim

the command runs but there is no output to stdout.

Maybe I'm missing something, will try to come back to it in a couple of days.

rth avatar May 13 '20 21:05 rth

Running :messages listed a JS error cannot-find-module-tslib, leading me to believe an unstable build.

After I removed, reinstalled this plugin, and tested it with and without yarn, the issues was fixed for both cases.

Testing machine: Ubuntu 18.

rdok avatar May 14 '20 14:05 rdok

Running :messages listed a JS error

Ahh, thanks for the pointer! In my case I also get,

starting server                                                                                                                
internal/modules/cjs/loader.js:583
    throw err;
    ^
Error: Cannot find module 'tslib'

will try to re-install.

rth avatar May 14 '20 14:05 rth

I am on Mac Os X and it works perfectly fine in iTerm2 (I mean the :MarkdownPreview) but inside Alacritty it doesn't work.

Maybe it needs Automation access as iTerm2

image

I wonder why I can't find it in my mac? Snipaste_2020-05-15_10-33-34

And by the way, would you please paste your config about Markdown-Prewview of your vimrc. I have problem how to set my default browser.

Unknown-Chinese-User avatar May 15 '20 02:05 Unknown-Chinese-User

@Unknown-Chinese-User by default is should work on mac OS. You should checkout if you have install the plugin correctly.

iamcco avatar May 15 '20 02:05 iamcco

图片 I think I have installed it. And I tried let g:mkdp_browser = 'firefox' or let g:mkdp_browser = '/Applications/Firefox.app/Contents/MacOS/firefox' (this is where mac os put its executable file) They all don't work

Unknown-Chinese-User avatar May 15 '20 03:05 Unknown-Chinese-User

@Unknown-Chinese-User you should make sure install hook success.

iamcco avatar May 15 '20 03:05 iamcco

Could you teach me how to install hook?@iamcco

Unknown-Chinese-User avatar May 15 '20 03:05 Unknown-Chinese-User

@Unknown-Chinese-User

image

iamcco avatar May 15 '20 03:05 iamcco

I installed it in the first way.

Unknown-Chinese-User avatar May 15 '20 04:05 Unknown-Chinese-User

@Unknown-Chinese-User do :call mkdp#util#install() again.

iamcco avatar May 15 '20 05:05 iamcco

Thank you! I can preview markdown now! This is because my terminal can't access the address.@iamcco

Unknown-Chinese-User avatar May 15 '20 07:05 Unknown-Chinese-User

FYI I had the same issue as @rth and @rdok (and probably others) above. I'm using Neovim on Ubuntu 18.04. Same error that tslib couldn't be found.

So then I added let g:mkdp_browser = 'firefox' to my init.vim file.

Then I reopened neovim and ran :PlugUpdate since I am using the Vim-Plug plugin manager.

Then the next time :MarkdownPreview worked for me! :)

lee2sman avatar May 27 '20 05:05 lee2sman

Come on,,,, any edge/edge dev players?

i tried npm install in the cloned dir, and it was sunceed. Then i config MDP like this :

image

but still nothing happens on :MarkdownPreview in 127.0.0.1:8888

Can anyone give me some help please

Corgile avatar May 29 '20 14:05 Corgile

Come on,,,, any edge/edge dev players?

cinfig changed : image

no use

Corgile avatar May 29 '20 14:05 Corgile

@homlex make sure command edge can open browser

iamcco avatar May 30 '20 10:05 iamcco

I'm on Linux running tmux and alacritty (and neovim 0.5). The issue I ran into is that if your DISPLAY env var is not set, it will silently fail. This is a particularly long-running tmux session that may have outlasted the gnome process or the initial alaritty that I ran... or something. Anyway export DISPLAY=:0 did the trick for me and this plugin works just as awesomely as it does on macOS.

I really wonder where the markdown-preview logs are.

I did not need them since my second guess at troubleshooting solved the problem (my first guess, using firefox, also works flawlessly once DISPLAY is set). But the question of where are the logs, still remains. It really should loudly complain in the vim messages if there is a failure to open the browser!!!

unphased avatar Jul 26 '20 18:07 unphased

@unphased try

let $NVIM_MKDP_LOG_FILE = expand('~/mkdp-log.log')
let $NVIM_MKDP_LOG_LEVEL = 'debug'

iamcco avatar Jul 27 '20 02:07 iamcco

FWIW I had to change it to:

let $NVIM_MKDP_LOG_FILE = $HOME . '/.tmp/mkdp-log.log'
let $NVIM_MKDP_LOG_LEVEL = 'debug'

unphased avatar Aug 01 '20 19:08 unphased

found out this also happens with iTerm2 after OS upgrade, my solution (after using node only to avoid any security issues with the downloaded binary) was to reinstall iTerm2 shell integration (and restart iTerm2).

rene-aguirre avatar Sep 23 '20 04:09 rene-aguirre

I've got the same symptom (nothing happens on MarkdownPreview, and nothing in :mess)

When I enable the log file:

let $NVIM_MKDP_LOG_FILE = expand('~/mkdp-log.log')
let $NVIM_MKDP_LOG_LEVEL = 'debug'

I get an endless stream of this:

2020-10-22 16:03:31 ERROR (pid:697053) [app/nvim] - unhandledRejection  Promise {
  <rejected> Error: nvim_call_function: Vim:E117: Unknown function: mkdp#util#echo_messages
      at /home/jess/.local/share/nvim/plugins/markdown-preview.nvim/app/node_modules/neovim/lib/api/Base.js:31:28
      at Transport.parseMessage (/home/jess/.local/share/nvim/plugins/markdown-preview.nvim/app/node_modules/neovim/lib/utils/transport.js:96:13)
      at DecodeStream.<anonymous> (/home/jess/.local/share/nvim/plugins/markdown-preview.nvim/app/node_modules/neovim/lib/utils/transport.js:37:18)
      at DecodeStream.emit (events.js:315:20)
      at addChunk (_stream_readable.js:295:12)
      at readableAddChunk (_stream_readable.js:271:9)
      at DecodeStream.Readable.push (_stream_readable.js:212:10)
      at DecodeStream.Transform.push (_stream_transform.js:152:32)
      at DecodeBuffer.DecodeStream.decoder.push (/home/jess/.local/share/nvim/plugins/markdown-preview.nvim/app/node_modules/msgpack-lite/lib/decode-stream.js:24:12)
      at DecodeBuffer.flush (/home/jess/.local/share/nvim/plugins/markdown-preview.nvim/app/node_modules/msgpack-lite/lib/flex-buffer.js:57:12)
} Error: nvim_call_function: Vim:E117: Unknown function: mkdp#util#echo_messages
    at /home/jess/.local/share/nvim/plugins/markdown-preview.nvim/app/node_modules/neovim/lib/api/Base.js:31:28
    at Transport.parseMessage (/home/jess/.local/share/nvim/plugins/markdown-preview.nvim/app/node_modules/neovim/lib/utils/transport.js:96:13)
    at DecodeStream.<anonymous> (/home/jess/.local/share/nvim/plugins/markdown-preview.nvim/app/node_modules/neovim/lib/utils/transport.js:37:18)
    at DecodeStream.emit (events.js:315:20)
    at addChunk (_stream_readable.js:295:12)
    at readableAddChunk (_stream_readable.js:271:9)
    at DecodeStream.Readable.push (_stream_readable.js:212:10)
    at DecodeStream.Transform.push (_stream_transform.js:152:32)
    at DecodeBuffer.DecodeStream.decoder.push (/home/jess/.local/share/nvim/plugins/markdown-preview.nvim/app/node_modules/msgpack-lite/lib/decode-stream.js:24:12)
    at DecodeBuffer.flush (/home/jess/.local/share/nvim/plugins/markdown-preview.nvim/app/node_modules/msgpack-lite/lib/flex-buffer.js:57:12)

However, the following works fine from within neovim:

:call mkdp#util#echo_messages('Error', 'test')

I've tried deleting node_modules and running yarn install again too.

jessarcher avatar Oct 22 '20 06:10 jessarcher

I just got mine working by using the pre-built version instead of the yarn install approach.

- Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app && yarn install'  }
+ Plug 'iamcco/markdown-preview.nvim', { 'do': { -> mkdp#util#install() }, 'for': ['markdown', 'vim-plug']}

jessarcher avatar Oct 23 '20 01:10 jessarcher

@corgile try to add let g:mkdp_browser = 'msedge' to .vimrc, it works on my computer(msys2, win 10 20H2, nodejs 14.15.1, yarn 1.22.10)

vamirio98 avatar Jan 26 '21 15:01 vamirio98

@corgile try to add let g:mkdp_browser = 'msedge' to .vimrc, it works on my computer(msys2, win 10 20H2, nodejs 14.15.1, yarn 1.22.10)

Thanks a lot, I'll try it 😁

Corgile avatar Jan 26 '21 15:01 Corgile

Running :messages listed a JS error cannot-find-module-tslib, leading me to believe an unstable build.

After I removed, reinstalled this plugin, and

Hello everyone I had the same probelm and i was fixit follow the instructions with this answers: 1- Remove NodeJS lastest and install Node.js LTS, at this moment the LTS is 14.16 (In Windows and Debian 10, yes I have dual OS). 2. Remove plugin in nvim with your plugin manager, in my case is Plug Manager. First commenten the line of Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app && yarn install' } , next is close .vimrc or init.vim (in my case .vimrc), reopen .vimrc and write :PlugClean, and put Y to remove plugin. 3. Install LTS Node and NPM, in debian i was built from code, in ubuntu or another distros with sudo install nodejs npm 4. In terminal with sudo write sudo npm install tslib && sudo npm install -g yarn; yarn add tslib 5. Open your .vimrc or init.vim file and uncomment Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app && yarn install' } and close file 6. Reopen your .vimrc or init.vim and puts :PlugInstall 7. add in your .vimrc or init.vim the line let g:mkdp_browser = 'firefox' if you use firefox, I use firefox XD. Close your vim file configuration. 8. Create any markdown file to test it

IMPORTANT: install tslib is very important to put woking on the plugin!

ellipsiis avatar May 14 '21 16:05 ellipsiis

Also had the same issue. Unlike @ellipsiis I use the Vundle manager. So I had to adjust his solution slightly.

I went to ~/.vim/bundle/markdown-preview.nvim/app and then ran yarn install. Now it works fine. Perhaps there needs to be a { 'do': 'cd app && yarn install' } in the Vundle install instructions?

pinkyblinky avatar Apr 23 '22 22:04 pinkyblinky

@pinkyblinky When I had the problem of preview, I tried the solutions that you posted, but your solution to ad the installation of yarn in the NVIM configuration and plugins files can't work for me. Is nice the fact of your simple solution worked for you, thanks for your feedback and comment. 😁

ellipsiis avatar Apr 23 '22 23:04 ellipsiis

I've tried various things in this post to no avail. It's very frustrating to have no logs even with the proper configuration. :MarkdownPreview should log at least a line in the file. So far the file is not creted at all.

teto avatar May 17 '22 19:05 teto

I have freshly installed Linux on which I didn't installed yarn and was wondering why it doesn't works? 💩 Installed yarn and ran :call mkdp#util#install() and it works. 😌

zelfroster avatar Jun 21 '22 02:06 zelfroster

Had similar issues as here and managed to fix with npm install in the cloned dir using the no node / yarn initial installation for vim-plug. This was on Win 10. Works now with Brave as the browser without any excessive config. Hope this helps someone with this issue!

JPK85 avatar Jul 15 '22 14:07 JPK85