summaryrefslogtreecommitdiffstatshomepage
path: root/runtime/lua/man.lua
AgeCommit message (Collapse)AuthorFiles
2026-03-29test: fix s390x failuresJustin M. Keyes1
Problem: failures in s390x CI. Solution: - runtime/lua/man.lua: parse_path() can return nil but 3 callers didn't handle it. - skip some tests on s390x. TODO: - TODO: why "build/bin/xxd is not executable" on s390x? - TODO: other failures, not addressed (see below). OTHER FAILURES: FAILED test/functional/treesitter/fold_spec.lua @ 87: treesitter foldexpr recomputes fold levels after lines are added/removed test/functional/treesitter/fold_spec.lua:95: Expected objects to be the same. Passed in: (table: 0x4013c18940) { [1] = '0' [2] = '0' [3] = '0' *[4] = '0' [5] = '0' ... Expected: (table: 0x4005acf900) { [1] = '0' [2] = '0' [3] = '>1' *[4] = '1' [5] = '1' ... stack traceback: (tail call): ? test/functional/treesitter/fold_spec.lua:95: in function <test/functional/treesitter/fold_spec.lua:87> FAILED test/functional/treesitter/select_spec.lua @ 52: treesitter incremental-selection works test/functional/treesitter/select_spec.lua:63: Expected objects to be the same. Passed in: (string) 'bar(2)' Expected: (string) 'foo(1)' stack traceback: (tail call): ? test/functional/treesitter/select_spec.lua:63: in function <test/functional/treesitter/select_spec.lua:52> FAILED test/functional/treesitter/select_spec.lua @ 69: treesitter incremental-selection repeat test/functional/treesitter/select_spec.lua:82: Expected objects to be the same. Passed in: (string) '2' Expected: (string) '4' stack traceback: (tail call): ? test/functional/treesitter/select_spec.lua:82: in function <test/functional/treesitter/select_spec.lua:69> FAILED test/functional/treesitter/select_spec.lua @ 98: treesitter incremental-selection history test/functional/treesitter/select_spec.lua:111: Expected objects to be the same. Passed in: (string) 'bar(2)' Expected: (string) 'foo(1)' stack traceback: (tail call): ? test/functional/treesitter/select_spec.lua:111: in function <test/functional/treesitter/select_spec.lua:98> FAILED test/functional/treesitter/select_spec.lua @ 186: treesitter incremental-selection with injections works test/functional/treesitter/select_spec.lua:201: Expected objects to be the same. Passed in: (string) 'lua' Expected: (string) 'foo' stack traceback: (tail call): ? test/functional/treesitter/select_spec.lua:201: in function <test/functional/treesitter/select_spec.lua:186> FAILED test/functional/treesitter/select_spec.lua @ 216: treesitter incremental-selection with injections ignores overlapping nodes test/functional/treesitter/select_spec.lua:231: Expected objects to be the same. Passed in: (string) ' )' Expected: (string) ' foo(' stack traceback: (tail call): ? test/functional/treesitter/select_spec.lua:231: in function <test/functional/treesitter/select_spec.lua:216> FAILED test/functional/treesitter/select_spec.lua @ 307: treesitter incremental-selection with injections handles disjointed trees test/functional/treesitter/select_spec.lua:337: Expected objects to be the same. Passed in: (string) 'int' Expected: (string) '1}' stack traceback: (tail call): ? test/functional/treesitter/select_spec.lua:337: in function <test/functional/treesitter/select_spec.lua:307> ERROR test/functional/treesitter/parser_spec.lua @ 562: treesitter parser API can run async parses with string parsers test/functional/treesitter/parser_spec.lua:565: attempt to index a nil value stack traceback: test/functional/testnvim/exec_lua.lua:124: in function <test/functional/testnvim/exec_lua.lua:105> (tail call): ? (tail call): ? test/functional/treesitter/parser_spec.lua:563: in function <test/functional/treesitter/parser_spec.lua:562> FAILED test/functional/core/job_spec.lua @ 1157: jobs jobstop() kills entire process tree #6530 test/functional/core/job_spec.lua:1244: retry() attempts: 94 test/functional/core/job_spec.lua:1246: Expected objects to be the same. Passed in: (table: 0x401dd74b30) { [name] = 'sleep <defunct>' [pid] = 33579 [ppid] = 1 } Expected: (userdata) 'vim.NIL' stack traceback: test/testutil.lua:89: in function 'retry' test/functional/core/job_spec.lua:1244: in function <test/functional/core/job_spec.lua:1157>
2026-03-12refactor: integer functions, optimize asserts #34112Lewis Russell1
refactor(lua): add integer coercion helpers Add vim._tointeger() and vim._ensure_integer(), including optional base support, and switch integer-only tonumber()/assert call sites in the Lua runtime to use them. This also cleans up related integer parsing in LSP, health, loader, URI, tohtml, and Treesitter code. supported by AI
2026-03-11docs: api, messages, lsp, trustJustin M. Keyes1
gen_vimdoc.lua: In prepare for the upcoming release, comment-out the "Experimental" warning for prerelease features.
2026-03-10fix(man.lua): :Man ignores section of gzipped manpage #38235MP4301
Problem: Under certain circumstances (e.g. gzipped manpages with mandoc), :Man will not find the correct page because it does not process multiple extensions correctly. For example, with a file named strcpy.3p.gz, it will only check the .gz part to try to check the section. This leads to some pages being inaccessible because it will return the page from the wrong section. Solution: Loop and try multiple extensions to try to find one which matches the name of the section. Also refactor the man.get_path function so that it can be tested.
2026-01-28refactor(lua): use vim.fs instead of fnamemodifyYochem van Rosmalen1
Although powerful -- especially with chained modifiers --, the readability (and therefore maintainability) of `fnamemodify()` and its modifiers is often worse than a function name, giving less context and having to rely on `:h filename-modifiers`. However, it is used plenty in the Lua stdlib: - 16x for the basename: `fnamemodify(path, ':t')` - 7x for the parents: `fnamemodify(path, ':h')` - 7x for the stem (filename w/o extension): `fnamemodify(path, ':r')` - 6x for the absolute path: `fnamemodify(path, ':p')` - 2x for the suffix: `fnamemodify(path, ':e')` - 2x relative to the home directory: `fnamemodify(path, ':~')` - 1x relative to the cwd: `fnamemodify(path, ':.')` The `fs` module in the stdlib provides a cleaner interface for most of these path operations: `vim.fs.basename` instead of `':t'`, `vim.fs.dirname` instead of `':h'`, `vim.fs.abspath` instead of `':p'`. This commit refactors the runtime to use these instead of fnamemodify. Not all fnamemodify calls are removed; some have intrinsic differences in behavior with the `vim.fs` replacement or do not yet have a replacement in the Lua module, i.e. `:~`, `:.`, `:e` and `:r`.
2025-12-15fix(man.lua): show_toc condition may cause infinite loop #36979Alejandro Exojo1
`lnum` gets set with `vim.fn.nextnonblank`, which returns 0 on failure, and which is truthy on Lua.
2025-11-25fix(man.lua): :Man slow/hangs if MANPAGER is set #36689Muhammad Saheed1
Problem: When `MANPAGER` is set to something like 'nvim +Man!', `vim.system({ 'nvim' })` call waits forever for input and times out after 10 seconds in `system()` and the assert on `stdout` being not `nil` fails. Solution: Set `MANPAGER=cat` when calling `system()`
2025-08-28refactor(lua): consistent use of local aliasesChristian Clason1
2025-05-19Don't set manwidth wider than the window (#34078)Fionn Fitzmaurice1
fix: set manwidth to not exceed the window width If we set the MANWIDTH variable to a value wider than the window, the contents wrap and formatting breaks. A more sensible way to handle this is to interpret MANWIDTH as a maximum width, but to set the width to the window size if smaller. See also: #9023, #10748.
2025-05-03fix(runtime): conceal paths in help, man ToC loclist #33764Michele Campeotto1
Problem: The check for concealing paths in TOCs in the qf syntax file fails because the TOC tile has changed. Solution: Force the qf syntax file to be reloaded after the qf_toc variable has been set, so that the it can apply the correct settings. Using the explicit qf_toc key, already used in the syntax file, instead of the title is less prone to breaking. It was also already being set for man pages but it had no effect because the syntax file had already been loaded when the variable was set. Fixes #33733
2025-04-15fix(man.lua): E95 when piping to :Man #33068João Bettencourt1
Problem: When piping raw manpage content into `:Man!`, buf name is set to 'man://.. ref', but the check only matches the prefix. Allows duplicate buffers to be created, triggering E95. Solution: Match full buf name instead of only 'man://' prefix. If the buffer already exists, generate a unique name with 'man://' .. 'ref' .. '?new=' format. Refs: #30132
2025-04-12fix(man.lua): useless executability check #33438Emanuel Krollmann1
Problem: executability check using `uv.fs_access` doesn't work currently and can't work on windows Solution: only check for executable with `vim.fn.executable`
2025-04-12fix(man.lua): noisy "ENOENT" error on Windows #33409Emanuel Krollmann1
Problem: :Man shows noisy "ENOENT: no such file or directory" error on Windows. Solution: Do some checks before calling `vim.system`.
2025-03-19fix(runtime): gO always says "Help TOC" #32971Justin M. Keyes1
Problem: gO always says "Help TOC". Solution: Use a generic title instead.
2025-02-02fix(man.lua): skip `Attrs.None` highlights #32262Johannes Larsen1
Before the 7121983c45d92349a6532f32dcde9f425e30781e refactoring this loop added highlights from a `buf_hls` list that had filtered out elements with `Attrs.None`. After the refactoring this added highlights from `hls` directly, and those elements would fail with e.g.: $ nvim 'man://math.h(0)' Error detected while processing command line: Error executing Lua callback: /usr/share/nvim/runtime/lua/man.lua:205: Invalid 'hl_group': Expected Lua string stack traceback: [C]: in function 'nvim_buf_add_highlight' /usr/share/nvim/runtime/lua/man.lua:205: in function 'highlight_man_page' /usr/share/nvim/runtime/lua/man.lua:632: in function 'init_pager' /usr/share/nvim/runtime/plugin/man.lua:9: in function </usr/share/nvim/runtime/plugin/man.lua:6>
2025-01-27fix: resolve all remaining LuaLS diagnosticsLewis Russell1
2024-12-18refactor(man.lua): various changesLewis Russell1
- 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
2024-12-16fix(Man): completion on MacLewis Russell1
Problem: `man -w` does not work on recent versions of MacOs. Solution: Make it so an empty result is interpreted as an error unless silent=true
2024-12-13Revert "fix(Man.lua): trigger completion even without arguments" #31572Justin M. Keyes1
This reverts commit 7940ec69136fa992c98aa7b37265fbc2e619232e.
2024-12-13fix(man.lua): `:Man <tab>` does not complete #31569Luca Saccarola1
closes: #31512
2024-10-26refactor(lsp): drop str_byteindex/str_utfindex wrappers #30915Tristan Knight1
* deprecate old signatures * move to new str_byteindex/str_utfindex signature * use single-underscore name (double-underscore is reserved for Lua itself)
2024-10-15feat(man.vim): "q" always closes window #30819xudyang11
2024-08-29fix(man): check if buffer is valid before restoring 'tagfunc' (#30180)zeertzjq1
2024-08-15fix(man): avoid setting v:errmsg (#30052)zeertzjq1
2024-06-07fix(man): filter OSC 8 hyperlink markup #29171Lennard Hofmann1
Problem: `man cmake` shows "8;;https://cmake.orghttps://cmake.org8;;" Solution: Remove noise so that it shows as "https://cmake.org". See also: https://en.wikipedia.org/wiki/ANSI_escape_code#OSC
2024-04-26fix(man.vim): q quits after jump to different tag in MANPAGER modified (#28495)Brian Cao1
2024-03-16fix(man): pass modifiers also to :tag (#27878)zeertzjq1
There aren't really many modifiers that take an effect on :tag (except maybe :confirm, :unsilent, :verbose), but pass them for consistency.
2024-03-16feat(man): allow opening pages in current window (#27861)Tomasz N1
With :hide modifier, open page in current window.
2024-01-02docs: small fixesdundargoc1
Co-authored-by: Christian Clason <c.clason@uni-graz.at> Co-authored-by: HiPhish <hiphish@posteo.de> Co-authored-by: JD Rudie <rudiejd@miamioh.edu>
2023-10-16fix(man.lua): hardwrapped manpage is not resized #25646James Barford-Evans1
Problem: If a manpage is opened, its hardwrapped dimensions are not recalculated after closing then revisiting the same manpage. Solution: Unload the manpage when it is hidden. This forces it to be reloaded, which forces the hard-wrapping to be recalculated when it is revisited. Fixes: #25457
2023-06-21feat(man): respect 'wrapmargin' when wrapping man pages (#24091)Gregory Anders1
2023-06-07feat(lua): add `vim.system()`Lewis Russell1
feat(lua): add vim.system() Problem: Handling system commands in Lua is tedious and error-prone: - vim.fn.jobstart() is vimscript and comes with all limitations attached to typval. - vim.loop.spawn is too low level Solution: Add vim.system(). Partly inspired by Python's subprocess module Does not expose any libuv objects.
2023-06-03feat(lua): rename vim.loop -> vim.uv (#22846)Lewis Russell1
2023-05-07fix(man.lua): return support of all sectionsVadim A. Misbakh-Soloviov1
Current behaviour of `:Man` is to only work with "number" sections. This is caused by wrong assumptions about man sections naming. Also, there was similar assumption about length of section dirs in `paths` variable. fixes #23485 Signed-off-by: Vadim Misbakh-Soloviov <git@mva.name>
2023-04-11fix(man.lua): don't continue on command error (#23009)zeertzjq1
Fix #21169
2023-03-07fix(man.lua): tests, namingJustin M. Keyes1
2023-03-07feat(man.lua): support spaces in manpage namesEriks Muhins1
Problem: :Man command errors if given more than two arguments. Thus, it is impossible to open man pages that contain spaces in their names. Solution: Adjust :Man so that it tries variants with spaces and underscores, and uses the first found.
2023-02-21refactor(man): add type annotationsLewis Russell1
2023-02-01fix(man): use italics for `<bs>_` (#22086)Lewis Russell1
fix(man): use italics for <bs>_ Even though underline is strictly what this should be. <bs>_ was used by nroff to indicate italics which wasn't possible on old typewriters so underline was used. Modern terminals now support italics so lets use that now. See: - https://unix.stackexchange.com/questions/274658/purpose-of-ascii-text-with-overstriking-file-format/274795#274795 - https://cmd.inp.nsk.su/old/cmd2/manuals/unix/UNIX_Unleashed/ch08.htm
2023-01-25fix(man.lua): open in current window if it's already a man page (#21987)0xAdk1
This matters when there are multiple man page windows open.
2022-11-09fix(man.lua): use `env` command (#21007)euclidianAce1
Previously man.lua would use the `env` field in the parameters of `vim.loop.spawn` to override things like MANPAGER. This caused issues on NixOS since `spawn` will _override_ the environment rather than _append_ to it (and NixOS relies on a heavily modified environment). Using the `env` command to append to the environment solves this issue.
2022-11-03fix(man.lua): set modifiable before writing page (#20914)Kevin Hwang1
2022-10-17fix(man): handle absolute paths as `:Man` targets (#20624)Mahmoud Al-Qudsi1
* fix(man): handle absolute paths as :Man targets Previously, attempting to provide `:Man` with an absolute path as the name would cause neovim to return the following error: ``` Error detected while processing command line: /usr/local/share/nvim/runtime/lua/man.lua:690: /usr/local/share/nvim/runtime/lua/man.lua:683: Vim:E426: tag not found: nil(nil) Press ENTER or type command to continue ``` ..because it would try to validate the existence of a man page for the provided name by executing `man -w /some/path` which (on at least some Linux machines [0]) returns `/some/path` instead of the path to the nroff files that would be formatted to satisfy the man(1) lookup. While man pages are not normally named after absolute paths, users shouldn't be blamed for trying. Given such a name/path, neovim would **not** complain that the path didn't have a corresponding man file but would error out when trying to call the tag function for the null-propagated name-and-section `nil(nil)`. (The same underlying error existed before this function was ported to lua, but did not exhibit the lua-specific `nil(nil)` name; instead a tag lookup for `()` would fail and error out.) With this patch, we detect the case where `man -w ...` returns the same value as the provided name to not only prevent invoking the tag function for a non-existent/malformed name+sect but also to properly report the non-existence of a man page for the provided lookup (the absolute path). While man(1) can be used to directly read an nroff-formatted document via `man /path/to/nroff.doc`, `:Man /path/to/nroff.doc` never supported this behavior so no functionality is lost in case the provided path _was_ an nroff file. [0]: `man -w /absolute/path` returning `/absolute/path` observed on an Ubuntu 18.04 installation. * test: add regression test for #20624 Add a functional test to `man_spec.lua` to check for a regression for #20624 by first obtaining an absolute path to a random file and materializing it to disk, then attempting to query `:Man` for an entry by that same name/path. The test passes if nvim correctly reports that there is no man page correspending to the provided name/path and fails if any other error (or no error) is shown.
2022-10-13feat(cscope)!: removeLewis Russell1
2022-10-11fix(man): support MacOS 13Lewis Russell1
MacOS 13 has changed its version of `man` to an version that doesn't properly support `man -w` (without arguments). In order to workaround this we simply fallback to $MANPATH. Fixes #20579
2022-10-11refactor(man): pass env directly to spawn() (#20591)Lewis Russell1
2022-09-22fix(tests): indicate in test logs when nvim exit times outbfredl1
When it happens it wastes 2 seconds which is NOT included in the normal busted timing info. It is hard to correct this, but we can at least print a warning when this happens.
2022-09-20feat(lua): move compat module from runtime to test (#20257)Lewis Russell1
2022-09-02fix(api)!: correctly deal with number before :tabzeertzjq1
Now nvim_parse_cmd and nvim_create_user_command use a "tab" value which is the same as the number passed before :tab modifier instead of the number plus 1, and "tab" value is -1 if :tab modifier is not used.
2022-09-02feat(Man): port to Lua (#19912)Lewis Russell1
Co-authored-by: zeertzjq <zeertzjq@outlook.com>