Open wisonye opened 1 year ago
Hi there! I have been stuck on a similar problem (trying to pass a Lua function to g:mkdp_browserfunc
) for a couple hours today, but I came up with a solution.
Since I couldn't figure out a way to pass the function by name in Lua, I opted for using Vimscript in this way:
vim.api.nvim_exec([[
vimscript here
]]], false)
Then, for the function you want to execute, I believe the code will be:
vim.api.nvim_exec([[
function! open_preview_in_brave(URL)
execute "/home/wison/my-shell/start_brave_browser.sh"
echom ">>> my_markdown_preview >>> open_preview_in_brave | url: " . a:url
endfunction
let g:mkdp_browserfunc = 'open_preview_in_brave'
]], false)
In any case, may I suggest using the variables:
mkdp_browser
to set the browser of choicemkdp_echo_preview_url
to print the URL of the previewI apologize in advance but I am still learning Lua, so the code might not be the best in terms of efficiency :).
Describe the bug Can't make it works with a customized shell script in
LUA
setupTo Reproduce Steps to reproduce the behavior:
Paste the following setting in Lua config file:
.md
file and run:MarkDdownPreview
commandExpected behavior I think the
open_preview_in_brave
function should be call.Screenshots
// Error in neovim
// I also added a little bit of debug code in
app/server.js
to print out the settings to a temp log file,g:mkdp_browserfunc
has been set with the correct function value:Desktop (please complete the following information):
Log: