From 318d9f3a916d5eea10db64deb91c5989a742c44d Mon Sep 17 00:00:00 2001 From: Michael Chris Lopez Date: Fri, 22 Oct 2021 17:32:36 +0800 Subject: [PATCH] only link LspDiagnostic* for < 0.6 --- lua/zenbones/specs/dark.lua | 124 +++++++++++++++------------- lua/zenbones/specs/light.lua | 124 +++++++++++++++------------- lua/zenbones/template/lightline.lua | 4 +- 3 files changed, 136 insertions(+), 116 deletions(-) diff --git a/lua/zenbones/specs/dark.lua b/lua/zenbones/specs/dark.lua index 2bf5366..587a348 100644 --- a/lua/zenbones/specs/dark.lua +++ b/lua/zenbones/specs/dark.lua @@ -13,7 +13,7 @@ local function generate(p, opt) end -- stylua: ignore start - local theme = lush(function() + local base = lush(function() return { -- The following are all the Neovim default highlight groups from the docs -- as of 0.5.0-nightly-446, to aid your theme creation. Your themes should @@ -156,49 +156,23 @@ local function generate(p, opt) -- use these groups, or use their own. Consult your LSP client's -- documentation. - LspReferenceText { ColorColumn }, -- used for highlighting "text" references - LspReferenceRead { ColorColumn }, -- used for highlighting "read" references - LspReferenceWrite { ColorColumn }, -- used for highlighting "write" references + LspReferenceText { ColorColumn }, -- used for highlighting "text" references + LspReferenceRead { ColorColumn }, -- used for highlighting "read" references + LspReferenceWrite { ColorColumn }, -- used for highlighting "write" references + LspCodeLens { LineNr }, - DiagnosticError { Error }, - DiagnosticWarn { WarningMsg }, - DiagnosticInfo { fg = p.water }, - DiagnosticHint { fg = p.blossom }, + DiagnosticError { Error }, + DiagnosticWarn { WarningMsg }, + DiagnosticInfo { fg = p.water }, + DiagnosticHint { fg = p.blossom }, - DiagnosticVirtualTextError { DiagnosticError, bg = p.rose.abs_de(48).da(68) }, - DiagnosticVirtualTextWarn { DiagnosticWarn, bg = p.wood.de(58).da(68) }, + DiagnosticVirtualTextError { DiagnosticError, bg = p.rose.abs_de(48).da(68) }, + DiagnosticVirtualTextWarn { DiagnosticWarn, bg = p.wood.de(58).da(68) }, - DiagnosticUnderlineError { DiagnosticError, gui = "undercurl" }, - DiagnosticUnderlineWarn { DiagnosticWarn, gui = "undercurl" }, - DiagnosticUnderlineInfo { DiagnosticInfo, gui = "undercurl" }, - DiagnosticUnderlineHint { DiagnosticHint, gui = "undercurl" }, - - LspDiagnosticsDefaultError { DiagnosticError }, -- Used as the base highlight group. Other LspDiagnostic highlights link to this by default (except Underline) - LspDiagnosticsDefaultWarning { DiagnosticWarn }, -- Used as the base highlight group. Other LspDiagnostic highlights link to this by default (except Underline) - LspDiagnosticsDefaultInformation { DiagnosticInfo }, -- Used as the base highlight group. Other LspDiagnostic highlights link to this by default (except Underline) - LspDiagnosticsDefaultHint { DiagnosticHint }, -- Used as the base highlight group. Other LspDiagnostic highlights link to this by default (except Underline) - - LspDiagnosticsVirtualTextError { DiagnosticVirtualTextError }, -- Used for "Error" diagnostic virtual text - LspDiagnosticsVirtualTextWarning { DiagnosticVirtualTextWarn }, -- Used for "Warning" diagnostic virtual text - -- LspDiagnosticsVirtualTextInformation { }, -- Used for "Information" diagnostic virtual text - -- LspDiagnosticsVirtualTextHint { }, -- Used for "Hint" diagnostic virtual text - - LspDiagnosticsUnderlineError { DiagnosticUnderlineError }, -- Used to underline "Error" diagnostics - LspDiagnosticsUnderlineWarning { DiagnosticUnderlineWarn }, -- Used to underline "Warning" diagnostics - LspDiagnosticsUnderlineInformation { DiagnosticUnderlineInfo }, -- Used to underline "Information" diagnostics - LspDiagnosticsUnderlineHint { DiagnosticUnderlineHint }, -- Used to underline "Hint" diagnostics - - -- LspDiagnosticsFloatingError { }, -- Used to color "Error" diagnostic messages in diagnostics float - -- LspDiagnosticsFloatingWarning { }, -- Used to color "Warning" diagnostic messages in diagnostics float - -- LspDiagnosticsFloatingInformation { }, -- Used to color "Information" diagnostic messages in diagnostics float - -- LspDiagnosticsFloatingHint { }, -- Used to color "Hint" diagnostic messages in diagnostics float - - -- LspDiagnosticsSignError { }, -- Used for "Error" signs in sign column - -- LspDiagnosticsSignWarning { }, -- Used for "Warning" signs in sign column - -- LspDiagnosticsSignInformation { }, -- Used for "Information" signs in sign column - -- LspDiagnosticsSignHint { }, -- Used for "Hint" signs in sign column - - LspCodeLens { LineNr }, + DiagnosticUnderlineError { DiagnosticError, gui = "undercurl" }, + DiagnosticUnderlineWarn { DiagnosticWarn, gui = "undercurl" }, + DiagnosticUnderlineInfo { DiagnosticInfo, gui = "undercurl" }, + DiagnosticUnderlineHint { DiagnosticHint, gui = "undercurl" }, -- These groups are for the neovim tree-sitter highlights. -- As of writing, tree-sitter support is a WIP, group names may change. @@ -258,7 +232,7 @@ local function generate(p, opt) -- TSLiteral { }; -- Literal text. -- TSURI { }; -- Any URI like a link or email. - TSNote { LspDiagnosticsDefaultInformation }, + TSNote { DiagnosticInfo }, TSWarning { WarningMsg }, TSDanger { Error }, @@ -330,23 +304,23 @@ local function generate(p, opt) BufferVisibleSign { fg = StatusLineNC.fg }, BufferVisibleIndex { fg = StatusLineNC.fg }, - CocErrorSign { LspDiagnosticsDefaultError }, - CocWarningSign { LspDiagnosticsDefaultWarning }, - CocInfoSign { LspDiagnosticsDefaultInformation }, - CocHintSign { LspDiagnosticsDefaultHint }, - CocErrorHighlight { LspDiagnosticsUnderlineError }, - CocWarningHighlight { LspDiagnosticsUnderlineWarning }, - CocInfoHighlight { LspDiagnosticsUnderlineInformation }, - CocHintHighlight { LspDiagnosticsUnderlineHint }, - CocErrorVirtualText { LspDiagnosticsVirtualTextError }, - CocWarningVitualText { LspDiagnosticsVirtualTextWarning }, + CocErrorSign { DiagnosticError }, + CocWarningSign { DiagnosticWarn }, + CocInfoSign { DiagnosticInfo }, + CocHintSign { DiagnosticHint }, + CocErrorHighlight { DiagnosticUnderlineError }, + CocWarningHighlight { DiagnosticUnderlineWarn }, + CocInfoHighlight { DiagnosticUnderlineInfo }, + CocHintHighlight { DiagnosticUnderlineHint }, + CocErrorVirtualText { DiagnosticVirtualTextError }, + CocWarningVitualText { DiagnosticVirtualTextWarn }, CocSelectedText { SpellBad }, CocCodeLens { LineNr }, CocMarkdownLink { fg = p.sky, gui = "underline" }, - NeogitNotificationError { LspDiagnosticsDefaultError }, - NeogitNotificationWarning { LspDiagnosticsDefaultWarning }, - NeogitNotificationInfo { LspDiagnosticsDefaultInformation }, + NeogitNotificationError { DiagnosticError }, + NeogitNotificationWarning { DiagnosticWarn }, + NeogitNotificationInfo { DiagnosticInfo }, NeogitDiffContextHighlight { CursorLine }, NeogitDiffDeleteHighlight { DiffDelete }, @@ -378,7 +352,7 @@ local function generate(p, opt) -- stylua: ignore end local specs = { - theme, + base, } if opt.lighten_noncurrent_window then @@ -386,12 +360,48 @@ local function generate(p, opt) specs, lush(function() return { - NormalNC { theme.Normal, bg = theme.Normal.bg.abs_li(2) }, -- normal text in non-current windows + NormalNC { base.Normal, bg = base.Normal.bg.abs_li(2) }, -- normal text in non-current windows } end) ) end + -- stylua: ignore start + if not vim.diagnostic then + table.insert( + specs, + lush(function() + return { + LspDiagnosticsDefaultError { base.DiagnosticError }, -- Used as the base highlight group. Other LspDiagnostic highlights link to this by default (except Underline) + LspDiagnosticsDefaultWarning { base.DiagnosticWarn }, -- Used as the base highlight group. Other LspDiagnostic highlights link to this by default (except Underline) + LspDiagnosticsDefaultInformation { base.DiagnosticInfo }, -- Used as the base highlight group. Other LspDiagnostic highlights link to this by default (except Underline) + LspDiagnosticsDefaultHint { base.DiagnosticHint }, -- Used as the base highlight group. Other LspDiagnostic highlights link to this by default (except Underline) + + LspDiagnosticsVirtualTextError { base.DiagnosticVirtualTextError }, -- Used for "Error" diagnostic virtual text + LspDiagnosticsVirtualTextWarning { base.DiagnosticVirtualTextWarn }, -- Used for "Warning" diagnostic virtual text + -- LspDiagnosticsVirtualTextInformation { }, -- Used for "Information" diagnostic virtual text + -- LspDiagnosticsVirtualTextHint { }, -- Used for "Hint" diagnostic virtual text + + LspDiagnosticsUnderlineError { base.DiagnosticUnderlineError }, -- Used to underline "Error" diagnostics + LspDiagnosticsUnderlineWarning { base.DiagnosticUnderlineWarn }, -- Used to underline "Warning" diagnostics + LspDiagnosticsUnderlineInformation { base.DiagnosticUnderlineInfo }, -- Used to underline "Information" diagnostics + LspDiagnosticsUnderlineHint { base.DiagnosticUnderlineHint }, -- Used to underline "Hint" diagnostics + + -- LspDiagnosticsFloatingError { }, -- Used to color "Error" diagnostic messages in diagnostics float + -- LspDiagnosticsFloatingWarning { }, -- Used to color "Warning" diagnostic messages in diagnostics float + -- LspDiagnosticsFloatingInformation { }, -- Used to color "Information" diagnostic messages in diagnostics float + -- LspDiagnosticsFloatingHint { }, -- Used to color "Hint" diagnostic messages in diagnostics float + + -- LspDiagnosticsSignError { }, -- Used for "Error" signs in sign column + -- LspDiagnosticsSignWarning { }, -- Used for "Warning" signs in sign column + -- LspDiagnosticsSignInformation { }, -- Used for "Information" signs in sign column + -- LspDiagnosticsSignHint { }, -- Used for "Hint" signs in sign column + } + end) + ) + end + -- stylua: ignore end + return lush.merge(specs) end diff --git a/lua/zenbones/specs/light.lua b/lua/zenbones/specs/light.lua index 60b7387..5c88803 100644 --- a/lua/zenbones/specs/light.lua +++ b/lua/zenbones/specs/light.lua @@ -13,7 +13,7 @@ local function generate(p, opt) end -- stylua: ignore start - local base_specs = lush(function() + local base = lush(function() return { -- The following are all the Neovim default highlight groups from the docs -- as of 0.5.0-nightly-446, to aid your theme creation. Your themes should @@ -156,49 +156,23 @@ local function generate(p, opt) -- use these groups, or use their own. Consult your LSP client's -- documentation. - LspReferenceText { ColorColumn }, -- used for highlighting "text" references - LspReferenceRead { ColorColumn }, -- used for highlighting "read" references - LspReferenceWrite { ColorColumn }, -- used for highlighting "write" references + LspReferenceText { ColorColumn }, -- used for highlighting "text" references + LspReferenceRead { ColorColumn }, -- used for highlighting "read" references + LspReferenceWrite { ColorColumn }, -- used for highlighting "write" references + LspCodeLens { LineNr }, - DiagnosticError { Error }, - DiagnosticWarn { WarningMsg }, - DiagnosticInfo { fg = p.water }, - DiagnosticHint { fg = p.blossom }, + DiagnosticError { Error }, + DiagnosticWarn { WarningMsg }, + DiagnosticInfo { fg = p.water }, + DiagnosticHint { fg = p.blossom }, - DiagnosticVirtualTextError { DiagnosticError, bg = p.rose.abs_de(48).li(82) }, - DiagnosticVirtualTextWarn { DiagnosticWarn, bg = p.wood.de(58).li(86) }, + DiagnosticVirtualTextError { DiagnosticError, bg = p.rose.abs_de(48).li(82) }, + DiagnosticVirtualTextWarn { DiagnosticWarn, bg = p.wood.de(58).li(86) }, - DiagnosticUnderlineError { DiagnosticError, gui = "undercurl" }, - DiagnosticUnderlineWarn { DiagnosticWarn, gui = "undercurl" }, - DiagnosticUnderlineInfo { DiagnosticInfo, gui = "undercurl" }, - DiagnosticUnderlineHint { DiagnosticHint, gui = "undercurl" }, - - LspDiagnosticsDefaultError { DiagnosticError }, -- Used as the base highlight group. Other LspDiagnostic highlights link to this by default (except Underline) - LspDiagnosticsDefaultWarning { DiagnosticWarn }, -- Used as the base highlight group. Other LspDiagnostic highlights link to this by default (except Underline) - LspDiagnosticsDefaultInformation { DiagnosticInfo }, -- Used as the base highlight group. Other LspDiagnostic highlights link to this by default (except Underline) - LspDiagnosticsDefaultHint { DiagnosticHint }, -- Used as the base highlight group. Other LspDiagnostic highlights link to this by default (except Underline) - - LspDiagnosticsVirtualTextError { DiagnosticVirtualTextError }, -- Used for "Error" diagnostic virtual text - LspDiagnosticsVirtualTextWarning { DiagnosticVirtualTextWarn }, -- Used for "Warning" diagnostic virtual text - -- LspDiagnosticsVirtualTextInformation { }, -- Used for "Information" diagnostic virtual text - -- LspDiagnosticsVirtualTextHint { }, -- Used for "Hint" diagnostic virtual text - - LspDiagnosticsUnderlineError { DiagnosticUnderlineError }, -- Used to underline "Error" diagnostics - LspDiagnosticsUnderlineWarning { DiagnosticUnderlineWarn }, -- Used to underline "Warning" diagnostics - LspDiagnosticsUnderlineInformation { DiagnosticUnderlineInfo }, -- Used to underline "Information" diagnostics - LspDiagnosticsUnderlineHint { DiagnosticUnderlineHint }, -- Used to underline "Hint" diagnostics - - -- LspDiagnosticsFloatingError { }, -- Used to color "Error" diagnostic messages in diagnostics float - -- LspDiagnosticsFloatingWarning { }, -- Used to color "Warning" diagnostic messages in diagnostics float - -- LspDiagnosticsFloatingInformation { }, -- Used to color "Information" diagnostic messages in diagnostics float - -- LspDiagnosticsFloatingHint { }, -- Used to color "Hint" diagnostic messages in diagnostics float - - -- LspDiagnosticsSignError { }, -- Used for "Error" signs in sign column - -- LspDiagnosticsSignWarning { }, -- Used for "Warning" signs in sign column - -- LspDiagnosticsSignInformation { }, -- Used for "Information" signs in sign column - -- LspDiagnosticsSignHint { }, -- Used for "Hint" signs in sign column - - LspCodeLens { LineNr }, + DiagnosticUnderlineError { DiagnosticError, gui = "undercurl" }, + DiagnosticUnderlineWarn { DiagnosticWarn, gui = "undercurl" }, + DiagnosticUnderlineInfo { DiagnosticInfo, gui = "undercurl" }, + DiagnosticUnderlineHint { DiagnosticHint, gui = "undercurl" }, -- These groups are for the neovim tree-sitter highlights. -- As of writing, tree-sitter support is a WIP, group names may change. @@ -258,7 +232,7 @@ local function generate(p, opt) -- TSLiteral { }; -- Literal text. -- TSURI { }; -- Any URI like a link or email. - TSNote { LspDiagnosticsDefaultInformation }, + TSNote { DiagnosticInfo }, TSWarning { WarningMsg }, TSDanger { Error }, @@ -330,23 +304,23 @@ local function generate(p, opt) BufferVisibleSign { fg = StatusLineNC.fg }, BufferVisibleIndex { fg = StatusLineNC.fg }, - CocErrorSign { LspDiagnosticsDefaultError }, - CocWarningSign { LspDiagnosticsDefaultWarning }, - CocInfoSign { LspDiagnosticsDefaultInformation }, - CocHintSign { LspDiagnosticsDefaultHint }, - CocErrorHighlight { LspDiagnosticsUnderlineError }, - CocWarningHighlight { LspDiagnosticsUnderlineWarning }, - CocInfoHighlight { LspDiagnosticsUnderlineInformation }, - CocHintHighlight { LspDiagnosticsUnderlineHint }, - CocErrorVirtualText { LspDiagnosticsVirtualTextError }, - CocWarningVitualText { LspDiagnosticsVirtualTextWarning }, + CocErrorSign { DiagnosticError }, + CocWarningSign { DiagnosticWarn }, + CocInfoSign { DiagnosticInfo }, + CocHintSign { DiagnosticHint }, + CocErrorHighlight { DiagnosticUnderlineError }, + CocWarningHighlight { DiagnosticUnderlineWarn }, + CocInfoHighlight { DiagnosticUnderlineInfo }, + CocHintHighlight { DiagnosticUnderlineHint }, + CocErrorVirtualText { DiagnosticVirtualTextError }, + CocWarningVitualText { DiagnosticVirtualTextWarn }, CocSelectedText { SpellBad }, CocCodeLens { LineNr }, CocMarkdownLink { fg = p.sky, gui = "underline" }, - NeogitNotificationError { LspDiagnosticsDefaultError }, - NeogitNotificationWarning { LspDiagnosticsDefaultWarning }, - NeogitNotificationInfo { LspDiagnosticsDefaultInformation }, + NeogitNotificationError { DiagnosticError }, + NeogitNotificationWarning { DiagnosticWarn }, + NeogitNotificationInfo { DiagnosticInfo }, NeogitDiffContextHighlight { CursorLine }, NeogitDiffDeleteHighlight { DiffDelete }, @@ -378,7 +352,7 @@ local function generate(p, opt) -- stylua: ignore end local specs = { - base_specs, + base, } if opt.darken_noncurrent_window then @@ -386,12 +360,48 @@ local function generate(p, opt) specs, lush(function() return { - NormalNC { base_specs.Normal, bg = base_specs.Normal.bg.abs_da(2) }, -- normal text in non-current windows + NormalNC { base.Normal, bg = base.Normal.bg.abs_da(2) }, -- normal text in non-current windows } end) ) end + -- stylua: ignore start + if not vim.diagnostic then + table.insert( + specs, + lush(function() + return { + LspDiagnosticsDefaultError { base.DiagnosticError }, -- Used as the base highlight group. Other LspDiagnostic highlights link to this by default (except Underline) + LspDiagnosticsDefaultWarning { base.DiagnosticWarn }, -- Used as the base highlight group. Other LspDiagnostic highlights link to this by default (except Underline) + LspDiagnosticsDefaultInformation { base.DiagnosticInfo }, -- Used as the base highlight group. Other LspDiagnostic highlights link to this by default (except Underline) + LspDiagnosticsDefaultHint { base.DiagnosticHint }, -- Used as the base highlight group. Other LspDiagnostic highlights link to this by default (except Underline) + + LspDiagnosticsVirtualTextError { base.DiagnosticVirtualTextError }, -- Used for "Error" diagnostic virtual text + LspDiagnosticsVirtualTextWarning { base.DiagnosticVirtualTextWarn }, -- Used for "Warning" diagnostic virtual text + -- LspDiagnosticsVirtualTextInformation { }, -- Used for "Information" diagnostic virtual text + -- LspDiagnosticsVirtualTextHint { }, -- Used for "Hint" diagnostic virtual text + + LspDiagnosticsUnderlineError { base.DiagnosticUnderlineError }, -- Used to underline "Error" diagnostics + LspDiagnosticsUnderlineWarning { base.DiagnosticUnderlineWarn }, -- Used to underline "Warning" diagnostics + LspDiagnosticsUnderlineInformation { base.DiagnosticUnderlineInfo }, -- Used to underline "Information" diagnostics + LspDiagnosticsUnderlineHint { base.DiagnosticUnderlineHint }, -- Used to underline "Hint" diagnostics + + -- LspDiagnosticsFloatingError { }, -- Used to color "Error" diagnostic messages in diagnostics float + -- LspDiagnosticsFloatingWarning { }, -- Used to color "Warning" diagnostic messages in diagnostics float + -- LspDiagnosticsFloatingInformation { }, -- Used to color "Information" diagnostic messages in diagnostics float + -- LspDiagnosticsFloatingHint { }, -- Used to color "Hint" diagnostic messages in diagnostics float + + -- LspDiagnosticsSignError { }, -- Used for "Error" signs in sign column + -- LspDiagnosticsSignWarning { }, -- Used for "Warning" signs in sign column + -- LspDiagnosticsSignInformation { }, -- Used for "Information" signs in sign column + -- LspDiagnosticsSignHint { }, -- Used for "Hint" signs in sign column + } + end) + ) + end + -- stylua: ignore end + return lush.merge(specs) end diff --git a/lua/zenbones/template/lightline.lua b/lua/zenbones/template/lightline.lua index a1085b2..045ea4b 100644 --- a/lua/zenbones/template/lightline.lua +++ b/lua/zenbones/template/lightline.lua @@ -46,8 +46,8 @@ return function(name, specs, p) tabsel_fg = specs.Normal.fg.hex, warning_bg = specs.DiagnosticVirtualTextWarn.bg.hex, warning_fg = specs.DiagnosticVirtualTextWarn.fg.hex, - error_bg = specs.LspDiagnosticsVirtualTextError.bg.hex, - error_fg = specs.LspDiagnosticsVirtualTextError.fg.hex, + error_bg = specs.DiagnosticVirtualTextError.bg.hex, + error_fg = specs.DiagnosticVirtualTextError.fg.hex, }, } end