diff options
author | Lewis Russell <lewis6991@gmail.com> | 2024-12-16 16:16:57 +0000 |
---|---|---|
committer | Lewis Russell <me@lewisr.dev> | 2024-12-18 14:40:36 +0000 |
commit | 7121983c45d92349a6532f32dcde9f425e30781e (patch) | |
tree | 8e8c089870c589e61d998aa9e3fa74ca0ef23080 /runtime/plugin/man.lua | |
parent | 888a803755c58db56b5b20fcf6b812de877056c9 (diff) | |
download | rneovim-7121983c45d92349a6532f32dcde9f425e30781e.tar.gz rneovim-7121983c45d92349a6532f32dcde9f425e30781e.tar.bz2 rneovim-7121983c45d92349a6532f32dcde9f425e30781e.zip |
refactor(man.lua): various changes
- 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
Diffstat (limited to 'runtime/plugin/man.lua')
-rw-r--r-- | runtime/plugin/man.lua | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/runtime/plugin/man.lua b/runtime/plugin/man.lua index 512b1f63e8..d6d90208a2 100644 --- a/runtime/plugin/man.lua +++ b/runtime/plugin/man.lua @@ -8,9 +8,9 @@ vim.api.nvim_create_user_command('Man', function(params) 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) + 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, { @@ -31,6 +31,9 @@ vim.api.nvim_create_autocmd('BufReadCmd', { pattern = 'man://*', nested = true, callback = function(params) - require('man').read_page(vim.fn.matchstr(params.match, 'man://\\zs.*')) + 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, }) |