aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/man.lua
Commit message (Collapse)AuthorAge
* fix(lua): enable param-type-mismatch diagnosticLewis Russell2026-09-28
| | | | | | | | | Problem: Argument type mismatches are excluded from EmmyLua checks. Solution: Correct runtime annotations and calls, document local checker workarounds, and enable the diagnostic. AI-assisted
* fix(api): correct Lua command and completion typesLewis Russell2026-09-28
| | | | | | | | | | | Problem: Command inputs and parsed modifiers have different optional fields, and completion window IDs are annotated as floating-point values. Solution: Separate modifier input and return types, correct integer IDs, and update the metadata generators and their output. AI-assisted
* fix(lua): enable nil-safety diagnostics in runtime codeLewis Russell2026-09-25
| | | | | | | | | | | | Enable EmmyLua's need-check-nil diagnostic and resolve nullable values through more precise types, explicit invariants, and guards for missing runtime state. Keep analyzer-specific workarounds local and update the affected API documentation. Exclude the bundled re.lua from analysis so its nil-check warnings do not fail CI. AI-assisted
* fix(lua): add missing param annotations (#41911)Lewis Russell2026-09-15
|
* build: enable more EmmyLua checksLewis Russell2026-09-09
| | | | | | | | | | Enable checks for unused code, deprecated calls, return types, and annotations. Fix the warnings and replace the deprecated highlight function. Keep exceptions where old APIs are still needed or the checker gets it wrong. AI-assisted
* build: enable more EmmyLua checksLewis Russell2026-09-08
| | | | | | | | | | | | | | | | - call-non-callable - missing-fields - redefined-label - redefined-local - undefined-field - unreachable-code Promote redefined-local and unreachable-code to warnings. Fix DOS line-ending handling for multiline semantic tokens, and support intersection types in the help parser. AI-assisted
* fix(man): don't grow a highlight into the previous line #41490Stefan VanBuren2026-08-26
| | | | | | | | | | | | | Problem: With these two lines (`\b` marking a backspace): f\bfoo xb\bb line 1's bold run ends at byte 1 and line 2's begins at byte 1, so line 1 renders "fo" in bold rather than "f", and line 2's "b" is not bold at all. Solution: Only grow a highlight group that is on the current row.
* fix(man): allow :Man to open by absolute path #41401Shubh2026-08-23
| | | | | | | | Problem: man -w echoes any existent file back unchanged. :Man rejected all such paths, so :Man /usr/share/man/man1/bash.1 failed even for real man pages. Solution: Accept an echoed path when it looks like a man page (.../man1/foo.1).
* feat(options): lua closure/function optionsJustin M. Keyes2026-07-31
| | | | | | | | | | | | | | | Problem: Cannot assign Lua functions/closures to "func" ('completefunc', 'tagfun', …) or "expr" ('foldexpr', 'indentexpr', …) options. Solution: - Store "func"/"expr" options as `Callback` instead of string. - Delete oceans of copy-pasted code. - BREAKING: LuaRef returned via RPC/Vimscript is now represented as `"<Lua N: file:line>"` (like what `:map` shows) instead of `nil`. - Note: `man.vim` still uses `v:lua` string, bc it's a vimscript ftplugin. Helped-by: Lewis Russell <lewis6991@gmail.com>
* fix(man): use direct lookup without manpath #40421Josh Hirschkorn2026-07-27
| | | | | | | | | | | Problem: On NetBSD, `man -w open` can return the exact manpage path, but `:Man` may still fail when man directories cannot be discovered from `manpath -q`, bare `man -w`, or `$MANPATH`. Solution: Fall back to the direct manpage lookup when directory discovery fails. Add a test for resolving `open(2)` through `goto_tag()` without manpath data.
* fix(man.lua): cache pages until width changes #40607Barrett Ruth2026-07-06
| | | | | | | Problem: :Man unloads hidden buffers, so reopening large pages reruns rendering even when the width is unchanged. Solution: keep regular man buffers loaded and refresh them only when the effective width changes.
* fix(man.lua): highlight codeblocks #40310J. Adly2026-06-18
| | | | | | | | | | | | Problem: :Man does not syntax highlight codeblocks (injected language). Analysis: init_pager() swapped pcall(parse_ref, ref) return values order, so vim.b.man_sect was set to the manpage name instead of the section number, so C syntax highlighting did not load. Solution: Swap the calls.
* docs: dev, lsp, indent-guides #39756Justin M. Keyes2026-05-14
| | | | | | | - document "indent guides" https://github.com/neovim/neovim/issues/39726 - document guidance for "subcommands" https://github.com/neovim/neovim/issues/32263#issuecomment-4436002808 Co-authored-by: glepnir <glephunter@gmail.com> Co-authored-by: Noa Levi <275430404+lphuc2250gma@users.noreply.github.com>
* feat(lua)!: vim.isnil, vim.nonnil, deprecate vim.F #39495Olivia Kinnear2026-05-06
|
* test: fix s390x failuresJustin M. Keyes2026-03-29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* refactor: integer functions, optimize asserts #34112Lewis Russell2026-03-12
| | | | | | | | | | | | 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
* docs: api, messages, lsp, trustJustin M. Keyes2026-03-11
| | | | | gen_vimdoc.lua: In prepare for the upcoming release, comment-out the "Experimental" warning for prerelease features.
* fix(man.lua): :Man ignores section of gzipped manpage #38235MP4302026-03-10
| | | | | | | | | | | | | | | 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.
* refactor(lua): use vim.fs instead of fnamemodifyYochem van Rosmalen2026-01-28
| | | | | | | | | | | | | | | | | | | | | | | | | 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`.
* fix(man.lua): show_toc condition may cause infinite loop #36979Alejandro Exojo2025-12-15
| | | | `lnum` gets set with `vim.fn.nextnonblank`, which returns 0 on failure, and which is truthy on Lua.
* fix(man.lua): :Man slow/hangs if MANPAGER is set #36689Muhammad Saheed2025-11-25
| | | | | | | | | | 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()`
* refactor(lua): consistent use of local aliasesChristian Clason2025-08-28
|
* Don't set manwidth wider than the window (#34078)Fionn Fitzmaurice2025-05-19
| | | | | | | | | | 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.
* fix(runtime): conceal paths in help, man ToC loclist #33764Michele Campeotto2025-05-03
| | | | | | | | | | | | | | | | | 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
* fix(man.lua): E95 when piping to :Man #33068João Bettencourt2025-04-15
| | | | | | | | | | | 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
* fix(man.lua): useless executability check #33438Emanuel Krollmann2025-04-12
| | | | | | | | 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`
* fix(man.lua): noisy "ENOENT" error on Windows #33409Emanuel Krollmann2025-04-12
| | | | | | | Problem: :Man shows noisy "ENOENT: no such file or directory" error on Windows. Solution: Do some checks before calling `vim.system`.
* fix(runtime): gO always says "Help TOC" #32971Justin M. Keyes2025-03-19
| | | | | | | Problem: gO always says "Help TOC". Solution: Use a generic title instead.
* fix(man.lua): skip `Attrs.None` highlights #32262Johannes Larsen2025-02-02
| | | | | | | | | | | | | | | 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>
* fix: resolve all remaining LuaLS diagnosticsLewis Russell2025-01-27
|
* refactor(man.lua): various changesLewis Russell2024-12-18
| | | | | | | | | | | | | | | | | | | - 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
* fix(Man): completion on MacLewis Russell2024-12-16
| | | | | | | | 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
* Revert "fix(Man.lua): trigger completion even without arguments" #31572Justin M. Keyes2024-12-13
| | | This reverts commit 7940ec69136fa992c98aa7b37265fbc2e619232e.
* fix(man.lua): `:Man <tab>` does not complete #31569Luca Saccarola2024-12-13
| | | closes: #31512
* refactor(lsp): drop str_byteindex/str_utfindex wrappers #30915Tristan Knight2024-10-26
| | | | | * deprecate old signatures * move to new str_byteindex/str_utfindex signature * use single-underscore name (double-underscore is reserved for Lua itself)
* feat(man.vim): "q" always closes window #30819xudyang12024-10-15
|
* fix(man): check if buffer is valid before restoring 'tagfunc' (#30180)zeertzjq2024-08-29
|
* fix(man): avoid setting v:errmsg (#30052)zeertzjq2024-08-15
|
* fix(man): filter OSC 8 hyperlink markup #29171Lennard Hofmann2024-06-07
| | | | | 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
* fix(man.vim): q quits after jump to different tag in MANPAGER modified (#28495)Brian Cao2024-04-26
|
* fix(man): pass modifiers also to :tag (#27878)zeertzjq2024-03-16
| | | | There aren't really many modifiers that take an effect on :tag (except maybe :confirm, :unsilent, :verbose), but pass them for consistency.
* feat(man): allow opening pages in current window (#27861)Tomasz N2024-03-16
| | | With :hide modifier, open page in current window.
* docs: small fixesdundargoc2024-01-02
| | | | | | 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>
* fix(man.lua): hardwrapped manpage is not resized #25646James Barford-Evans2023-10-16
| | | | | | | | | | | 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
* feat(man): respect 'wrapmargin' when wrapping man pages (#24091)Gregory Anders2023-06-21
|
* feat(lua): add `vim.system()`Lewis Russell2023-06-07
| | | | | | | | | | | | | | | 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.
* feat(lua): rename vim.loop -> vim.uv (#22846)Lewis Russell2023-06-03
|
* fix(man.lua): return support of all sectionsVadim A. Misbakh-Soloviov2023-05-07
| | | | | | | | | | | | 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>
* fix(man.lua): don't continue on command error (#23009)zeertzjq2023-04-11
| | | Fix #21169
* fix(man.lua): tests, namingJustin M. Keyes2023-03-07
|