mirror of
https://github.com/neovim/neovim.git
synced 2024-09-17 20:58:20 -04:00
feat(man): allow opening pages in current window (#27861)
With :hide modifier, open page in current window.
This commit is contained in:
parent
102a72a21e
commit
25e7299707
@ -626,8 +626,10 @@ Man Open the manpage for the <cWORD> (man buffers)
|
||||
or <cword> (non-man buffers) under the cursor.
|
||||
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
|
||||
To reuse the current window: >vim
|
||||
:hide Man printf
|
||||
|
||||
Local mappings:
|
||||
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
|
||||
wrapping.
|
||||
|
||||
To use Nvim as a manpager: >
|
||||
To use Nvim as a manpager: >sh
|
||||
export MANPAGER='nvim +Man!'
|
||||
|
||||
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
|
||||
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
|
||||
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
|
||||
|
||||
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: >
|
||||
: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*
|
||||
|
||||
|
@ -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
|
||||
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`,
|
||||
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 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 } })
|
||||
else
|
||||
smods.silent = true
|
||||
|
Loading…
Reference in New Issue
Block a user