Commit Graph

22 Commits

Author SHA1 Message Date
Lewis Russell
2d99830706
refactor(man): add type annotations 2023-02-21 12:19:09 +00:00
Lewis Russell
9ce44a750c
fix(man): use italics for <bs>_ (#22086)
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-02-01 17:21:42 +00:00
0xAdk
3c48d3c83f
fix(man.lua): open in current window if it's already a man page (#21987)
This matters when there are multiple man page windows open.
2023-01-25 22:39:25 +08:00
euclidianAce
0faf007a23
fix(man.lua): use env command (#21007)
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-09 23:26:02 +00:00
Kevin Hwang
cc5b7368d6
fix(man.lua): set modifiable before writing page (#20914) 2022-11-03 09:13:29 +08:00
Mahmoud Al-Qudsi
39911d76be
fix(man): handle absolute paths as :Man targets (#20624)
* 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-17 10:37:44 +01:00
Lewis Russell
288208257c feat(cscope)!: remove 2022-10-13 16:37:23 +01:00
Lewis Russell
b126b11840 fix(man): support MacOS 13
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-11 15:38:15 +01:00
Lewis Russell
cba05c541d
refactor(man): pass env directly to spawn() (#20591) 2022-10-11 13:25:42 +01:00
bfredl
02f8ca59a8 fix(tests): indicate in test logs when nvim exit times out
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-22 10:38:11 +02:00
Lewis Russell
abe2d90693
feat(lua): move compat module from runtime to test (#20257) 2022-09-20 11:15:32 +01:00
zeertzjq
1ef7720567 fix(api)!: correctly deal with number before :tab
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-02 22:28:57 +08:00
Lewis Russell
2afcdbd63a
feat(Man): port to Lua (#19912)
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2022-09-02 15:20:29 +01:00
Christian Clason
aefdc6783c chore: format runtime with stylua 2022-05-09 16:31:55 +02:00
Kovas Palunas
fdd8dcae01 man.vim: Handle ANSI escape sequences with ":" #10267
closes #10267
2019-06-30 15:25:49 +02:00
Justin M. Keyes
127b8569e6 lint 2018-12-20 11:57:30 +01:00
Justin M. Keyes
221f6fffad runtime/lua/vim/compat.lua
ref #9280
Introduce the `vim.compat` module, to help environments with system Lua
5.2+ run the build/tests. Include the module implicitly in all tests.

ref #8677
legacy `vim` module:
    beep
    buffer
    command
    dict
    eval
    firstline
    lastline
    line
    list
    open
    type
    window
2018-12-20 11:57:30 +01:00
Matěj Cepl
e6d0dea42b test: Lua 5.2/5.3 compat #9280
Make the code run both on Lua 5.1 (which is the default for Neovim, and
is what LuaJIT provides) and Lua 5.2+.
2018-12-20 11:57:30 +01:00
Filip Szymański
423d7af3df man.lua: avoid float conversion on lua 5.3 (#7851)
Error detected while processing function man#open_page[58]..<SNR>54_put_page:
    line    8:
    E5105: Error while calling lua chunk: /usr/share/nvim/runtime/lua/man.lua:165: Vim(let):E805: Using a Float as a Number
2018-01-15 20:14:27 +01:00
Gabriel Holodak
eb44519b5d Address PR comments 2017-12-27 23:28:04 -05:00
Gabriel Holodak
6740c94562 Add support for escape sequences 2017-12-27 23:27:14 -05:00
Gabriel Holodak
c28ce5f619 Switch to processing in Lua 2017-12-27 23:27:14 -05:00