diff --git a/nvim/lua/core/utils.lua b/nvim/lua/core/utils.lua index 4d96dfe9..8929fa13 100644 --- a/nvim/lua/core/utils.lua +++ b/nvim/lua/core/utils.lua @@ -6,13 +6,21 @@ local M = {} ---@return table properties # the highlight group properties function M.get_hlgroup(name, fallback) if vim.fn.hlexists(name) == 1 then - local hl - hl = vim.api.nvim_get_hl(0, { name = name, link = false }) - if not hl.fg then hl.fg = "NONE" end - if not hl.bg then hl.bg = "NONE" end + local group = vim.api.nvim_get_hl(0, { name = name }) + + local hl = { + fg = group.fg == nil and "NONE" or M.parse_hex(group.fg), + bg = group.bg == nil and "NONE" or M.parse_hex(group.bg), + } + return hl end return fallback or {} end +--- Parse a given integer color to a hex value. +function M.parse_hex(int_color) + return string.format("#%x", int_color) +end + return M diff --git a/nvim/lua/plugins/lualine.lua b/nvim/lua/plugins/lualine.lua index 7cbc786b..89f57b3b 100644 --- a/nvim/lua/plugins/lualine.lua +++ b/nvim/lua/plugins/lualine.lua @@ -2,19 +2,19 @@ return { "nvim-lualine/lualine.nvim", event = "VeryLazy", opts = function() - local colors = require("cyberdream.colors").default - local cyberdream = require("lualine.themes.cyberdream").get_theme() + local utils = require("core.utils") local copilot_colors = { - [""] = { fg = colors.grey, bg = colors.none }, - ["Normal"] = { fg = colors.grey, bg = colors.none }, - ["Warning"] = { fg = colors.red, bg = colors.none }, - ["InProgress"] = { fg = colors.yellow, bg = colors.none }, + [""] = utils.get_hlgroup("Comment"), + ["Normal"] = utils.get_hlgroup("Comment"), + ["Warning"] = utils.get_hlgroup("DiagnosticError"), + ["InProgress"] = utils.get_hlgroup("DiagnosticWarn"), } + return { options = { component_separators = { left = " ", right = " " }, section_separators = { left = " ", right = " " }, - theme = cyberdream, + theme = "auto", globalstatus = true, disabled_filetypes = { statusline = { "dashboard", "alpha" } }, }, @@ -43,14 +43,14 @@ return { cond = function() return package.loaded["nvim-navic"] and require("nvim-navic").is_available() end, - color = { fg = colors.grey, bg = colors.none }, + color = utils.get_hlgroup("Comment", nil), }, }, lualine_x = { { require("lazy.status").updates, cond = require("lazy.status").has_updates, - color = { fg = colors.green }, + color = utils.get_hlgroup("DiffAdd"), }, { function() @@ -78,7 +78,7 @@ return { }, { "location", - color = { fg = colors.cyan, bg = colors.none }, + color = utils.get_hlgroup("DiffChange"), }, }, lualine_z = {