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 /test/functional/plugin/man_spec.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 'test/functional/plugin/man_spec.lua')
-rw-r--r-- | test/functional/plugin/man_spec.lua | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/test/functional/plugin/man_spec.lua b/test/functional/plugin/man_spec.lua index e3f3de6252..c1dbc6dac3 100644 --- a/test/functional/plugin/man_spec.lua +++ b/test/functional/plugin/man_spec.lua @@ -21,13 +21,12 @@ local function get_search_history(name) local man = require('man') local res = {} --- @diagnostic disable-next-line:duplicate-set-field - man.find_path = function(sect, name0) + man._find_path = function(name0, sect) table.insert(res, { sect, name0 }) return nil end - local ok, rv = pcall(man.open_page, -1, { tab = 0 }, args) - assert(not ok) - assert(rv and rv:match('no manual entry')) + local err = man.open_page(-1, { tab = 0 }, args) + assert(err and err:match('no manual entry')) return res end) end @@ -225,7 +224,7 @@ describe(':Man', function() matches('^/.+', actual_file) local args = { nvim_prog, '--headless', '+:Man ' .. actual_file, '+q' } matches( - ('Error detected while processing command line:\r\n' .. 'man.lua: "no manual entry for %s"'):format( + ('Error detected while processing command line:\r\n' .. 'man.lua: no manual entry for %s'):format( pesc(actual_file) ), fn.system(args, { '' }) @@ -235,8 +234,8 @@ describe(':Man', function() it('tries variants with spaces, underscores #22503', function() eq({ - { '', 'NAME WITH SPACES' }, - { '', 'NAME_WITH_SPACES' }, + { vim.NIL, 'NAME WITH SPACES' }, + { vim.NIL, 'NAME_WITH_SPACES' }, }, get_search_history('NAME WITH SPACES')) eq({ { '3', 'some other man' }, @@ -255,8 +254,8 @@ describe(':Man', function() { 'n', 'some_other_man' }, }, get_search_history('n some other man')) eq({ - { '', '123some other man' }, - { '', '123some_other_man' }, + { vim.NIL, '123some other man' }, + { vim.NIL, '123some_other_man' }, }, get_search_history('123some other man')) eq({ { '1', 'other_man' }, @@ -265,11 +264,10 @@ describe(':Man', function() end) it('can complete', function() - t.skip(t.is_os('mac') and t.is_arch('x86_64'), 'not supported on intel mac') eq( true, exec_lua(function() - return #require('man').man_complete('f', 'Man g') > 0 + return #require('man').man_complete('f', 'Man f') > 0 end) ) end) |