Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nothing happens on MarkdownPreview #188

Open
rth opened this issue May 10, 2020 · 45 comments
Open

Nothing happens on MarkdownPreview #188

rth opened this issue May 10, 2020 · 45 comments

Comments

@rth
Copy link

rth commented May 10, 2020

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.
@vaklinzi
Copy link

vaklinzi commented May 12, 2020

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
Copy link
Author

rth commented May 12, 2020

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
Copy link

vaklinzi commented May 12, 2020

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
Copy link
Owner

iamcco commented May 13, 2020

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
Copy link

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

@Adolf-L
Copy link

Adolf-L commented May 13, 2020

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
Copy link
Owner

iamcco commented May 13, 2020

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

@Adolf-L
Copy link

Adolf-L commented May 13, 2020

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
Copy link
Author

rth commented May 13, 2020

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
Copy link

rdok commented May 14, 2020

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
Copy link
Author

rth commented May 14, 2020

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
Copy link

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
Copy link
Owner

iamcco commented May 15, 2020

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

@Unknown-Chinese-User
Copy link

图片

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
Copy link
Owner

iamcco commented May 15, 2020

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

@Unknown-Chinese-User
Copy link

Could you teach me how to install hook?@iamcco

@iamcco
Copy link
Owner

iamcco commented May 15, 2020

@Unknown-Chinese-User

image

@Unknown-Chinese-User
Copy link

I installed it in the first way.

@iamcco
Copy link
Owner

iamcco commented May 15, 2020

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

@Unknown-Chinese-User
Copy link

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

@lee2sman
Copy link

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
Copy link

Corgile commented May 29, 2020

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
Copy link

Corgile commented May 29, 2020

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

cinfig changed :
image

no use

@iamcco
Copy link
Owner

iamcco commented May 30, 2020

@Homlex make sure command edge can open browser

@unphased
Copy link

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
Copy link
Owner

iamcco commented Jul 27, 2020

@unphased try

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

@unphased
Copy link

unphased commented Aug 1, 2020

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
Copy link

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
Copy link

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
Copy link

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
Copy link
Contributor

@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
Copy link

Corgile commented Jan 26, 2021

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

@KremlinRoot
Copy link

KremlinRoot commented May 14, 2021

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!

@pinkyblinky
Copy link

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?

@KremlinRoot
Copy link

@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
Copy link

teto commented May 17, 2022

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
Copy link

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
Copy link

JPK85 commented Jul 15, 2022

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
Copy link

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
Copy link

orhun commented Nov 19, 2022

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

@stephenparkhum
Copy link

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

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

@ghost
Copy link

ghost commented Apr 24, 2023

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

@eric-dishman-ctct
Copy link

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
Copy link

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.

@R-Sandor
Copy link

@pinkyblinky changing into the directory and running yarn install fixed it! Thanks all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests