diff --git a/.cspell/words.txt b/.cspell/words.txt new file mode 100644 index 0000000..a75e1ac --- /dev/null +++ b/.cspell/words.txt @@ -0,0 +1,5 @@ +choosewin_color_other +darcula_lush +lualine +termguicolors +vim \ No newline at end of file diff --git a/README.md b/README.md index 20b45c7..00152c5 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,11 @@ -A Lush Theme for Neovim. -=== +# darcula_lush + +A dark [Lush](https://github.com/rktjmp/lush.nvim) theme for Neovim. + +The theme includes both its full RGB palette and a dark 16-color ANSI +fallback. With `termguicolors` disabled, Neovim uses the `cterm` colors, so the +theme remains usable in a Linux console or another TTY without true color or +256-color support. See: http://git.io/lush.nvim for more information on Lush and a helper script to setup your repo clone. diff --git a/colors/darcula_lush.lua b/colors/darcula_lush.lua index 2c97148..4462855 100644 --- a/colors/darcula_lush.lua +++ b/colors/darcula_lush.lua @@ -3,4 +3,7 @@ vim.g.colors_name = "darcula_lush" package.loaded["lush_theme.darcula_lush"] = nil -require("lush")(require("lush_theme.darcula_lush")) +local theme = require("lush_theme.darcula_lush") + +require("lush")(theme) +require("lush_theme.darcula_lush.cterm").apply(theme) diff --git a/lua/lush_theme/darcula_lush.lua b/lua/lush_theme/darcula_lush.lua index ba2d8b3..0ccbe10 100644 --- a/lua/lush_theme/darcula_lush.lua +++ b/lua/lush_theme/darcula_lush.lua @@ -15,124 +15,136 @@ ---@diagnostic disable: undefined-global local lush = require("lush") -local hsl = lush.hsl - -local darken = function(color, by) - by = 12 * (by or 1) - return color.darken(by) -end - -local lighten = function(color, by) - by = 12 * (by or 1) - return color.lighten(by) -end - -local black = hsl("#101017") -local black2 = hsl("#101016") - -local base_colors = { - black = black, - black2 = black2, - blue = hsl("#6877bb"), - cyan = hsl("#00FFFF").darken(40), - green = hsl("#6A906A"), - orange = hsl("#BC8043").lighten(8), - red = hsl("#CF6060"), - tan = hsl("#9A8065"), - purple = hsl("#9876AA"), - yellow = hsl("#ffff80").darken(53), - white = hsl("#a5a0a1").lighten(12) -} local primary_colors = { - black = base_colors.black, - black2 = base_colors.black2, - blue = base_colors.blue, - cyan = base_colors.cyan, - green = base_colors.green, - grey = darken(base_colors.white, 5), - orange = base_colors.orange, - light_orange = lighten(base_colors.orange, 1.5), - purple = base_colors.purple, - light_grey = darken(base_colors.white, 1.4), - white = base_colors.white, - red = base_colors.red, - tan = base_colors.tan, - yellow = base_colors.yellow + none = "NONE", + black_dark = "#0A0A0F", + black = "#111118", + black_light = "#1D1B1C", + grey_darkest = "#474344", + grey_darker = "#5C5758", + grey_dark = "#5F595A", + grey = "#766F71", + grey_lighter = "#9C9697", + silver = "#B0ABAC", + silver_lighter = "#BFBBBC", + white = "#FFFFFF", + blue_saturated = "#004EAD", + blue_darkest = "#344074", + blue_darker = "#445397", + blue = "#727FAF", + blue_black_dark = "#20202C", + blue_black = "#212130", + blue_black_light = "#242433", + blue_grey_darkest = "#282839", + blue_grey_darker = "#2E2E42", + blue_grey_dark = "#3F3F5A", + blue_grey = "#434360", + blue_grey_light = "#4D4D6F", + cyan = "#009999", + green_darkest = "#1E3A1E", + green_darker = "#364936", + green_dark = "#506D50", + green = "#6A906A", + yellow_darkest = "#2E2E1E", + yellow = "#B5A15A", + orange_darkest = "#4D3D22", + orange_dark = "#B47A41", + orange = "#C18A53", + orange_light = "#CC9E71", + red_darkest = "#3A1E1E", + red_darker = "#4A2020", + red_dark = "#952D2D", + red = "#C96B68", + purple = "#927B9E", + tan = "#9A8065" } local colors = { - BufferBackground = primary_colors.black, - ColorColumnBackground = lighten(primary_colors.black, 0.8), - CommentForeground = lighten(primary_colors.grey, 2.1), - ConcealBackground = primary_colors.grey, - ConcealForeground = darken(primary_colors.white), + None = primary_colors.none, + IconAzureForeground = primary_colors.blue_saturated, + IconCyanForeground = primary_colors.cyan, + GutterBackground = primary_colors.black_dark, + Background = primary_colors.black, + FaintForeground = primary_colors.black_light, + AddedBackground = primary_colors.green_darkest, + InactiveStatusBackground = primary_colors.blue_black_dark, + StatusBackground = primary_colors.blue_black, + RaisedBackground = primary_colors.blue_black_light, + TabBackground = primary_colors.blue_grey_darkest, + ChangedBackground = primary_colors.yellow_darkest, + SecondaryBackground = primary_colors.blue_grey_darker, + ModeCommandBackground = primary_colors.blue_darkest, + TodoBackground = primary_colors.green_darker, + RemovedBackground = primary_colors.red_darkest, + SelectionBackground = primary_colors.blue_grey_dark, + ModeNormalBackground = primary_colors.blue_grey, + ModeVisualBackground = primary_colors.blue_darker, + ConcealBackground = primary_colors.grey_darkest, + ScrollbarBackground = primary_colors.blue_grey_light, + ModeInsertBackground = primary_colors.green_dark, + LineNrForeground = primary_colors.grey_darker, + ErrorBackground = primary_colors.red_darker, + DiffTextBackground = primary_colors.orange_darkest, + DimForeground = primary_colors.grey_dark, + AccentForeground = primary_colors.blue, + PositiveForeground = primary_colors.green, + CommentForeground = primary_colors.grey, + ModeReplaceBackground = primary_colors.red_dark, ConstantForeground = primary_colors.purple, - CursorLineBackground = lighten(primary_colors.black, 0.8), - CursorLineNrForeground = primary_colors.green, - DirectoryForeground = lighten(primary_colors.light_grey, 1), DirectoryIconForeground = primary_colors.tan, - EOBBackground = primary_colors.black, - ErrorBackground = darken(primary_colors.red, 5), + SecondaryForeground = primary_colors.grey_lighter, + NormalForeground = primary_colors.silver, + WarningForeground = primary_colors.yellow, + OperatorForeground = primary_colors.orange_dark, + EmphasisForeground = primary_colors.silver_lighter, + SyntaxForeground = primary_colors.orange, + FunctionForeground = primary_colors.orange_light, ErrorForeground = primary_colors.red, - FileForeground = primary_colors.light_grey, - FloatBackground = lighten(primary_colors.black, 0.8), - FloatForeground = lighten(primary_colors.white, 2), - FunctionForeground = primary_colors.light_orange, - HighlightBackground = "NONE", - HighlightForeground = lighten(primary_colors.white, 1.5), - HintForeground = darken(primary_colors.white, 1), - InfoForeground = lighten(primary_colors.white), - InlayForeground = lighten(primary_colors.grey, 1), - KeywordForeground = primary_colors.orange, - LineNrForeground = darken(primary_colors.white, 4), - NamespaceForeground = primary_colors.orange, - NonTextForeground = lighten(primary_colors.grey, 1), - NormalForeground = primary_colors.white, - NumberForeground = primary_colors.blue, - NrBackground = darken(primary_colors.black, 3.5), - OperatorForeground = darken(primary_colors.orange, 1), - PmenuSelBackground = lighten(primary_colors.black, 2), - PreProcForeground = primary_colors.yellow, - ProgressForeground = darken(primary_colors.white), - RootForeground = primary_colors.green, - ScrollViewBackground = hsl("#FFFFFF"), - ScrollViewForeground = "NONE", - SearchBackground = "NONE", - SearchForeground = primary_colors.blue, - SelectionBackground = lighten(primary_colors.black, 2), - SpecialForeground = primary_colors.orange, - StatusBackground = lighten(primary_colors.black, 0.7), - StatusBackgroundNC = lighten(primary_colors.black2, 0.7), - StringForeground = primary_colors.green, - WarningForeground = primary_colors.yellow + ScrollbarThumbBackground = primary_colors.white } vim.g.choosewin_color_label = { - gui = {colors.PmenuSelBackground.hex, colors.FloatForeground.hex, "bold"} + gui = {colors.SelectionBackground, colors.EmphasisForeground, "bold"} } vim.g.choosewin_color_label_current = { - gui = {primary_colors.green.hex, colors.FloatBackground.hex, "bold"} + gui = {colors.PositiveForeground, colors.RaisedBackground, "bold"} } vim.g.choosewin_color_other = { - gui = {colors.StatusBackground.hex} + gui = {colors.StatusBackground} } local create_lualine_theme = function() - local theme_colors = { - background_i = darken(primary_colors.green, 2).hex, - background_n = lighten(primary_colors.black, 2.2).hex, - background_b = lighten(primary_colors.black, 1.3).hex, - background_c = colors.StatusBackground.hex, - background_cm = darken(primary_colors.blue, 3.5).hex, - background_r = darken(primary_colors.red, 3).hex, - background_v = darken(primary_colors.blue, 2).hex, - foreground = lighten(primary_colors.white, 1).hex, - foreground_2 = primary_colors.white.hex, - foreground_3 = darken(primary_colors.white).hex - } + local theme_colors + if vim.o.termguicolors then + theme_colors = { + background_i = colors.ModeInsertBackground, + background_n = colors.ModeNormalBackground, + background_b = colors.SecondaryBackground, + background_c = colors.StatusBackground, + background_cm = colors.ModeCommandBackground, + background_r = colors.ModeReplaceBackground, + background_v = colors.ModeVisualBackground, + foreground = colors.EmphasisForeground, + foreground_2 = colors.NormalForeground, + foreground_3 = colors.SecondaryForeground + } + else + theme_colors = { + background_i = 2, + background_n = 8, + background_b = 8, + background_c = 0, + background_cm = 4, + background_r = 1, + background_v = 4, + foreground = 15, + foreground_2 = 7, + foreground_3 = 8 + } + end return { normal = { a = { @@ -204,6 +216,7 @@ if ok then pattern = "darcula_lush", callback = function() lualine.setup({options = {theme = create_lualine_theme()}}) + require("lush_theme.darcula_lush.cterm").apply_matching("^lualine_") end } ) @@ -220,11 +233,11 @@ local theme = CodeHint {gui = "reverse"}, CodeInfo {gui = "reverse"}, CodeWarn {gui = "reverse"}, - ErrorSign {bg = colors.NrBackground, fg = colors.ErrorForeground}, - HintSign {bg = colors.NrBackground, fg = colors.HintForeground}, - InfoSign {bg = colors.NrBackground, fg = colors.InfoForeground}, - WarningSign {bg = colors.NrBackground, fg = colors.WarningForeground}, - IblScope {fg = colors.ConcealForeground, bg = "NONE"}, + ErrorSign {bg = colors.GutterBackground, fg = colors.ErrorForeground}, + HintSign {bg = colors.GutterBackground, fg = colors.SecondaryForeground}, + InfoSign {bg = colors.GutterBackground, fg = colors.EmphasisForeground}, + WarningSign {bg = colors.GutterBackground, fg = colors.WarningForeground}, + IblScope {fg = colors.SecondaryForeground, bg = colors.None}, IdentifierUnderCaret { gui = "underline,bold,italic" }, @@ -239,63 +252,63 @@ local theme = -- -- CoC CocErrorHighlight {fg = colors.ErrorForeground, gui = "bold,underline"}, - CocHintHighlight {fg = colors.HintForeground, gui = "bold,underline"}, - CocInfoHighlight {fg = colors.InfoForeground, gui = "bold,underline"}, + CocHintHighlight {fg = colors.SecondaryForeground, gui = "bold,underline"}, + CocInfoHighlight {fg = colors.EmphasisForeground, gui = "bold,underline"}, CocWarnHighlight {fg = colors.WarningForeground, gui = "bold,underline"}, CocHighlightRead {IdentifierUnderCaret}, CocHighlightText {IdentifierUnderCaret}, CocHighlightWrite {IdentifierUnderCaretWrite}, - CocCodeLens {fg = colors.InlayForeground, bg = "NONE"}, - CocErrorFloat {fg = colors.FloatForeground, bg = colors.FloatBackground}, - CocFloating {fg = colors.FloatForeground, bg = colors.FloatBackground}, - CocHintFloat {fg = colors.FloatForeground, bg = colors.FloatBackground}, - CocHintVirtualText {fg = colors.InlayForeground, bg = "NONE"}, - CocInfoFloat {fg = colors.FloatForeground, bg = colors.FloatBackground}, - CocInlayHint {fg = colors.InlayForeground, bg = "NONE"}, - CocMenuSel {bg = colors.PmenuSelBackground}, + CocCodeLens {fg = colors.DimForeground, bg = colors.None}, + CocErrorFloat {fg = colors.EmphasisForeground, bg = colors.RaisedBackground}, + CocFloating {fg = colors.EmphasisForeground, bg = colors.RaisedBackground}, + CocHintFloat {fg = colors.EmphasisForeground, bg = colors.RaisedBackground}, + CocHintVirtualText {fg = colors.DimForeground, bg = colors.None}, + CocInfoFloat {fg = colors.EmphasisForeground, bg = colors.RaisedBackground}, + CocInlayHint {fg = colors.DimForeground, bg = colors.None}, + CocMenuSel {bg = colors.SelectionBackground}, CocNotificationError { - fg = colors.FloatForeground, - bg = colors.FloatBackground + fg = colors.EmphasisForeground, + bg = colors.RaisedBackground }, CocNotificationInfo { - fg = colors.FloatForeground, - bg = colors.FloatBackground + fg = colors.EmphasisForeground, + bg = colors.RaisedBackground }, CocNotificationProgress { - fg = colors.ProgressForeground, - bg = colors.FloatBackground + fg = colors.SecondaryForeground, + bg = colors.RaisedBackground }, CocNotificationWarning { - fg = colors.FloatForeground, - bg = colors.FloatBackground + fg = colors.EmphasisForeground, + bg = colors.RaisedBackground }, - CocPumMenu {fg = colors.FloatForeground, bg = colors.FloatBackground}, - CocSearch {fg = colors.SearchForeground}, + CocPumMenu {fg = colors.EmphasisForeground, bg = colors.RaisedBackground}, + CocSearch {fg = colors.AccentForeground}, CocSemClass {fg = colors.FunctionForeground}, CocSymbolConstant {fg = colors.ConstantForeground}, CocSymbolConstructor {fg = colors.FunctionForeground}, CocSymbolFunction {fg = colors.FunctionForeground}, CocSymbolMethod {fg = colors.FunctionForeground}, - CocUnderline {fg = colors.NumberForeground, gui = "bold,underline"}, - CocWarningFloat {fg = colors.FloatForeground, bg = colors.FloatBackground}, + CocUnderline {fg = colors.AccentForeground, gui = "bold,underline"}, + CocWarningFloat {fg = colors.EmphasisForeground, bg = colors.RaisedBackground}, -- easymotion EasyMotionShade {fg = colors.CommentForeground}, EasyMotionIncSearch { - fg = colors.SearchForeground, + fg = colors.AccentForeground, gui = "bold,italic,underline" }, EasyMotionTarget {gui = "underline", fg = colors.WarningForeground}, -- -- fidget - FidgetDone {fg = colors.StringForeground}, - FidgetGroup {fg = darken(colors.NormalForeground, 7)}, - FidgetProgress {fg = colors.NumberForeground}, + FidgetDone {fg = colors.PositiveForeground}, + FidgetGroup {fg = colors.FaintForeground}, + FidgetProgress {fg = colors.AccentForeground}, -- -- gitsigns - GitSignsCurrentLineBlame {fg = colors.CommentForeground, bg = "NONE"}, + GitSignsCurrentLineBlame {fg = colors.CommentForeground, bg = colors.None}, -- -- lua - luaParenError {bg = "NONE"}, + luaParenError {bg = colors.None}, -- -- nvim-cmp CmpItemAbbr {fg = colors.NormalForeground}, @@ -303,137 +316,137 @@ local theme = fg = colors.CommentForeground, gui = "strikethrough" }, - CmpItemAbbrMatch {fg = colors.NumberForeground}, + CmpItemAbbrMatch {fg = colors.AccentForeground}, CmpItemAbbrMatchFuzzy {CmpItemAbbrMatch}, - CmpItemKind {fg = colors.KeywordForeground}, - CmpItemKindDefault {fg = colors.KeywordForeground}, - CmpItemMenu {fg = colors.FloatForeground}, + CmpItemKind {fg = colors.SyntaxForeground}, + CmpItemKindDefault {fg = colors.SyntaxForeground}, + CmpItemMenu {fg = colors.EmphasisForeground}, -- -- nvim notify NotifyBackground { - bg = colors.FloatBackground, - fg = colors.FloatBackground + bg = colors.RaisedBackground, + fg = colors.RaisedBackground }, NotifyINFOBody { - -- bg = colors.FloatBackground, - fg = colors.FloatForeground + -- bg = colors.RaisedBackground, + fg = colors.EmphasisForeground }, NotifyINFOBorder { - -- bg = colors.FloatBackground, - fg = colors.FloatForeground + -- bg = colors.RaisedBackground, + fg = colors.EmphasisForeground }, NotifyINFOIcon { - -- bg = colors.FloatBackground, - fg = colors.StringForeground + -- bg = colors.RaisedBackground, + fg = colors.PositiveForeground }, NotifyINFOTitle { - -- bg = colors.FloatBackground, - fg = colors.StringForeground + -- bg = colors.RaisedBackground, + fg = colors.PositiveForeground }, NotifyERRORBody { - -- bg = colors.FloatBackground, - fg = colors.FloatForeground + -- bg = colors.RaisedBackground, + fg = colors.EmphasisForeground }, NotifyERRORBorder { - -- bg = colors.FloatBackground, - fg = colors.FloatForeground + -- bg = colors.RaisedBackground, + fg = colors.EmphasisForeground }, NotifyERRORIcon { - -- bg = colors.FloatBackground, + -- bg = colors.RaisedBackground, fg = colors.ErrorForeground }, NotifyERRORTitle { - -- bg = colors.FloatBackground, + -- bg = colors.RaisedBackground, fg = colors.ErrorForeground }, NotifyWARNBody { - -- bg = colors.FloatBackground, - fg = colors.FloatForeground + -- bg = colors.RaisedBackground, + fg = colors.EmphasisForeground }, NotifyWARNBorder { - -- bg = colors.FloatBackground, - fg = colors.FloatForeground + -- bg = colors.RaisedBackground, + fg = colors.EmphasisForeground }, NotifyWARNIcon { - -- bg = colors.FloatBackground, + -- bg = colors.RaisedBackground, fg = colors.WarningForeground }, NotifyWARNTitle { - -- bg = colors.FloatBackground, + -- bg = colors.RaisedBackground, fg = colors.WarningForeground }, NotifyDEBUGBody { - -- bg = colors.FloatBackground, - fg = colors.FloatForeground + -- bg = colors.RaisedBackground, + fg = colors.EmphasisForeground }, NotifyDEBUGBorder { - -- bg = colors.FloatBackground, - fg = colors.FloatForeground + -- bg = colors.RaisedBackground, + fg = colors.EmphasisForeground }, NotifyDEBUGIcon { - -- bg = colors.FloatBackground, - fg = colors.NumberForeground + -- bg = colors.RaisedBackground, + fg = colors.AccentForeground }, NotifyDEBUGTitle { - -- bg = colors.FloatBackground, - fg = colors.NumberForeground + -- bg = colors.RaisedBackground, + fg = colors.AccentForeground }, NotifyTRACEBody { - -- bg = colors.FloatBackground, + -- bg = colors.RaisedBackground, fg = colors.ConstantForeground }, NotifyTRACEBorder { - -- bg = colors.FloatBackground, + -- bg = colors.RaisedBackground, fg = colors.ConstantForeground }, -- -- nvim tree - NvimTreeEndOfBuffer {bg = colors.EOBBackground}, + NvimTreeEndOfBuffer {bg = colors.Background}, NvimTreeFolderIcon {fg = colors.DirectoryIconForeground}, - NvimTreeFolderName {fg = colors.DirectoryForeground, gui = "bold"}, - NvimTreeNormal {bg = colors.EOBBackground, fg = colors.FileForeground}, - NvimTreeOpenedFolderName {fg = colors.DirectoryForeground, gui = "bold"}, - NvimTreeRootFolder {fg = colors.RootForeground}, + NvimTreeFolderName {fg = colors.SecondaryForeground, gui = "bold"}, + NvimTreeNormal {bg = colors.Background, fg = colors.SecondaryForeground}, + NvimTreeOpenedFolderName {fg = colors.SecondaryForeground, gui = "bold"}, + NvimTreeRootFolder {fg = colors.PositiveForeground}, NvimTreeGitDirty {fg = colors.ErrorForeground}, NvimTreeGitDirtyIcon {fg = colors.ErrorForeground}, - NvimTreeSymlink {fg = colors.NumberForeground, gui = "italic"}, - NvimTreeExecFile {fg = colors.StringForeground, gui = "italic"}, + NvimTreeSymlink {fg = colors.AccentForeground, gui = "italic"}, + NvimTreeExecFile {fg = colors.PositiveForeground, gui = "italic"}, -- -- nvim scrollview ScrollView { - fg = colors.ScrollViewForeground, - bg = colors.ScrollViewBackground + fg = colors.None, + bg = colors.ScrollbarThumbBackground }, -- -- Telescope - TelescopeBorder {bg = lighten(colors.EOBBackground, 1)}, - TelescopeMatching {fg = colors.SearchForeground}, - TelescopeNormal {bg = colors.BufferBackground}, - TelescopePromptNormal {bg = colors.BufferBackground}, + TelescopeBorder {bg = colors.TabBackground}, + TelescopeMatching {fg = colors.AccentForeground}, + TelescopeNormal {bg = colors.Background}, + TelescopePromptNormal {bg = colors.Background}, -- -- Neovim - Added {fg = colors.StringForeground}, + Added {fg = colors.PositiveForeground}, Changed {gui = "italic,underline"}, - Character {fg = colors.StringForeground}, - ColorColumn {bg = colors.ColorColumnBackground}, + Character {fg = colors.PositiveForeground}, + ColorColumn {bg = colors.RaisedBackground}, Comment {fg = colors.CommentForeground}, - Conceal {bg = colors.ConcealBackground, fg = colors.ConcealForeground}, - Conditional {fg = colors.KeywordForeground}, + Conceal {bg = colors.ConcealBackground, fg = colors.SecondaryForeground}, + Conditional {fg = colors.SyntaxForeground}, Constant {fg = colors.ConstantForeground}, Cursor {gui = "reverse"}, CursorColumn { gui = "underline", - fg = colors.HighlightForeground, - bg = colors.HighlightBackground + fg = colors.EmphasisForeground, + bg = colors.None }, - CursorLine {bg = colors.CursorLineBackground}, + CursorLine {bg = colors.RaisedBackground}, CursorLineNr { - bg = colors.NrBackground, - fg = colors.CursorLineNrForeground + bg = colors.GutterBackground, + fg = colors.PositiveForeground }, CurSearch { - fg = colors.SearchForeground, - bg = colors.SearchBackground, + fg = colors.AccentForeground, + bg = colors.None, gui = "bold,italic,underline" }, Delimiter {fg = colors.FunctionForeground}, @@ -447,29 +460,29 @@ local theme = DiagnosticFloatingWarn {CocWarningFloat}, DiagnosticSignError { fg = colors.ErrorForeground, - bg = colors.NrBackground + bg = colors.GutterBackground }, - DiagnosticSignHint {fg = colors.HintForeground, bg = colors.NrBackground}, - DiagnosticSignInfo {fg = colors.InfoForeground, bg = colors.NrBackground}, + DiagnosticSignHint {fg = colors.SecondaryForeground, bg = colors.GutterBackground}, + DiagnosticSignInfo {fg = colors.EmphasisForeground, bg = colors.GutterBackground}, DiagnosticSignWarn { fg = colors.WarningForeground, - bg = colors.NrBackground + bg = colors.GutterBackground }, DiagnosticLineNrError { fg = colors.ErrorForeground, - bg = colors.NrBackground + bg = colors.GutterBackground }, DiagnosticLineNrHint { - fg = colors.HintForeground, - bg = colors.NrBackground + fg = colors.SecondaryForeground, + bg = colors.GutterBackground }, DiagnosticLineNrInfo { - fg = colors.InfoForeground, - bg = colors.NrBackground + fg = colors.EmphasisForeground, + bg = colors.GutterBackground }, DiagnosticLineNrWarn { fg = colors.WarningForeground, - bg = colors.NrBackground + bg = colors.GutterBackground }, DiagnosticUnderlineError { CocErrorHighlight @@ -483,151 +496,150 @@ local theme = DiagnosticUnderlineWarn { CocWarnHighlight }, - DiagnosticVirtualTextError {fg = colors.InlayForeground, bg = "NONE"}, - DiagnosticVirtualTextWarn {fg = colors.InlayForeground, bg = "NONE"}, - DiagnosticVirtualTextInfo {fg = colors.InlayForeground, bg = "NONE"}, - DiagnosticVirtualTextHint {fg = colors.InlayForeground, bg = "NONE"}, - DiffAdd {bg = "#1e3a1e"}, - DiffChange {bg = "#2e2e1e"}, - DiffDelete {bg = "#3a1e1e"}, - DiffText {bg = "#5e4a1e"}, - Directory {fg = colors.FileForeground}, - EndOfBuffer {bg = colors.EOBBackground}, + DiagnosticVirtualTextError {fg = colors.DimForeground, bg = colors.None}, + DiagnosticVirtualTextWarn {fg = colors.DimForeground, bg = colors.None}, + DiagnosticVirtualTextInfo {fg = colors.DimForeground, bg = colors.None}, + DiagnosticVirtualTextHint {fg = colors.DimForeground, bg = colors.None}, + DiffAdd {bg = colors.AddedBackground}, + DiffChange {bg = colors.ChangedBackground}, + DiffDelete {bg = colors.RemovedBackground}, + DiffText {bg = colors.DiffTextBackground}, + Directory {fg = colors.SecondaryForeground}, + EndOfBuffer {bg = colors.Background}, Error { gui = "italic", bg = colors.ErrorBackground, fg = colors.ErrorForeground }, ErrorMsg {fg = colors.ErrorForeground}, - Exception {fg = colors.KeywordForeground}, - FloatBorder {bg = colors.FloatBackground}, - FoldColumn {fg = colors.ErrorForeground, bg = colors.NrBackground}, + Exception {fg = colors.SyntaxForeground}, + FloatBorder {bg = colors.RaisedBackground}, + FoldColumn {fg = colors.ErrorForeground, bg = colors.GutterBackground}, Folded {fg = colors.CommentForeground, bg = colors.ConcealBackground}, Function {fg = colors.FunctionForeground}, Identifier {fg = colors.NormalForeground}, - IncSearch {fg = colors.SearchForeground, gui = "bold,italic,underline"}, - Keyword {fg = colors.KeywordForeground}, - Label {fg = colors.KeywordForeground}, - LineNr {bg = colors.NrBackground, fg = colors.LineNrForeground}, - LineNrSpecial {bg = colors.NrBackground, fg = colors.SpecialForeground}, + IncSearch {fg = colors.AccentForeground, gui = "bold,italic,underline"}, + Keyword {fg = colors.SyntaxForeground}, + Label {fg = colors.SyntaxForeground}, + LineNr {bg = colors.GutterBackground, fg = colors.LineNrForeground}, + LineNrSpecial {bg = colors.GutterBackground, fg = colors.SyntaxForeground}, LspReferenceRead { gui = "underline,italic", - guibg = "NONE" + guibg = colors.None }, LspReferenceText { gui = "underline,italic", - guibg = "NONE" + guibg = colors.None }, LspReferenceWrite { gui = "underline,bold,italic", - guibg = "NONE" + guibg = colors.None }, - LspCodeLens {fg = CocCodeLens.fg}, - LspCodeLensSeparator {fg = CocCodeLens.fg}, - LspSignatureActiveParameter {gui = "italic", fg = colors.NumberForeground}, + LspCodeLens {fg = colors.DimForeground}, + LspCodeLensSeparator {fg = colors.DimForeground}, + LspSignatureActiveParameter {gui = "italic", fg = colors.AccentForeground}, MatchParen { gui = "italic,bold", - bg = "NONE", - fg = colors.MatchParenForeground + bg = colors.None }, - ModeMsg {fg = colors.StringForeground}, - MoreMsg {fg = colors.StringForeground}, - NonText {fg = colors.NonTextForeground}, - Normal {bg = colors.BufferBackground, fg = colors.NormalForeground}, - NormalFloat {bg = colors.FloatBackground, fg = colors.FloatForeground}, - NormalNC {bg = colors.BufferBackground, fg = colors.NormalForeground}, - Number {fg = colors.NumberForeground}, + ModeMsg {fg = colors.PositiveForeground}, + MoreMsg {fg = colors.PositiveForeground}, + NonText {fg = colors.DimForeground}, + Normal {bg = colors.Background, fg = colors.NormalForeground}, + NormalFloat {bg = colors.RaisedBackground, fg = colors.EmphasisForeground}, + NormalNC {bg = colors.Background, fg = colors.NormalForeground}, + Number {fg = colors.AccentForeground}, Operator {fg = colors.OperatorForeground}, - Pmenu {bg = colors.FloatBackground, fg = colors.FloatForeground}, - PmenuMatch {fg = colors.SearchForeground}, - PmenuSbar {bg = lighten(Pmenu.bg, 0.5)}, - PmenuSel {bg = colors.PmenuSelBackground}, - PmenuThumb {bg = lighten(Pmenu.bg, 2)}, - PreProc {fg = colors.PreProcForeground}, - Question {fg = colors.StringForeground}, + Pmenu {bg = colors.RaisedBackground, fg = colors.EmphasisForeground}, + PmenuMatch {fg = colors.AccentForeground}, + PmenuSbar {bg = colors.SecondaryBackground}, + PmenuSel {bg = colors.SelectionBackground}, + PmenuThumb {bg = colors.ScrollbarBackground}, + PreProc {fg = colors.WarningForeground}, + Question {fg = colors.PositiveForeground}, QuickFixLine { - fg = colors.HighlightForeground, - bg = colors.HighlightBackground + fg = colors.EmphasisForeground, + bg = colors.None }, Removed {fg = colors.ErrorForeground}, - Repeat {fg = colors.KeywordForeground}, + Repeat {fg = colors.SyntaxForeground}, Search { - fg = colors.SearchForeground, - bg = colors.SearchBackground, + fg = colors.AccentForeground, + bg = colors.None, gui = "bold,italic,underline" }, - SignColumn {bg = colors.NrBackground}, - Special {fg = colors.SpecialForeground}, - SpecialKey {fg = colors.NonTextForeground}, + SignColumn {bg = colors.GutterBackground}, + Special {fg = colors.SyntaxForeground}, + SpecialKey {fg = colors.DimForeground}, SpellBad {gui = "italic", fg = colors.NormalForeground}, SpellCap {gui = "italic", fg = colors.NormalForeground}, SpellLocal {gui = "italic", fg = colors.NormalForeground}, SpellRare {gui = "italic", fg = colors.NormalForeground}, - Statement {fg = colors.KeywordForeground}, + Statement {fg = colors.SyntaxForeground}, StatusLine {bg = colors.StatusBackground}, - StatusLineNC {bg = colors.StatusBackgroundNC}, - String {fg = colors.StringForeground}, - Substitute {fg = colors.SearchForeground, gui = "underline"}, - TabLine {bg = lighten(colors.EOBBackground)}, - TabLineFill {bg = colors.EOBBackground}, - TabLineSel {gui = "bold", bg = lighten(colors.EOBBackground, 2)}, - Title {fg = colors.FileForeground}, + StatusLineNC {bg = colors.InactiveStatusBackground}, + String {fg = colors.PositiveForeground}, + Substitute {fg = colors.AccentForeground, gui = "underline"}, + TabLine {bg = colors.TabBackground}, + TabLineFill {bg = colors.Background}, + TabLineSel {gui = "bold", bg = colors.SelectionBackground}, + Title {fg = colors.SecondaryForeground}, Todo { - bg = darken(colors.StringForeground, 4), + bg = colors.TodoBackground, fg = colors.NormalForeground, gui = "italic" }, - Type {fg = colors.KeywordForeground}, - Underlined {fg = colors.NumberForeground, gui = "underline"}, - VertSplit {bg = colors.NrBackground}, + Type {fg = colors.SyntaxForeground}, + Underlined {fg = colors.AccentForeground, gui = "underline"}, + VertSplit {bg = colors.GutterBackground}, Visual {bg = colors.SelectionBackground}, WarningMsg {fg = colors.WarningForeground}, - WinSeparator {bg = colors.NrBackground}, + WinSeparator {bg = colors.GutterBackground}, -- -- mini.icons - MiniIconsAzure {fg = hsl("#0050AF")}, - MiniIconsBlue {fg = primary_colors.blue}, - MiniIconsCyan {fg = primary_colors.cyan}, - MiniIconsGreen {fg = primary_colors.green}, - MiniIconsGrey {fg = hsl("#aaaaaa")}, - MiniIconsOrange {fg = primary_colors.orange}, - MiniIconsPurple {fg = primary_colors.purple}, - MiniIconsRed {fg = primary_colors.red}, - MiniIconsYellow {fg = primary_colors.yellow}, + MiniIconsAzure {fg = colors.IconAzureForeground}, + MiniIconsBlue {fg = colors.AccentForeground}, + MiniIconsCyan {fg = colors.IconCyanForeground}, + MiniIconsGreen {fg = colors.PositiveForeground}, + MiniIconsGrey {fg = colors.NormalForeground}, + MiniIconsOrange {fg = colors.SyntaxForeground}, + MiniIconsPurple {fg = colors.ConstantForeground}, + MiniIconsRed {fg = colors.ErrorForeground}, + MiniIconsYellow {fg = colors.WarningForeground}, -- -- mini.statusline MiniStatuslineDevinfo { - bg = lighten(primary_colors.black, 1.3) + bg = colors.SecondaryBackground }, MiniStatuslineFileinfo { - bg = lighten(primary_colors.black, 1.3) + bg = colors.SecondaryBackground }, MiniStatuslineFilename { bg = colors.StatusBackground }, MiniStatuslineModeNormal { - fg = lighten(primary_colors.white, 1), - bg = lighten(primary_colors.black, 2.2), + fg = colors.EmphasisForeground, + bg = colors.ModeNormalBackground, gui = "bold" }, MiniStatuslineModeInsert { - bg = darken(primary_colors.green, 2), - fg = lighten(primary_colors.white, 1), + bg = colors.ModeInsertBackground, + fg = colors.EmphasisForeground, gui = "bold" }, MiniStatuslineModeVisual { - bg = darken(primary_colors.blue, 2), - fg = lighten(primary_colors.white, 1), + bg = colors.ModeVisualBackground, + fg = colors.EmphasisForeground, gui = "bold" }, MiniStatuslineModeReplace { - bg = darken(primary_colors.red, 3), - fg = lighten(primary_colors.white, 1), + bg = colors.ModeReplaceBackground, + fg = colors.EmphasisForeground, gui = "bold" }, MiniStatuslineModeCommand { - bg = darken(primary_colors.blue, 3.5), - fg = lighten(primary_colors.white, 1), + bg = colors.ModeCommandBackground, + fg = colors.EmphasisForeground, gui = "bold" }, MiniStatuslineModeOther { @@ -645,21 +657,21 @@ local theme = sym("@constructor") {fg = colors.FunctionForeground}, sym("@function") {fg = colors.FunctionForeground}, sym("@function.builtin") {fg = colors.FunctionForeground}, - sym("@keyword.directive") {fg = colors.PreProcForeground}, - sym("@keyword.function") {fg = colors.KeywordForeground}, - sym("@keyword.import") {fg = colors.PreProcForeground}, - sym("@keyword.operator") {fg = Operator.fg, gui = Operator.gui}, + sym("@keyword.directive") {fg = colors.WarningForeground}, + sym("@keyword.function") {fg = colors.SyntaxForeground}, + sym("@keyword.import") {fg = colors.WarningForeground}, + sym("@keyword.operator") {fg = colors.OperatorForeground, gui = Operator.gui}, sym("@lsp.type.property.lua") {fg = colors.ConstantForeground}, - sym("@module") {fg = colors.NamespaceForeground}, - sym("@number") {fg = colors.NumberForeground}, - sym("@number.float") {fg = colors.NumberForeground}, - sym("@operator") {fg = Operator.fg, gui = Operator.gui}, - sym("@operator.special") {fg = Operator.fg, gui = Operator.gui}, + sym("@module") {fg = colors.SyntaxForeground}, + sym("@number") {fg = colors.AccentForeground}, + sym("@number.float") {fg = colors.AccentForeground}, + sym("@operator") {fg = colors.OperatorForeground, gui = Operator.gui}, + sym("@operator.special") {fg = colors.OperatorForeground, gui = Operator.gui}, sym("@punctuation.bracket") {fg = colors.FunctionForeground}, - sym("@punctuation.delimiter") {fg = colors.SpecialForeground}, - sym("@punctuation.special") {fg = colors.SpecialForeground}, + sym("@punctuation.delimiter") {fg = colors.SyntaxForeground}, + sym("@punctuation.special") {fg = colors.SyntaxForeground}, sym("@type.cpp") {fg = colors.FunctionForeground}, - sym("@type.definition") {fg = Constant.fg, gui = ""}, + sym("@type.definition") {fg = colors.ConstantForeground, gui = ""}, sym("@variable") {fg = colors.NormalForeground}, sym("@variable.member") {fg = colors.ConstantForeground}, sym("@variable.member.cpp") {fg = colors.NormalForeground} diff --git a/lua/lush_theme/darcula_lush/cterm.lua b/lua/lush_theme/darcula_lush/cterm.lua new file mode 100644 index 0000000..8e623b8 --- /dev/null +++ b/lua/lush_theme/darcula_lush/cterm.lua @@ -0,0 +1,168 @@ +local M = {} + +-- These anchors describe the role of each ANSI color in darcula_lush. They +-- intentionally use only the 16-color palette so the fallback also works on +-- a Linux console and other terminals without 256-color support. +local ansi_anchors = { + {index = 0, rgb = 0x101017}, -- black: editor surfaces + {index = 1, rgb = 0x3a1e1e}, -- dark red: error/diff surfaces + {index = 2, rgb = 0x1e3a1e}, -- dark green: added/success surfaces + {index = 3, rgb = 0x4d3d22}, -- dark yellow: changed surfaces + {index = 4, rgb = 0x344074}, -- dark blue: mode surfaces + {index = 7, rgb = 0xb0abac}, -- light gray: normal text + {index = 8, rgb = 0x5f595a}, -- dark gray: muted text/selections + {index = 9, rgb = 0xc96b68}, -- bright red: errors + {index = 10, rgb = 0x6a906a}, -- bright green: strings + {index = 11, rgb = 0xc18a53}, -- bright yellow: keywords/functions + {index = 12, rgb = 0x727faf}, -- bright blue: numbers/search + {index = 13, rgb = 0x927b9e}, -- bright magenta: constants + {index = 14, rgb = 0x009999}, -- bright cyan: cyan accents + {index = 15, rgb = 0xc4c0c1} -- white: emphasized text +} + +-- Keep the current palette's deliberately muted colors from drifting to a +-- similarly close hue (comments becoming green, for example). The nearest +-- anchor remains a useful fallback when the RGB palette grows. +local color_overrides = { + ["#004ead"] = 12, + ["#009999"] = 14, + ["#0a0a0f"] = 0, + ["#111118"] = 0, + ["#1d1b1c"] = 8, + ["#1e3a1e"] = 2, + ["#20202c"] = 0, + ["#212130"] = 0, + ["#242433"] = 0, + ["#282839"] = 8, + ["#2e2e1e"] = 3, + ["#2e2e42"] = 8, + ["#344074"] = 4, + ["#364936"] = 2, + ["#3a1e1e"] = 1, + ["#3f3f5a"] = 8, + ["#434360"] = 8, + ["#445397"] = 4, + ["#474344"] = 8, + ["#4d4d6f"] = 8, + ["#506d50"] = 2, + ["#5c5758"] = 8, + ["#4a2020"] = 1, + ["#4d3d22"] = 3, + ["#5f595a"] = 8, + ["#727faf"] = 12, + ["#6a906a"] = 10, + ["#766f71"] = 8, + ["#952d2d"] = 1, + ["#958e8f"] = 7, + ["#927b9e"] = 13, + ["#9a8065"] = 11, + ["#9c9697"] = 7, + ["#a19b9c"] = 7, + ["#ababab"] = 7, + ["#b0abac"] = 7, + ["#b5a15a"] = 11, + ["#b47a41"] = 11, + ["#bab5b6"] = 15, + ["#bfbbbc"] = 15, + ["#c18a53"] = 11, + ["#c4c0c1"] = 15, + ["#cc9e71"] = 11, + ["#c96b68"] = 9, + ["#ffffff"] = 15 +} + +local group_overrides = { + CocMenuSel = {ctermfg = 0, ctermbg = 7}, + ColorColumn = {ctermbg = 8}, + CursorColumn = {ctermfg = 7, ctermbg = 8}, + CursorLine = {ctermbg = 8}, + DiffAdd = {ctermfg = 15, ctermbg = 2}, + DiffChange = {ctermfg = 15, ctermbg = 3}, + DiffDelete = {ctermfg = 15, ctermbg = 1}, + DiffText = {ctermfg = 0, ctermbg = 3}, + Error = {ctermfg = 15, ctermbg = 1}, + Folded = {ctermfg = 7, ctermbg = 8}, + PmenuSel = {ctermfg = 0, ctermbg = 7}, + QuickFixLine = {ctermfg = 0, ctermbg = 7}, + StatusLine = {ctermfg = 0, ctermbg = 7}, + StatusLineNC = {ctermfg = 7, ctermbg = 8}, + TabLine = {ctermfg = 7, ctermbg = 8}, + TabLineSel = {ctermfg = 0, ctermbg = 7}, + Visual = {ctermfg = 0, ctermbg = 7} +} + +local function channels(rgb) + return math.floor(rgb / 0x10000) % 0x100, + math.floor(rgb / 0x100) % 0x100, + rgb % 0x100 +end + +local function nearest_ansi(color) + local rgb + if type(color) == "number" then + rgb = color + local override = color_overrides[string.format("#%06x", rgb)] + if override then + return override + end + elseif type(color) ~= "string" then + return nil + else + local hex = color:match("^#(%x%x%x%x%x%x)$") + if not hex then + return nil + end + local override = color_overrides["#" .. hex:lower()] + if override then + return override + end + rgb = tonumber(hex, 16) + end + + local red, green, blue = channels(rgb) + local nearest + local nearest_distance + + for _, anchor in ipairs(ansi_anchors) do + local anchor_red, anchor_green, anchor_blue = channels(anchor.rgb) + local distance = (red - anchor_red) ^ 2 + + (green - anchor_green) ^ 2 + + (blue - anchor_blue) ^ 2 + + if not nearest_distance or distance < nearest_distance then + nearest = anchor.index + nearest_distance = distance + end + end + + return nearest +end + +function M.apply(theme) + local compiled = require("lush").compile(theme) + + for group, attrs in pairs(compiled) do + if not attrs.link then + attrs.ctermfg = nearest_ansi(attrs.fg) + attrs.ctermbg = nearest_ansi(attrs.bg) + + for key, value in pairs(group_overrides[group] or {}) do + attrs[key] = value + end + + vim.api.nvim_set_hl(0, group, attrs) + end + end +end + +function M.apply_matching(pattern) + for group, attrs in pairs(vim.api.nvim_get_hl(0, {})) do + if group:match(pattern) and not attrs.link then + attrs.ctermfg = nearest_ansi(attrs.fg) + attrs.ctermbg = nearest_ansi(attrs.bg) + vim.api.nvim_set_hl(0, group, attrs) + end + end +end + +return M