iamcco / markdown-preview.nvim

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

Nothing happens on MarkdownPreview #188

Open rth opened 4 years ago

rth commented 4 years ago

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

vaklinzi commented 4 years ago

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

rth commented 4 years ago

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.

vaklinzi commented 4 years ago

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.

iamcco commented 4 years ago

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'
vaklinzi commented 4 years ago

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

Adolf-L commented 4 years ago

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.

iamcco commented 4 years ago

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

Adolf-L commented 4 years ago

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.

rth commented 4 years ago

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.

rdok commented 4 years ago

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.

rth commented 4 years ago

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.

Unknown-Chinese-User commented 4 years ago

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.

iamcco commented 4 years ago

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

Unknown-Chinese-User commented 4 years ago
图片

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

iamcco commented 4 years ago

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

Unknown-Chinese-User commented 4 years ago

Could you teach me how to install hook?@iamcco

iamcco commented 4 years ago

@Unknown-Chinese-User

image

Unknown-Chinese-User commented 4 years ago

I installed it in the first way.

iamcco commented 4 years ago

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

Unknown-Chinese-User commented 4 years ago

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

lee2sman commented 4 years ago

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! :)

Corgile commented 4 years ago

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 commented 4 years ago

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

cinfig changed : image

no use

iamcco commented 4 years ago

@homlex make sure command edge can open browser

unphased commented 4 years ago

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!!!

iamcco commented 4 years ago

@unphased try

let $NVIM_MKDP_LOG_FILE = expand('~/mkdp-log.log')
let $NVIM_MKDP_LOG_LEVEL = 'debug'
unphased commented 3 years ago

FWIW I had to change it to:

let $NVIM_MKDP_LOG_FILE = $HOME . '/.tmp/mkdp-log.log'
let $NVIM_MKDP_LOG_LEVEL = 'debug'
rene-aguirre commented 3 years ago

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).

jessarcher commented 3 years ago

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 commented 3 years ago

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']}
vamirio98 commented 3 years ago

@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)

Corgile commented 3 years ago

@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 😁

cryptopretor commented 3 years ago

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).

  1. 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.
  2. Install LTS Node and NPM, in debian i was built from code, in ubuntu or another distros with sudo install nodejs npm
  3. In terminal with sudo write sudo npm install tslib && sudo npm install -g yarn; yarn add tslib
  4. Open your .vimrc or init.vim file and uncomment Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app && yarn install' } and close file
  5. Reopen your .vimrc or init.vim and puts :PlugInstall
  6. 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.
  7. Create any markdown file to test it

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

pinkyblinky commented 2 years ago

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?

cryptopretor commented 2 years ago

@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. 😁

teto commented 2 years ago

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.

zelfroster commented 2 years ago

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. 😌

JPK85 commented 2 years ago

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!

CharlesChiuGit commented 1 year ago

Remove the plugin and reinstall it solved my problem. Install via packer.nvim

use({
    "iamcco/markdown-preview.nvim",
    opt = true,
    ft = "markdown",
    run = function()
    vim.fn["mkdp#util#install"]()
    end,
})
orhun commented 1 year ago

In my case, I solved it by going into ~/.local/share/nvim/site/pack/packer/start/markdown-preview.nvim/ and running yarn install.

stephenparkhum commented 1 year ago

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

This one solved my issue! Thanks @Unknown-Chinese-User 👍

ghost commented 1 year ago

I did the "by hand" installation, and now it works fine.

eric-dishman-ctct commented 3 weeks ago

In my case, I solved it by going into ~/.local/share/nvim/site/pack/packer/start/markdown-preview.nvim/ and running yarn install.

I had the same problem on Windows 10. This step fixed my issue. Thanks!!

lee2sman commented 3 weeks ago

Similarly, I am using plug and had to navigate to ~/.config/nvim/plugged/markdown-preview.nvim and then run npm install and now mine works again.