fix(ui): add conditional `nvim_get_hl_by_name` for Neovim 0.8.0 (#1429)

This commit is contained in:
Iordanis Petkakis 2024-05-04 11:01:20 +03:00 committed by GitHub
parent 3f13f08043
commit 24234f47a2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 2 deletions

View File

@ -131,8 +131,14 @@ function M:mount()
self.buf = vim.api.nvim_create_buf(false, true) self.buf = vim.api.nvim_create_buf(false, true)
end end
local normal = vim.api.nvim_get_hl(0, { name = "Normal" }) local normal, has_bg
local has_bg = normal and normal.bg ~= nil if vim.fn.has("nvim-0.9.0") == 0 then
normal = vim.api.nvim_get_hl_by_name("Normal", true)
has_bg = normal and normal.background ~= nil
else
normal = vim.api.nvim_get_hl(0, { name = "Normal" })
has_bg = normal and normal.bg ~= nil
end
if has_bg and self.opts.backdrop and self.opts.backdrop < 100 and vim.o.termguicolors then if has_bg and self.opts.backdrop and self.opts.backdrop < 100 and vim.o.termguicolors then
self.backdrop_buf = vim.api.nvim_create_buf(false, true) self.backdrop_buf = vim.api.nvim_create_buf(false, true)