LunarVim icon indicating copy to clipboard operation
LunarVim copied to clipboard

Unable to define a function for a plugin

Open chrstnwhlrt opened this issue 2 years ago • 4 comments

Problem description

I try to configure iamcco/markdown-preview.nvim plugin (https://github.com/iamcco/markdown-preview.nvim) which allows using a custom function to start the browser (see https://github.com/iamcco/markdown-preview.nvim#faq).

The corresponding nvim config looks like this:

function OpenMarkdownPreview (url)
    execute "silent ! firefox --new-window " . a:url
endfunction
let g:mkdp_browserfunc = 'OpenMarkdownPreview'

My LunarVim adaption looks like this:

vim.fn.OpenMarkdownPreview = function(url)
    vim.cmd("silent ! /Applications/Firefox.app/Contents/MacOS/firefox --new-window " .. url)
end
vim.g.mkdp_browserfunc = "OpenMarkdownPreview"

which is not working, because the plugin is unable to find the function. How can I convert the nvim config correctly?

LunarVim version

rolling-5d964c5

Neovim version (>= 0.7)

NVIM v0.7.0

Operating system/version

macOS 12.3.1

Steps to reproduce

  1. Install the markdown-preview plugin https://github.com/iamcco/markdown-preview.nvim
  2. Try to configure a specific function used within the plugin

support info

Unused here

Screenshots

No response

chrstnwhlrt avatar Jun 13 '22 13:06 chrstnwhlrt

Why are you dont read documentation?

https://www.lunarvim.org/plugins/02-extra-plugins.html#markdown-preview-nvim

kobzar avatar Jun 13 '22 14:06 kobzar

Why are you dont read documentation?

https://www.lunarvim.org/plugins/02-extra-plugins.html#markdown-preview-nvim

Okay maybe I'm missing something out here, but the documentation doesn't say anything about providing a specific function to the plugin using the global configuration variable, or does it?

chrstnwhlrt avatar Jun 15 '22 10:06 chrstnwhlrt

you need to call these before setting up the plugin, it's the downside of using vim globals as a configuration.

you can do this with packer if you replace the config call with setup.

please open a PR to fix the docs :smile:

kylo252 avatar Jun 17 '22 07:06 kylo252

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Oct 12 '22 02:10 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar Oct 27 '22 02:10 github-actions[bot]