iamcco / iamcco/markdown-preview.nvim
Custom arguments in g:mkdp_browserfunc and :MarkdownPreview
- Dominant language
- JavaScript
- Stars
- 8k
- Forks
- 411
- PR merge metrics
- No merged PRs in 30d
Description
Hi
I was thinking passing custom arguments to browser function, something like:
```viml
function! g:Mkdp_custombrowser(url, custom_args)
silent exec "chromium " . a:custom_args . " --app=" . a:url . " &"
endfunc
let g:mkdp_browserfunc = 'g:Mkdp_custombrowser'
```
And call it like:
`:MarkdownPreview "--arg1=\"foo\" --arg2=\"bar\""`
I was trying to hack around the codebase with something like:
```viml
" plugin/mkdp.vim:
function! s:MkdpAU() abort
command! -buffer -nargs=* MarkdownPreview call mkdp#util#open_preview_page()
call s:init_command()
endfunction
" autoload/mkdp/util.vim:
" open preview page
function! mkdp#util#open_preview_page(args) abort
if get(s:, 'try_id', '') !=# ''
return
endif
let l:server_status = mkdp#rpc#get_server_status()
if l:server_status ==# -1
call mkdp#rpc#start_server()
elseif l:server_status ==# 0
let s:try_id = timer_start(1000, function('s:try_open_preview_page'))
else
call mkdp#util#open_browser(a:args)
endif
endfunction
" open browser
function! mkdp#util#open_browser(args) abort
call mkdp#rpc#open_browser()
call mkdp#autocmd#init()
call mkdp#command#init()
endfunction
```
But got:
```viml
:MarkdownPreview foo
[markdown-preview.vim] UnhandledRejection
Error: nvim_call_function: Vim:E119: Not enough arguments for function: mkdp#util#open_browser
```
I'm not very well versed in VimScript.
Thanks!
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.