iamcco / markdown-preview.nvim

markdown preview plugin for (neo)vim
MIT License
6.76k stars 280 forks source link

After typing :MarkdownPreview nothing happens #219

Closed Abdulee closed 4 years ago

Abdulee commented 4 years ago

Hi, I have installed this plugin using vim plug however when I type the command i.e MarkdownPreview nothing happens. I am fairly new to nvim but not sure why this is happening don't have a lot of plugins or anything, running Arch linux. Here is a snippet of my plugins.vim file

  1 if empty(glob('~/.config/nvim/autoload/plug.vim'))
  2   silent !curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs
  3     \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
  4   "autocmd VimEnter * PlugInstall
  5   "autocmd VimEnter * PlugInstall | source $MYVIMRC
  6 endif
  7 
  8 call plug#begin('~/.config/nvim/autoload/plugged')
  9 
 10     " Better Syntax Support
 11     Plug 'sheerun/vim-polyglot'
 12     " File Explorer
 13     Plug 'scrooloose/NERDTree'
 14     " Auto pairs for '(' '[' '{'
 15     Plug 'jiangmiao/auto-pairs'
 16     " MARKDOWN PLUGINS
 17     Plug 'plasticboy/vim-markdown'
 18     Plug 'iamcco/markdown-preview.nvim', { 'do': { -> mkdp#util#install() }, 'for': ['markdown', 'vim    -plug']}
 19 call plug#end()
~

As for init.vim I just pasted the default settings and added the firefox as the browser.

iamcco commented 4 years ago

set let g:mkdp_echo_preview_url = 1 to see if can see preview page url

Abdulee commented 4 years ago

set let g:mkdp_echo_preview_url = 1 to see if can see preview page url

Still doesn't do anything ... Can't see page url

supertrianguloid commented 4 years ago

Having the same issue

Plug 'iamcco/markdown-preview.nvim', { 'do': { -> mkdp#util#install() }, 'for': ['markdown', 'vim-plug']} let g:mkdp_browser = 'brave ' let g:mkdp_echo_preview_url = 1

on Arch Linux with neovim v0.5.0-613-g44cbf288e

Also does not spit out the preview page url.

iamcco commented 4 years ago

Using :mess command and have any error message?

ikey4u commented 4 years ago

Using :mess command and have any error message?

@iamcco Same problem, :mess has no output. It is hard to reproduce the problem, sometimes it work for several seconds, then it stop working.

Update:

Well, I know the problem. These are steps to reproduce the issue.

  1. Start nvim with this command nvim --listen 127.0.0.1:9999 test.md
  2. If you run :MarkdownPreview, the issue is there, nothing preview page is opened, nothing messages are printed.
  3. Do not close above neovim instance, and open a new neovim instance using nvim test1.md. Run :MarkdownPreview in this new instance, the plugin works(of course only in the new instance).

And after setup

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

The logs are as follows:

2020-08-06 17:45:30 ERROR (pid:97377) [app/nvim] - unhandledRejection  Promise {
  <rejected> Error: connect ENOENT 127.0.0.1:9999
      at PipeConnectWrap.afterConnect [as oncomplete] (net.js:1141:16) {
    errno: 'ENOENT',
    code: 'ENOENT',
    syscall: 'connect',
    address: '127.0.0.1:9999'
  }
} Error: connect ENOENT 127.0.0.1:9999
    at PipeConnectWrap.afterConnect [as oncomplete] (net.js:1141:16) {
  errno: 'ENOENT',
  code: 'ENOENT',
  syscall: 'connect',
  address: '127.0.0.1:9999'
}
Abdulee commented 4 years ago

Output of :mess

internal/modules/cjs/loader.js:1033                                                                      
  throw err;
  ^
Error: Cannot find module 'tslib'
Require stack:
- /home/klock/.config/nvim/autoload/plugged/markdown-preview.nvim/app/lib/app/index.js
- /home/klock/.config/nvim/autoload/plugged/markdown-preview.nvim/app/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1030:15)
    at Function.Module._load (internal/modules/cjs/loader.js:899:27)
    at Module.require (internal/modules/cjs/loader.js:1090:19)
    at require (internal/modules/cjs/helpers.js:75:18)
    at Object.<anonymous> (/home/klock/.config/nvim/autoload/plugged/markdown-preview.nvim/app/lib/app/index.js:3:1
7)
    at Module._compile (internal/modules/cjs/loader.js:1201:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1221:10)
    at Module.load (internal/modules/cjs/loader.js:1050:32)
    at Function.Module._load (internal/modules/cjs/loader.js:938:14)
    at Module.require (internal/modules/cjs/loader.js:1090:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/klock/.config/nvim/autoload/plugged/markdown-preview.nvim/app/lib/app/index.js',
    '/home/klock/.config/nvim/autoload/plugged/markdown-preview.nvim/app/index.js'
  ]
iamcco commented 4 years ago

@ikey4u should be fixed now.

@Abdulee your plugin install is not complete. do call mkdp#util#install() again or go to plugin's app directory run yarn install or npm install

ikey4u commented 4 years ago

@iamcco

Thank your quick response!

But unfortunately, the patch fix listen address does not make the magic.

iamcco commented 4 years ago

@iamcco

Thank your quick response!

But unfortunately, the patch fix listen address does not make the magic.

It's weird, it works for me. check the log.

ikey4u commented 4 years ago

@iamcco Thank your quick response! But unfortunately, the patch fix listen address does not make the magic.

It's weird, it works for me. check the log.

When I add proxy for yarn, it occurred to me that NODE does not recognize URL without a protocol! As a result, If nvim listen a remote address, the url should be passed like http://127.0.0.1:9999 rather than 127.0.0.1:9999. 127.0.0.1:9999 could not be recognized in your NODE based plugin. Thats should be the key.

However, in the official documentation of neovim, it gives an example nvim --listen 127.0.0.1:9999 which has no protocol. And I have used command nvim --listen http://127.0.0.:9999 but neovim cannot recognize this address. It looks like that neovim does not support protocol!

Change nvim listen on unix socket, it works well and so does your plugin, the problem goes away.

Abdulee commented 4 years ago

@Abdulee your plugin install is not complete. do call mkdp#util#install() again or go to plugin's app directory run yarn install or npm install

Thank you very much. I did a yarn install and it was it now works like a charm.

Alex-ley commented 3 years ago

It's strange, I have somewhat the opposite result when mimicking @ikey4u 's approach

run:

nvim --listen 127.0.0.1:9999 README.md

Then run :MarkdownPreview and it works.

When I do my normal routine:

nvim README.md

Then run :MarkdownPreview and it often does nothing.

I usually use nvim, but I've been having some issues with their nightly build (0.5.0-Beta) (which I had to get to use my German QWERTZ keyboard's { [ ] } characters-- kind of essential--) getting segmentation faults.

So, I tried to switch to vim (8.2) and the good thing is that all my plugins with vim plug work fine, except for MarkdownPreview.

I tried all methods I found on the GH issues (cd into folder and run npm install, run :PlugInstall, :PlugUpgrade, and :call mkdp#util#install(), etc. and it seems to be all going fine (and it works for nvim like I said), but when I use vim and run :MarkdownPreview, literally nothing happens. There is also no option for using vim to do something like:

vim --listen 127.0.0.1:9999 README.md

Any ideas? MarkdownPreview should work with vim >8.1?

rambip commented 3 years ago

I think the npm installs work differently in arch than in other distros.

I use packer for my nvim plugins, and: The config use {'iamcco/markdown-preview.nvim', run = 'cd app && npm install'} doesn't work for me, even if I have npm installed.

But this one use {'iamcco/markdown-preview.nvim', config = "vim.call('mkdp#util#install')"} works well.

The install proposed in #329 should be the prebuild I think, this would cause less bugs.

Vanderscycle commented 3 years ago

It's strange, I have somewhat the opposite result when mimicking @ikey4u 's approach

run:

nvim --listen 127.0.0.1:9999 README.md

Then run :MarkdownPreview and it works.

When I do my normal routine:

nvim README.md

Then run :MarkdownPreview and it often does nothing.

I usually use nvim, but I've been having some issues with their nightly build (0.5.0-Beta) (which I had to get to use my German QWERTZ keyboard's { [ ] } characters-- kind of essential--) getting segmentation faults.

So, I tried to switch to vim (8.2) and the good thing is that all my plugins with vim plug work fine, except for MarkdownPreview.

I tried all methods I found on the GH issues (cd into folder and run npm install, run :PlugInstall, :PlugUpgrade, and :call mkdp#util#install(), etc. and it seems to be all going fine (and it works for nvim like I said), but when I use vim and run :MarkdownPreview, literally nothing happens. There is also no option for using vim to do something like:

vim --listen 127.0.0.1:9999 README.md

Any ideas? MarkdownPreview should work with vim >8.1?

This actually solved the issue I was having with packer and getting :MarkdownPreview to launch