From 8b3dee4d5e03859edfa763eb87126324d21003e4 Mon Sep 17 00:00:00 2001 From: Micah Halter Date: Fri, 29 Sep 2023 18:05:47 -0400 Subject: [PATCH] fix: add support for Neovim v0.7+ Co-authored-by: Lukas Reineke --- lua/ibl/highlights.lua | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lua/ibl/highlights.lua b/lua/ibl/highlights.lua index d14a0b64..ce950223 100644 --- a/lua/ibl/highlights.lua +++ b/lua/ibl/highlights.lua @@ -15,7 +15,14 @@ local M = { } local get = function(name) - return vim.api.nvim_get_hl(0, { name = name }) + local hl + if vim.api.nvim_get_hl then -- check for new neovim 0.9 API + hl = vim.api.nvim_get_hl(0, { name = name }) + else + ---@diagnostic disable-next-line + hl = vim.api.nvim_get_hl_by_name(name, true) + end + return hl end local not_set = function(hl) @@ -44,7 +51,7 @@ M.setup = function() local config = conf.get_config(-1) for _, fn in - pairs(hooks.get(-1, hooks.type.HIGHLIGHT_SETUP) --[[ @as ibl.hooks.cb.highlight_setup[] ]]) + pairs(hooks.get(-1, hooks.type.HIGHLIGHT_SETUP) --[[ @as ibl.hooks.cb.highlight_setup[] ]]) do fn() end