2022-09-02 07:20:29 -07:00
|
|
|
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
|
2024-12-16 09:16:57 -07:00
|
|
|
local err = man.open_page(params.count, params.smods, params.fargs)
|
|
|
|
if err then
|
|
|
|
vim.notify('man.lua: ' .. err, vim.log.levels.ERROR)
|
2022-09-02 07:20:29 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end, {
|
|
|
|
bang = true,
|
|
|
|
bar = true,
|
2023-11-06 19:39:27 -07:00
|
|
|
range = true,
|
2022-09-02 07:20:29 -07:00
|
|
|
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://*',
|
2023-11-28 16:02:44 -07:00
|
|
|
nested = true,
|
2022-09-02 07:20:29 -07:00
|
|
|
callback = function(params)
|
2024-12-16 09:16:57 -07:00
|
|
|
local err = require('man').read_page(assert(params.match:match('man://(.*)')))
|
|
|
|
if err then
|
|
|
|
vim.notify('man.lua: ' .. err, vim.log.levels.ERROR)
|
|
|
|
end
|
2022-09-02 07:20:29 -07:00
|
|
|
end,
|
|
|
|
})
|