mirror of
https://github.com/neovim/neovim.git
synced 2024-12-23 20:55:18 -07:00
7121983c45
- Replace all uses of vim.regex with simpler Lua patterns. - Replace all uses of vim.fn.substitute with string.gsub. - Rework error handling so expected errors are passed back via a return. - These get routed up an passed to `vim.notify()` - Any other errors will cause a stack trace. - Reworked the module initialization of `localfile_arg` - Updated all type annotations. - Refactored CLI completion by introduction a parse_cmdline() function. - Simplified `show_toc()` - Refactor highlighting - Inline some functions - Fix completion on MacOS 13 and earlier. - Prefer `manpath -q` over `man -w` - Make completion more efficient by avoiding vim.fn.sort and vim.fn.uniq - Reimplement using a single loop
40 lines
899 B
Lua
40 lines
899 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 err = man.open_page(params.count, params.smods, params.fargs)
|
|
if err then
|
|
vim.notify('man.lua: ' .. 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)
|
|
local err = require('man').read_page(assert(params.match:match('man://(.*)')))
|
|
if err then
|
|
vim.notify('man.lua: ' .. err, vim.log.levels.ERROR)
|
|
end
|
|
end,
|
|
})
|