Skip to content

Commit 8eecbe1

Browse files
committed
small fixes and restructure
1 parent cfa5589 commit 8eecbe1

File tree

5 files changed

+115
-96
lines changed

5 files changed

+115
-96
lines changed

lua/neomodern/highlights/common.lua

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ local c = require("neomodern.colors")
22
local config = vim.g.neomodern_config
33
local util = require("neomodern.util")
44

5+
c.darkgutter = util.darken(c.bg, 0.85, "#000000")
6+
57
local M = {
68
ColorColumn = { bg = c.line },
79
Conceal = { fg = c.func, bg = config.transparent and c.none or c.bg },
@@ -15,7 +17,10 @@ local M = {
1517
CursorLine = { bg = c.line },
1618
CursorLineNr = {
1719
fg = config.alt_culnr_hl and c.alt or c.fg,
18-
bg = config.cursorline_gutter and c.line or c.none,
20+
bg = (
21+
(config.cursorline_gutter and c.line or nil)
22+
or (config.dark_gutter and c.darkgutter or nil)
23+
) or c.bg,
1924
},
2025
CursorLineSign = { bg = config.cursorline_gutter and c.line or c.none },
2126
CursorLineFold = { fg = c.fg, bg = config.cursorline_gutter and c.line or c.none },
@@ -32,9 +37,18 @@ local M = {
3237
FloatBorder = { fg = c.comment, bg = config.plain_float and c.none or c.float },
3338
FloatTitle = { fg = c.comment, bg = config.plain_float and c.none or c.float },
3439
Folded = { fg = c.comment, bg = config.transparent and c.none or c.line },
35-
FoldColumn = { fg = c.comment, bg = config.transparent and c.none or c.bg },
40+
FoldColumn = {
41+
fg = c.comment,
42+
bg = (
43+
(config.transparent and c.none or nil)
44+
or (config.dark_gutter and c.darkgutter or nil)
45+
) or c.bg,
46+
},
3647
IncSearch = { fg = c.type, bg = c.visual },
37-
LineNr = { fg = c.comment },
48+
LineNr = {
49+
fg = c.comment,
50+
bg = config.dark_gutter and c.darkgutter or c.bg,
51+
},
3852
MatchParen = { fg = c.fg, bg = c.visual, fmt = "bold" },
3953
ModeMsg = { fg = c.fg, fmt = "bold" },
4054
MoreMsg = { fg = c.func, fmt = "bold" },
@@ -52,7 +66,13 @@ local M = {
5266
Question = { fg = c.constant },
5367
QuickFixLine = { fg = c.func, fmt = "underline" },
5468
Search = { fg = c.diag_blue, bg = c.visual },
55-
SignColumn = { fg = c.fg, bg = config.transparent and c.none or c.bg },
69+
SignColumn = {
70+
fg = c.fg,
71+
bg = (
72+
(config.transparent and c.none or nil)
73+
or (config.dark_gutter and c.darkgutter or nil)
74+
) or c.bg,
75+
},
5676
SpecialKey = { fg = c.comment },
5777
SpellBad = { fg = c.none, fmt = "undercurl", sp = c.diag_red },
5878
SpellCap = { fg = c.none, fmt = "undercurl", sp = c.diag_yellow },

lua/neomodern/highlights.lua renamed to lua/neomodern/highlights/init.lua

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ local c = require("neomodern.colors")
22
local config = vim.g.neomodern_config
33
local M = {}
44

5+
local COMMON = require("neomodern.highlights.common")
6+
local SYNTAX = require("neomodern.highlights.syntax")
7+
local PLUGIN = require("neomodern.highlights.plugin")
8+
59
local function vim_highlights(highlights)
610
if highlights == nil then
711
return
@@ -21,14 +25,10 @@ local function vim_highlights(highlights)
2125
end
2226

2327
function M.setup()
24-
local COMMON = require("neomodern.highlights.common")
25-
local SYNTAX = require("neomodern.highlights.syntax")
26-
local PLUGIN = require("neomodern.highlights.plugin")
27-
2828
vim_highlights(COMMON)
29-
vim_highlights(SYNTAX.vim)
30-
vim_highlights(SYNTAX.treesitter)
31-
vim_highlights(SYNTAX.lsp)
29+
for _, group in pairs(SYNTAX) do
30+
vim_highlights(group)
31+
end
3232
for _, group in pairs(PLUGIN) do
3333
vim_highlights(group)
3434
end

lua/neomodern/highlights/plugin.lua

Lines changed: 1 addition & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -2,88 +2,8 @@ local c = require("neomodern.colors")
22
local config = vim.g.neomodern_config
33
local util = require("neomodern.util")
44

5-
local diagnostics_error_color = c.diag_red
6-
local diagnostics_hint_color = c.diag_blue
7-
local diagnostics_warn_color = c.diag_yellow
8-
local diagnostics_info_color = c.diag_blue
9-
105
local M = {}
116

12-
M.lsp = {
13-
DiagnosticError = { fg = c.diag_red },
14-
DiagnosticHint = { fg = c.diag_blue },
15-
DiagnosticInfo = { fg = c.diag_blue, fmt = "italic" },
16-
DiagnosticWarn = { fg = c.diag_yellow },
17-
18-
DiagnosticVirtualTextError = {
19-
bg = config.diagnostics.background
20-
and util.darken(diagnostics_error_color, 0.1, c.bg)
21-
or c.none,
22-
fg = diagnostics_error_color,
23-
},
24-
DiagnosticVirtualTextWarn = {
25-
bg = config.diagnostics.background
26-
and util.darken(diagnostics_warn_color, 0.1, c.bg)
27-
or c.none,
28-
fg = diagnostics_warn_color,
29-
},
30-
DiagnosticVirtualTextInfo = {
31-
bg = config.diagnostics.background
32-
and util.darken(diagnostics_info_color, 0.1, c.bg)
33-
or c.none,
34-
fg = diagnostics_info_color,
35-
},
36-
DiagnosticVirtualTextHint = {
37-
bg = config.diagnostics.background
38-
and util.darken(diagnostics_hint_color, 0.1, c.bg)
39-
or c.none,
40-
fg = diagnostics_hint_color,
41-
},
42-
43-
DiagnosticUnderlineError = {
44-
fmt = config.diagnostics.undercurl and "undercurl" or "underline",
45-
sp = c.diag_red,
46-
},
47-
DiagnosticUnderlineHint = {
48-
fmt = config.diagnostics.undercurl and "undercurl" or "underline",
49-
sp = c.diag_blue,
50-
},
51-
DiagnosticUnderlineInfo = {
52-
fmt = config.diagnostics.undercurl and "undercurl" or "underline",
53-
sp = c.diag_blue,
54-
},
55-
DiagnosticUnderlineWarn = {
56-
fmt = config.diagnostics.undercurl and "undercurl" or "underline",
57-
sp = c.diag_yellow,
58-
},
59-
60-
LspReferenceText = { bg = c.visual },
61-
LspReferenceWrite = { bg = c.visual },
62-
LspReferenceRead = { bg = c.visual },
63-
64-
LspCodeLens = {
65-
fg = c.keyword,
66-
bg = util.darken(c.keyword, 0.1, c.bg),
67-
fmt = config.code_style.comments,
68-
},
69-
LspCodeLensSeparator = { fg = c.comment },
70-
}
71-
72-
-- stylua: ignore start
73-
M.lsp.LspDiagnosticsDefaultError = M.lsp.DiagnosticError
74-
M.lsp.LspDiagnosticsDefaultHint = M.lsp.DiagnosticHint
75-
M.lsp.LspDiagnosticsDefaultInformation = M.lsp.DiagnosticInfo
76-
M.lsp.LspDiagnosticsDefaultWarning = M.lsp.DiagnosticWarn
77-
M.lsp.LspDiagnosticsUnderlineError = M.lsp.DiagnosticUnderlineError
78-
M.lsp.LspDiagnosticsUnderlineHint = M.lsp.DiagnosticUnderlineHint
79-
M.lsp.LspDiagnosticsUnderlineInformation = M.lsp.DiagnosticUnderlineInfo
80-
M.lsp.LspDiagnosticsUnderlineWarning = M.lsp.DiagnosticUnderlineWarn
81-
M.lsp.LspDiagnosticsVirtualTextError = M.lsp.DiagnosticVirtualTextError
82-
M.lsp.LspDiagnosticsVirtualTextWarning = M.lsp.DiagnosticVirtualTextWarn
83-
M.lsp.LspDiagnosticsVirtualTextInformation = M.lsp.DiagnosticVirtualTextInfo
84-
M.lsp.LspDiagnosticsVirtualTextHint = M.lsp.DiagnosticVirtualTextHint
85-
-- stylua: ignore end
86-
877
M.special = {
888
LazyNormal = { bg = c.float },
899
MasonNormal = { bg = c.float },
@@ -338,7 +258,7 @@ local lsp_kind_icons_color = {
338258
Variable = c.fg,
339259
}
340260

341-
if not config.plugin.plain then
261+
if not config.plugin.cmp.plain then
342262
for kind, color in pairs(lsp_kind_icons_color) do
343263
M.cmp["CmpItemKind" .. kind] =
344264
{ fg = color, fmt = config.plugin.cmp.reverse and "reverse" }

lua/neomodern/highlights/syntax.lua

Lines changed: 81 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ M.vim = {
2424
PreProc = { fg = c.string }, -- (preferred) generic preprocessor
2525
-- Define = { fg = c.comment }, -- preprocessor '#define'
2626
Include = { fg = c.constant, fmt = config.code_style.keywords }, -- preprocessor '#include'
27-
Macro = { fg = c.number, fmt = config.code_style.constants }, -- macros
27+
Macro = { fg = c.number, fmt = "italic" }, -- macros
2828
-- PreCondit = { fg = c.comment }, -- preprocessor conditionals '#if', '#endif' etc
2929
Special = { fg = c.type }, -- (preferred) any special symbol
3030
SpecialChar = { fg = c.keyword }, -- special character in a constant
@@ -82,8 +82,8 @@ if vim.version()["minor"] > 0.8 then
8282
-- ["@property"] = { fg = c.property }, --same as TSField
8383

8484
-- functions
85-
-- ["@function"] = { link = "Function" }, -- functions
86-
-- ["@function.builtin"] = M.syntax["Function"], --builtin functions
85+
["@function"] = M.vim["Function"], -- functions
86+
["@function.builtin"] = M.vim["Function"], --builtin functions
8787
-- ["@function.macro"] = { link = "Macro" }, -- macro defined functions
8888
-- ["@function.call"]
8989
-- ["@function.method"]
@@ -157,5 +157,82 @@ if vim.version()["minor"] > 0.8 then
157157
end
158158
end
159159

160-
return M
160+
local virtual_error = {
161+
bg = config.diagnostics.background and util.darken(c.diag_red, 0.1, c.bg) or c.none,
162+
fg = c.diag_red,
163+
}
164+
165+
local virtual_warn = {
166+
bg = config.diagnostics.background and util.darken(c.diag_yellow, 0.1, c.bg)
167+
or c.none,
168+
fg = c.diag_yellow,
169+
}
170+
171+
local virtual_info = {
172+
bg = config.diagnostics.background and util.darken(c.diag_blue, 0.1, c.bg)
173+
or c.none,
174+
fg = c.diag_blue,
175+
}
161176

177+
local virtual_hint = {
178+
bg = config.diagnostics.background and util.darken(c.diag_blue, 0.1, c.bg)
179+
or c.none,
180+
fg = c.diag_blue,
181+
}
182+
183+
M.diag = {
184+
DiagnosticError = { fg = c.diag_red },
185+
DiagnosticHint = { fg = c.diag_blue },
186+
DiagnosticInfo = { fg = c.diag_blue, fmt = "italic" },
187+
DiagnosticWarn = { fg = c.diag_yellow },
188+
189+
DiagnosticVirtualTextError = virtual_error,
190+
DiagnosticVirtualTextWarn = virtual_warn,
191+
DiagnosticVirtualTextInfo = virtual_info,
192+
DiagnosticVirtualTextHint = virtual_hint,
193+
194+
DiagnosticUnderlineError = {
195+
fmt = config.diagnostics.undercurl and "undercurl" or "underline",
196+
sp = c.diag_red,
197+
},
198+
DiagnosticUnderlineHint = {
199+
fmt = config.diagnostics.undercurl and "undercurl" or "underline",
200+
sp = c.diag_blue,
201+
},
202+
DiagnosticUnderlineInfo = {
203+
fmt = config.diagnostics.undercurl and "undercurl" or "underline",
204+
sp = c.diag_blue,
205+
},
206+
DiagnosticUnderlineWarn = {
207+
fmt = config.diagnostics.undercurl and "undercurl" or "underline",
208+
sp = c.diag_yellow,
209+
},
210+
211+
LspReferenceText = { bg = c.visual },
212+
LspReferenceWrite = { bg = c.visual },
213+
LspReferenceRead = { bg = c.visual },
214+
215+
LspCodeLens = {
216+
fg = c.keyword,
217+
bg = util.darken(c.keyword, 0.1, c.bg),
218+
fmt = config.code_style.comments,
219+
},
220+
LspCodeLensSeparator = { fg = c.comment },
221+
}
222+
223+
-- stylua: ignore start
224+
M.diag.LspDiagnosticsDefaultError = M.diag.DiagnosticError
225+
M.diag.LspDiagnosticsDefaultHint = M.diag.DiagnosticHint
226+
M.diag.LspDiagnosticsDefaultInformation = M.diag.DiagnosticInfo
227+
M.diag.LspDiagnosticsDefaultWarning = M.diag.DiagnosticWarn
228+
M.diag.LspDiagnosticsUnderlineError = M.diag.DiagnosticUnderlineError
229+
M.diag.LspDiagnosticsUnderlineHint = M.diag.DiagnosticUnderlineHint
230+
M.diag.LspDiagnosticsUnderlineInformation = M.diag.DiagnosticUnderlineInfo
231+
M.diag.LspDiagnosticsUnderlineWarning = M.diag.DiagnosticUnderlineWarn
232+
M.diag.LspDiagnosticsVirtualTextError = M.diag.DiagnosticVirtualTextError
233+
M.diag.LspDiagnosticsVirtualTextWarning = M.diag.DiagnosticVirtualTextWarn
234+
M.diag.LspDiagnosticsVirtualTextInformation = M.diag.DiagnosticVirtualTextInfo
235+
M.diag.LspDiagnosticsVirtualTextHint = M.diag.DiagnosticVirtualTextHint
236+
-- stylua: ignore end
237+
238+
return M

lua/neomodern/init.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ end
7474
---@field plain_float? boolean If true, does not set background of floating windows. Recommend for when using floating windows with borders
7575
---@field show_eob? boolean If true, highlights end-of-buffer tildes like comments
7676
---@field cursorline_gutter? boolean If true, highlights {sign, fold}column the same as cursorline
77+
---@field dark_gutter? boolean If true, highlights the gutter darker than the bg
7778
---@field alt_culnr_hl? boolean If true, highlights current line number as an alternate color
7879
---@field favor_treesitter_hl? boolean if true favor treesitter highlights over semantic highlights
7980
---@field diagnostics? table Has boolean fields to determine diagnostics appearance: 'darker', 'undercurl', 'background'
@@ -93,6 +94,7 @@ local default_config = {
9394
plain_float = false,
9495
show_eob = true,
9596
cursorline_gutter = true,
97+
dark_gutter = false,
9698
alt_culnr_hl = true,
9799
favor_treesitter_hl = false,
98100

0 commit comments

Comments
 (0)