markdown-preview.nvim
markdown-preview.nvim copied to clipboard
Nothing happens on MarkdownPreview
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.
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
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.
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.
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'
Setting let g:mkdp_browser = 'firefox'
fixed my problem. It doesn't work with chrome though. But it's ok for me.
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 function g:open_browser
will be call with the preview url.
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.
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.
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.
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.
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
I wonder why I can't find it in my mac?
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 by default is should work on mac OS. You should checkout if you have install the plugin correctly.

@Unknown-Chinese-User you should make sure install hook success.
Could you teach me how to install hook?@iamcco
@Unknown-Chinese-User
I installed it in the first way.
@Unknown-Chinese-User do :call mkdp#util#install()
again.
Thank you! I can preview markdown now! This is because my terminal can't access the address.@iamcco
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! :)
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 :
but still nothing happens on :MarkdownPreview in 127.0.0.1:8888
Can anyone give me some help please
Come on,,,, any edge/edge dev players?
cinfig changed :
no use
@homlex make sure command edge
can open browser
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 try
let $NVIM_MKDP_LOG_FILE = expand('~/mkdp-log.log')
let $NVIM_MKDP_LOG_LEVEL = 'debug'
FWIW I had to change it to:
let $NVIM_MKDP_LOG_FILE = $HOME . '/.tmp/mkdp-log.log'
let $NVIM_MKDP_LOG_LEVEL = 'debug'
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).
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.
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']}
@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 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 😁
Running
:messages
listed a JS errorcannot-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!
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 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. 😁
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.
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. 😌
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!