From f28cf1279785a2f64f01e8204e81000d11e8ffaf Mon Sep 17 00:00:00 2001 From: Walter Leibbrandt Date: Fri, 29 Jul 2022 14:30:01 +0200 Subject: [PATCH] Enable passing extra args to live-server This enables a high degree of customization. I've found it useful for changing the browser being opened, and changing the port on which the live server is started. --- autoload/markdown.vim | 3 ++- doc/nvim-markdown-preview.txt | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/autoload/markdown.vim b/autoload/markdown.vim index 1238ff8..b4e2f10 100644 --- a/autoload/markdown.vim +++ b/autoload/markdown.vim @@ -59,12 +59,13 @@ function! s:LiveServer.start(root, index_path) if !exists('self.pid') let mount_path = fnamemodify(a:index_path, ':h') let index = fnamemodify(a:index_path, ':t') + let extra_opts = get(g:, 'nvim_markdown_preview_liveserver_extra_args', []) let self.pid = jobstart([ \ 'live-server', \ '--quiet', \ '--mount='.'/:'.mount_path, \ '--open='.index, - \ ], + \ ] + extra_opts, \ self, \ ) endif diff --git a/doc/nvim-markdown-preview.txt b/doc/nvim-markdown-preview.txt index de3cb6c..8ff5b82 100644 --- a/doc/nvim-markdown-preview.txt +++ b/doc/nvim-markdown-preview.txt @@ -58,4 +58,11 @@ The default is `gfm` (Github flavored markdown). let g:nvim_markdown_preview_format = 'markdown' < +Set this variable to pass any additional options to live-server. + +> + let g:nvim_markdown_preview_liveserver_extra_args = + \ ['--browser=librewolf', '--port=9999'] +< + vim:tw=78:et:ft=help:norl: