mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 11:28:22 +00:00
fix(man.vim): q quits after jump to different tag in MANPAGER modified (#28495)
This commit is contained in:
@@ -24,7 +24,7 @@ if !exists('g:no_plugin_maps') && !exists('g:no_man_maps')
|
|||||||
nnoremap <silent> <buffer> k gk
|
nnoremap <silent> <buffer> k gk
|
||||||
nnoremap <silent> <buffer> gO :lua require'man'.show_toc()<CR>
|
nnoremap <silent> <buffer> gO :lua require'man'.show_toc()<CR>
|
||||||
nnoremap <silent> <buffer> <2-LeftMouse> :Man<CR>
|
nnoremap <silent> <buffer> <2-LeftMouse> :Man<CR>
|
||||||
if get(b:, 'pager')
|
if get(g:, 'pager')
|
||||||
nnoremap <silent> <buffer> <nowait> q :lclose<CR><C-W>q
|
nnoremap <silent> <buffer> <nowait> q :lclose<CR><C-W>q
|
||||||
else
|
else
|
||||||
nnoremap <silent> <buffer> <nowait> q :lclose<CR><C-W>c
|
nnoremap <silent> <buffer> <nowait> q :lclose<CR><C-W>c
|
||||||
|
@@ -411,15 +411,13 @@ local function find_man()
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param pager boolean
|
local function set_options()
|
||||||
local function set_options(pager)
|
|
||||||
vim.bo.swapfile = false
|
vim.bo.swapfile = false
|
||||||
vim.bo.buftype = 'nofile'
|
vim.bo.buftype = 'nofile'
|
||||||
vim.bo.bufhidden = 'unload'
|
vim.bo.bufhidden = 'unload'
|
||||||
vim.bo.modified = false
|
vim.bo.modified = false
|
||||||
vim.bo.readonly = true
|
vim.bo.readonly = true
|
||||||
vim.bo.modifiable = false
|
vim.bo.modifiable = false
|
||||||
vim.b.pager = pager
|
|
||||||
vim.bo.filetype = 'man'
|
vim.bo.filetype = 'man'
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -475,7 +473,7 @@ local function put_page(page)
|
|||||||
vim.cmd([[silent! keeppatterns keepjumps %s/\s\{199,}/\=repeat(' ', 10)/g]])
|
vim.cmd([[silent! keeppatterns keepjumps %s/\s\{199,}/\=repeat(' ', 10)/g]])
|
||||||
vim.cmd('1') -- Move cursor to first line
|
vim.cmd('1') -- Move cursor to first line
|
||||||
highlight_man_page()
|
highlight_man_page()
|
||||||
set_options(false)
|
set_options()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function format_candidate(path, psect)
|
local function format_candidate(path, psect)
|
||||||
@@ -662,7 +660,8 @@ function M.init_pager()
|
|||||||
vim.cmd.file({ 'man://' .. fn.fnameescape(ref):lower(), mods = { silent = true } })
|
vim.cmd.file({ 'man://' .. fn.fnameescape(ref):lower(), mods = { silent = true } })
|
||||||
end
|
end
|
||||||
|
|
||||||
set_options(true)
|
vim.g.pager = true
|
||||||
|
set_options()
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param count integer
|
---@param count integer
|
||||||
@@ -730,7 +729,7 @@ function M.open_page(count, smods, args)
|
|||||||
if not ok then
|
if not ok then
|
||||||
error(ret)
|
error(ret)
|
||||||
else
|
else
|
||||||
set_options(false)
|
set_options()
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.b.man_sect = sect
|
vim.b.man_sect = sect
|
||||||
|
@@ -192,6 +192,7 @@ describe(':Man', function()
|
|||||||
'--headless',
|
'--headless',
|
||||||
'+autocmd VimLeave * echo "quit works!!"',
|
'+autocmd VimLeave * echo "quit works!!"',
|
||||||
'+Man!',
|
'+Man!',
|
||||||
|
'+tag ls',
|
||||||
'+call nvim_input("q")',
|
'+call nvim_input("q")',
|
||||||
}
|
}
|
||||||
matches('quit works!!', fn.system(args, { 'manpage contents' }))
|
matches('quit works!!', fn.system(args, { 'manpage contents' }))
|
||||||
|
Reference in New Issue
Block a user