Add memorable command :MDPreview {start,stop}
This commit is contained in:
@@ -50,13 +50,41 @@ return {
|
||||
{
|
||||
'vihu/penview.nvim',
|
||||
ft = 'markdown',
|
||||
cmd = 'MDPreview',
|
||||
run = function()
|
||||
require("penview.build").install()
|
||||
end,
|
||||
config = function()
|
||||
require('penview').setup({
|
||||
local penview = require('penview')
|
||||
penview.setup({
|
||||
browser = 'firefox',
|
||||
})
|
||||
|
||||
-- :MDPreview {start,stop} previewing the current file in the browser
|
||||
local commands = { start = 'PenviewStart', stop = 'PenviewStop' }
|
||||
local actions = vim.tbl_keys(commands)
|
||||
table.sort(actions)
|
||||
|
||||
vim.api.nvim_create_user_command('MDPreview', function(opts)
|
||||
local command = commands[opts.args]
|
||||
if not command then
|
||||
vim.api.nvim_echo({
|
||||
{
|
||||
'MDPreview: expected {' .. table.concat(actions, ',') .. '}',
|
||||
"ErrorMsg"
|
||||
}
|
||||
}, true, {})
|
||||
return
|
||||
end
|
||||
vim.cmd(command)
|
||||
end, {
|
||||
nargs = 1,
|
||||
complete = function(lead)
|
||||
return vim.tbl_filter(function(action)
|
||||
return vim.startswith(action, lead)
|
||||
end, actions)
|
||||
end,
|
||||
})
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user