From f0ecb8f9c2647b3cb010c1793ee3026e7064e8cf Mon Sep 17 00:00:00 2001 From: iamcco Date: Mon, 14 Jan 2019 22:11:00 +0800 Subject: [PATCH] add g:mkdp_echo_preview_url to display url when open preview page --- README.md | 10 ++++++++++ app/server.js | 4 ++++ autoload/mkdp/util.vim | 6 ++++++ package.json | 2 +- plugin/mkdp.vim | 6 ++++++ 5 files changed, 27 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d6b697b..548513f 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,10 @@ let g:mkdp_open_to_the_world = 0 " default: '' let g:mkdp_browser = '' +" set to 1, echo preview page url in command line when open preview page +" default is 0 +let g:mkdp_echo_preview_url = 0 + " options for markdown render " mkit: markdown-it options for render " katex: katex options for math @@ -99,6 +103,12 @@ command: :MarkdownPreviewStop ``` +### F&Q + +A: Why my sync scroll is slow reaction + +B: set `updatetime` to a small number, like `set updatetime=100` + ### reference - [coc.nvim](https://github.com/neoclide/coc.nvim) diff --git a/app/server.js b/app/server.js index 877763b..c70bed0 100644 --- a/app/server.js +++ b/app/server.js @@ -118,6 +118,10 @@ async function startServer () { } else { opener(url) } + const isEchoUrl = await plugin.nvim.getVar('mkdp_echo_preview_url') + if (isEchoUrl) { + plugin.nvim.call('mkdp#util#echo_url', [url]) + } } plugin.init({ refreshPage, diff --git a/autoload/mkdp/util.vim b/autoload/mkdp/util.vim index 050fec3..44bed1f 100644 --- a/autoload/mkdp/util.vim +++ b/autoload/mkdp/util.vim @@ -15,6 +15,12 @@ function! mkdp#util#echo_messages(hl, msgs) echohl None endfunction +" echo url +function! mkdp#util#echo_url(url) + let l:url = 'Preview page: ' . a:url + call mkdp#util#echo_messages('Type', l:url) +endfunction + " try open preview page function! s:try_open_preview_page(timer_id) abort let l:server_status = mkdp#rpc#get_server_status() diff --git a/package.json b/package.json index 8b7f94c..fa678e2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "markdown-preview.vim", - "version": "0.0.5", + "version": "0.0.6", "description": "markdown preview plugin for (neo)vim", "bin": "./app/server.js", "repository": "https://github.com/iamcco/markdown-preview.vim.git", diff --git a/plugin/mkdp.vim b/plugin/mkdp.vim index 37471da..6884648 100644 --- a/plugin/mkdp.vim +++ b/plugin/mkdp.vim @@ -33,6 +33,12 @@ if !exists('g:mkdp_open_to_the_world') let g:mkdp_open_to_the_world = 0 endif +" set to 1, echo preview page url in command line when open preview page +" default is 0 +if !exists('g:mkdp_echo_preview_url') + let g:mkdp_echo_preview_url = 0 +endif + " switch browser to open preview page if !exists('g:mkdp_browser') let g:mkdp_browser = ''