neovim/runtime/plugin/man.lua
Gregory Anders a9b4dc9614
fix(man): set the nested flag for the BufReadCmd autocommand (#26285)
The nested flag must be set so that other autocommands can fire while
the BufReadCmd is still executing.
2023-11-28 17:02:44 -06:00

37 lines
824 B
Lua

if vim.g.loaded_man ~= nil then
return
end
vim.g.loaded_man = true
vim.api.nvim_create_user_command('Man', function(params)
local man = require('man')
if params.bang then
man.init_pager()
else
local ok, err = pcall(man.open_page, params.count, params.smods, params.fargs)
if not ok then
vim.notify(man.errormsg or err, vim.log.levels.ERROR)
end
end
end, {
bang = true,
bar = true,
range = true,
addr = 'other',
nargs = '*',
complete = function(...)
return require('man').man_complete(...)
end,
})
local augroup = vim.api.nvim_create_augroup('man', {})
vim.api.nvim_create_autocmd('BufReadCmd', {
group = augroup,
pattern = 'man://*',
nested = true,
callback = function(params)
require('man').read_page(vim.fn.matchstr(params.match, 'man://\\zs.*'))
end,
})