aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Cao <75100021+RandomChugokujin@users.noreply.github.com>2024-04-26 14:14:45 -0400
committerGitHub <noreply@github.com>2024-04-26 13:14:45 -0500
commit3a7c30dc93b9b903ff8591c43689c3bdcb4761de (patch)
tree553a444f48aea53bdfa3b0581df83de027087782
parent688860741589b4583129e426f4df0523f9213275 (diff)
downloadrneovim-3a7c30dc93b9b903ff8591c43689c3bdcb4761de.tar.gz
rneovim-3a7c30dc93b9b903ff8591c43689c3bdcb4761de.tar.bz2
rneovim-3a7c30dc93b9b903ff8591c43689c3bdcb4761de.zip
fix(man.vim): q quits after jump to different tag in MANPAGER modified (#28495)
-rw-r--r--runtime/ftplugin/man.vim2
-rw-r--r--runtime/lua/man.lua11
-rw-r--r--test/functional/plugin/man_spec.lua1
3 files changed, 7 insertions, 7 deletions
diff --git a/runtime/ftplugin/man.vim b/runtime/ftplugin/man.vim
index 277ce3c0b3..fdeaae4c3f 100644
--- a/runtime/ftplugin/man.vim
+++ b/runtime/ftplugin/man.vim
@@ -24,7 +24,7 @@ if !exists('g:no_plugin_maps') && !exists('g:no_man_maps')
nnoremap <silent> <buffer> k gk
nnoremap <silent> <buffer> gO :lua require'man'.show_toc()<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
else
nnoremap <silent> <buffer> <nowait> q :lclose<CR><C-W>c
diff --git a/runtime/lua/man.lua b/runtime/lua/man.lua
index 58a69f90dd..02e841030f 100644
--- a/runtime/lua/man.lua
+++ b/runtime/lua/man.lua
@@ -411,15 +411,13 @@ local function find_man()
return false
end
----@param pager boolean
-local function set_options(pager)
+local function set_options()
vim.bo.swapfile = false
vim.bo.buftype = 'nofile'
vim.bo.bufhidden = 'unload'
vim.bo.modified = false
vim.bo.readonly = true
vim.bo.modifiable = false
- vim.b.pager = pager
vim.bo.filetype = 'man'
end
@@ -475,7 +473,7 @@ local function put_page(page)
vim.cmd([[silent! keeppatterns keepjumps %s/\s\{199,}/\=repeat(' ', 10)/g]])
vim.cmd('1') -- Move cursor to first line
highlight_man_page()
- set_options(false)
+ set_options()
end
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 } })
end
- set_options(true)
+ vim.g.pager = true
+ set_options()
end
---@param count integer
@@ -730,7 +729,7 @@ function M.open_page(count, smods, args)
if not ok then
error(ret)
else
- set_options(false)
+ set_options()
end
vim.b.man_sect = sect
diff --git a/test/functional/plugin/man_spec.lua b/test/functional/plugin/man_spec.lua
index e9500bf920..978178191c 100644
--- a/test/functional/plugin/man_spec.lua
+++ b/test/functional/plugin/man_spec.lua
@@ -192,6 +192,7 @@ describe(':Man', function()
'--headless',
'+autocmd VimLeave * echo "quit works!!"',
'+Man!',
+ '+tag ls',
'+call nvim_input("q")',
}
matches('quit works!!', fn.system(args, { 'manpage contents' }))