drop highlight link as string support
authorTran Duc Binh <binhtran432k@gmail.com>
Tue, 23 Aug 2022 01:47:25 +0000 (08:47 +0700)
committerTran Duc Binh <binhtran432k@gmail.com>
Tue, 23 Aug 2022 01:47:25 +0000 (08:47 +0700)
lua/dracula/groups.lua
lua/dracula/init.lua

index 93752fd12aa3774f613bfc49076e11cbfa77cec7..4fce62e858a8147f7e37ca2095afa1ce8596810f 100644 (file)
@@ -25,7 +25,7 @@
 
 ---setup highlight groups
 ---@param configs DefaultConfig
----@return table<string, Highlight | string>
+---@return table<string, Highlight>
 ---@nodiscard
 local function setup(configs)
    local colors = configs.colors
@@ -341,37 +341,37 @@ local function setup(configs)
       BufferInactiveTarget = { fg = colors.red, },
 
       -- Compe
-      CompeDocumentation = "Pmenu",
-      CompeDocumentationBorder = "Pmenu",
+      CompeDocumentation = { link = "Pmenu" },
+      CompeDocumentationBorder = { link = "Pmenu" },
 
       -- Cmp
-      CmpItemKind = "Pmenu",
-      CmpItemAbbr = "Pmenu",
-      CmpItemKindMethod = "TSMethod",
-      CmpItemKindText = "TSText",
-      CmpItemKindFunction = "TSFunction",
-      CmpItemKindConstructor = "TSType",
-      CmpItemKindVariable = "TSVariable",
-      CmpItemKindClass = "TSType",
-      CmpItemKindInterface = "TSType",
-      CmpItemKindModule = "TSNamespace",
-      CmpItemKindProperty = "TSProperty",
-      CmpItemKindOperator = "TSOperator",
-      CmpItemKindReference = "TSParameterReference",
-      CmpItemKindUnit = "TSField",
-      CmpItemKindValue = "TSField",
-      CmpItemKindField = "TSField",
-      CmpItemKindEnum = "TSField",
-      CmpItemKindKeyword = "TSKeyword",
-      CmpItemKindSnippet = "TSText",
-      CmpItemKindColor = "cssColor",
-      CmpItemKindFile = "TSURI",
-      CmpItemKindFolder = "TSURI",
-      CmpItemKindEvent = "TSConstant",
-      CmpItemKindEnumMember = "TSField",
-      CmpItemKindConstant = "TSConstant",
-      CmpItemKindStruct = "TSStructure",
-      CmpItemKindTypeParameter = "TSParameter",
+      CmpItemKind = { link = "Pmenu" },
+      CmpItemAbbr = { link = "Pmenu" },
+      CmpItemKindMethod = { link = "TSMethod" },
+      CmpItemKindText = { link = "TSText" },
+      CmpItemKindFunction = { link = "TSFunction" },
+      CmpItemKindConstructor = { link = "TSType" },
+      CmpItemKindVariable = { link = "TSVariable" },
+      CmpItemKindClass = { link = "TSType" },
+      CmpItemKindInterface = { link = "TSType" },
+      CmpItemKindModule = { link = "TSNamespace" },
+      CmpItemKindProperty = { link = "TSProperty" },
+      CmpItemKindOperator = { link = "TSOperator" },
+      CmpItemKindReference = { link = "TSParameterReference" },
+      CmpItemKindUnit = { link = "TSField" },
+      CmpItemKindValue = { link = "TSField" },
+      CmpItemKindField = { link = "TSField" },
+      CmpItemKindEnum = { link = "TSField" },
+      CmpItemKindKeyword = { link = "TSKeyword" },
+      CmpItemKindSnippet = { link = "TSText" },
+      CmpItemKindColor = { link = "cssColor" },
+      CmpItemKindFile = { link = "TSURI" },
+      CmpItemKindFolder = { link = "TSURI" },
+      CmpItemKindEvent = { link = "TSConstant" },
+      CmpItemKindEnumMember = { link = "TSField" },
+      CmpItemKindConstant = { link = "TSConstant" },
+      CmpItemKindStruct = { link = "TSStructure" },
+      CmpItemKindTypeParameter = { link = "TSParameter" },
 
       -- TS rainbow colors
       rainbowcol1 = { fg = colors.red, },
index 03a0891b58f685472d6d917c58bc02aa2d1b0251..73d7d5187922d45273c8979c175c86edb94cea66 100644 (file)
@@ -10,7 +10,7 @@ local tbl_deep_extend = vim.tbl_deep_extend
 ---@field show_end_of_buffer boolean
 ---@field lualine_bg_color string?
 ---@field colors Palette
----@field overrides table<string, Highlight|string>
+---@field overrides table<string, Highlight>
 local DEFAULT_CONFIG = {
    italic_comment = false,
    transparent_bg = false,
@@ -66,14 +66,9 @@ local function apply(configs)
       groups[group] = setting
    end
 
-   -- run defined highlights
-   for group, value in pairs(groups) do
-      if type(value) == "table" then
-         ---@cast value Highlight
-         nvim_set_hl(0, group, value)
-      elseif type(value) == "string" then
-         nvim_set_hl(0, group, { link = value })
-      end
+   -- set defined highlights
+   for group, setting in pairs(groups) do
+      nvim_set_hl(0, group, setting)
    end
 end