1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 20:10:05 +08:00

fix(guide): use hide option only for nvim 0.10.0+

This commit is contained in:
Eric Wong 2024-06-09 22:16:21 +08:00
parent c5202375be
commit 511480cabc
2 changed files with 16 additions and 8 deletions

View File

@ -9,7 +9,7 @@ function M.opened()
end end
function M.show() function M.show()
if vim.api.nvim_win_is_valid(M.__winid) then if vim.api.nvim_win_is_valid(M.__winid) and vim.fn.has('nvim-0.10.0') == 1 then
vim.api.nvim_win_set_config(M.__winid, { hide = false }) vim.api.nvim_win_set_config(M.__winid, { hide = false })
end end
end end
@ -24,15 +24,18 @@ function M.open_float(sl, ...)
M.__bufnr = vim.api.nvim_create_buf(false, true) M.__bufnr = vim.api.nvim_create_buf(false, true)
end end
if M.__winid == nil or not M.opened() then if M.__winid == nil or not M.opened() then
M.__winid = vim.api.nvim_open_win(M.__bufnr, false, { local opt = {
relative = 'editor', relative = 'editor',
width = vim.o.columns, width = vim.o.columns,
height = 1, height = 1,
-- highlight = 'SpaceVim_statusline_a_bold', -- highlight = 'SpaceVim_statusline_a_bold',
row = vim.o.lines - 2, row = vim.o.lines - 2,
col = 0, col = 0,
hide = hide, }
}) if vim.fn.has('nvim-0.10.0') == 1 then
opt.hide = hide
end
M.__winid = vim.api.nvim_open_win(M.__bufnr, false, opt)
end end
vim.fn.setwinvar(M.__winid, '&winhighlight', 'Normal:SpaceVim_statusline_a_bold') vim.fn.setwinvar(M.__winid, '&winhighlight', 'Normal:SpaceVim_statusline_a_bold')
vim.fn.setbufvar(M.__bufnr, '&relativenumber', 0) vim.fn.setbufvar(M.__bufnr, '&relativenumber', 0)

View File

@ -567,14 +567,17 @@ local function winopen()
if not vim.api.nvim_buf_is_valid(bufnr) then if not vim.api.nvim_buf_is_valid(bufnr) then
bufnr = buffer.create_buf(false, true) bufnr = buffer.create_buf(false, true)
end end
winid = vim.api.nvim_open_win(bufnr, false, { local opt = {
relative = 'editor', relative = 'editor',
width = vim.o.columns, width = vim.o.columns,
height = 12, height = 12,
row = vim.o.lines - 14, row = vim.o.lines - 14,
col = 0, col = 0,
hide = true, }
}) if vim.fn.has('nvim-0.10.0') == 1 then
opt.hide = true
end
winid = vim.api.nvim_open_win(bufnr, false, opt)
guide_help_mode = false guide_help_mode = false
setlocalopt(bufnr, winid, { setlocalopt(bufnr, winid, {
winhighlight = 'Normal:Pmenu,Search:', winhighlight = 'Normal:Pmenu,Search:',
@ -729,7 +732,9 @@ end
wait_for_input = function() wait_for_input = function()
log.debug('wait for input:') log.debug('wait for input:')
local t = Key.t local t = Key.t
vim.fn.timer_start(10, show_win) if vim.fn.has('nvim-0.10.0') == 1 then
vim.fn.timer_start(10, show_win)
end
local inp = VIM.getchar() local inp = VIM.getchar()
log.debug('inp is:' .. inp) log.debug('inp is:' .. inp)
if inp == t('<Esc>') then if inp == t('<Esc>') then