mirror of
https://github.com/neovim/neovim
synced 2025-07-16 17:21:49 +00:00
feat(man): allow opening pages in current window (#27861)
With :hide modifier, open page in current window.
This commit is contained in:
@ -626,8 +626,10 @@ Man Open the manpage for the <cWORD> (man buffers)
|
|||||||
or <cword> (non-man buffers) under the cursor.
|
or <cword> (non-man buffers) under the cursor.
|
||||||
Man! Display the current buffer contents as a manpage.
|
Man! Display the current buffer contents as a manpage.
|
||||||
|
|
||||||
|:Man| accepts command modifiers. For example, to use a vertical split: >
|
|:Man| accepts command modifiers. For example, to use a vertical split: >vim
|
||||||
:vertical Man printf
|
:vertical Man printf
|
||||||
|
To reuse the current window: >vim
|
||||||
|
:hide Man printf
|
||||||
|
|
||||||
Local mappings:
|
Local mappings:
|
||||||
K or CTRL-] Jump to the manpage for the <cWORD> under the
|
K or CTRL-] Jump to the manpage for the <cWORD> under the
|
||||||
@ -647,14 +649,14 @@ Variables:
|
|||||||
empty. Enabled by default. Set |FALSE| to enable soft
|
empty. Enabled by default. Set |FALSE| to enable soft
|
||||||
wrapping.
|
wrapping.
|
||||||
|
|
||||||
To use Nvim as a manpager: >
|
To use Nvim as a manpager: >sh
|
||||||
export MANPAGER='nvim +Man!'
|
export MANPAGER='nvim +Man!'
|
||||||
|
|
||||||
Note that when running `man` from the shell and with that `MANPAGER` in your
|
Note that when running `man` from the shell and with that `MANPAGER` in your
|
||||||
environment, `man` will pre-format the manpage using `groff`. Thus, Nvim
|
environment, `man` will pre-format the manpage using `groff`. Thus, Nvim
|
||||||
will inevitably display the manual page as it was passed to it from stdin. One
|
will inevitably display the manual page as it was passed to it from stdin. One
|
||||||
of the caveats of this is that the width will _always_ be hard-wrapped and not
|
of the caveats of this is that the width will _always_ be hard-wrapped and not
|
||||||
soft wrapped as with `g:man_hardwrap=0`. You can set in your environment: >
|
soft wrapped as with `g:man_hardwrap=0`. You can set in your environment: >sh
|
||||||
export MANWIDTH=999
|
export MANWIDTH=999
|
||||||
|
|
||||||
So `groff`'s pre-formatting output will be the same as with `g:man_hardwrap=0` i.e soft-wrapped.
|
So `groff`'s pre-formatting output will be the same as with `g:man_hardwrap=0` i.e soft-wrapped.
|
||||||
@ -662,6 +664,10 @@ So `groff`'s pre-formatting output will be the same as with `g:man_hardwrap=0` i
|
|||||||
To disable bold highlighting: >
|
To disable bold highlighting: >
|
||||||
:highlight link manBold Normal
|
:highlight link manBold Normal
|
||||||
|
|
||||||
|
An alternative to using `MANPAGER` in shell can be redefined `man`, for example: >sh
|
||||||
|
man() {
|
||||||
|
nvim "+hide Man $1"
|
||||||
|
}
|
||||||
|
|
||||||
MARKDOWN *ft-markdown-plugin*
|
MARKDOWN *ft-markdown-plugin*
|
||||||
|
|
||||||
|
@ -254,6 +254,8 @@ The following new APIs and features were added.
|
|||||||
node emit a hyperlink. Hyperlinks are UI specific: in the TUI, the OSC 8
|
node emit a hyperlink. Hyperlinks are UI specific: in the TUI, the OSC 8
|
||||||
control sequence is used.
|
control sequence is used.
|
||||||
|
|
||||||
|
• |:Man| now supports `:hide` modifier to open page in the current window.
|
||||||
|
|
||||||
• |vim.ui.open()| opens URIs using the system default handler (macOS `open`,
|
• |vim.ui.open()| opens URIs using the system default handler (macOS `open`,
|
||||||
Windows `explorer`, Linux `xdg-open`, etc.)
|
Windows `explorer`, Linux `xdg-open`, etc.)
|
||||||
|
|
||||||
|
@ -716,7 +716,7 @@ function M.open_page(count, smods, args)
|
|||||||
local target = ('%s(%s)'):format(name, sect)
|
local target = ('%s(%s)'):format(name, sect)
|
||||||
|
|
||||||
local ok, ret = pcall(function()
|
local ok, ret = pcall(function()
|
||||||
if smods.tab == -1 and find_man() then
|
if smods.hide or (smods.tab == -1 and find_man()) then
|
||||||
vim.cmd.tag({ target, mods = { silent = true, keepalt = true } })
|
vim.cmd.tag({ target, mods = { silent = true, keepalt = true } })
|
||||||
else
|
else
|
||||||
smods.silent = true
|
smods.silent = true
|
||||||
|
Reference in New Issue
Block a user