From c389ad25069c8f2d89ff034b4cbbc7b20ef5bddd Mon Sep 17 00:00:00 2001 From: Max Miliano Date: Thu, 21 Dec 2023 20:22:41 -0300 Subject: [PATCH] feat: extras highlight token --- README.md | 6 +- doc/solarized.nvim.txt | 6 +- lua/solarized/autocmd.lua | 36 ++++++++++++ lua/solarized/command.lua | 8 +-- lua/solarized/config/init.lua | 15 ++--- lua/solarized/highlights.lua | 7 ++- lua/solarized/themes/default/custom.lua | 11 ++++ lua/solarized/themes/default/diagnostic.lua | 30 ++++++++-- lua/solarized/themes/default/editor.lua | 56 +++++++++++++++---- lua/solarized/themes/default/gitsign.lua | 18 +++++- .../themes/default/indentblankline.lua | 5 +- lua/solarized/themes/default/lspsaga.lua | 6 +- lua/solarized/themes/default/neogit.lua | 15 ++++- lua/solarized/themes/default/semantic.lua | 6 +- lua/solarized/themes/default/syntax.lua | 12 +++- lua/solarized/themes/default/telescope.lua | 6 +- lua/solarized/themes/default/todo.lua | 10 +++- lua/solarized/themes/default/tree.lua | 12 +++- lua/solarized/themes/default/treesitter.lua | 6 +- lua/solarized/themes/neo/custom.lua | 11 ++++ lua/solarized/themes/neo/editor.lua | 42 +++++++++++--- lua/solarized/themes/neo/indentblankline.lua | 10 +++- lua/solarized/themes/neo/lspsaga.lua | 6 +- lua/solarized/themes/neo/neogit.lua | 15 ++++- lua/solarized/themes/neo/semantic.lua | 6 +- lua/solarized/themes/neo/syntax.lua | 6 +- lua/solarized/themes/neo/telescope.lua | 6 +- lua/solarized/themes/neo/todo.lua | 10 +++- lua/solarized/themes/neo/tree.lua | 12 +++- lua/solarized/themes/neo/treesitter.lua | 6 +- lua/solarized/utils/colors.lua | 6 +- lua/solarized/utils/init.lua | 19 ++----- plugin/solarized.lua | 5 +- 33 files changed, 349 insertions(+), 82 deletions(-) create mode 100644 lua/solarized/autocmd.lua create mode 100644 lua/solarized/themes/default/custom.lua create mode 100644 lua/solarized/themes/neo/custom.lua diff --git a/README.md b/README.md index b6423a0..97a287c 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,7 @@ require('solarized').setup({ enables = { bufferline = true, cmp = true, + custom = true, -- solarized's custom highlights diagnostic = true, dashboard = true, editor = true, @@ -124,7 +125,10 @@ require('solarized').setup({ }, highlights = {}, colors = {}, - theme = 'default', -- or 'neosolarized' or 'neo' for short + theme = 'default', -- or 'neo' + extras = { + highlight_token = false, + }, }) vim.cmd.colorscheme = 'solarized' diff --git a/doc/solarized.nvim.txt b/doc/solarized.nvim.txt index c76fb24..9a20fbc 100644 --- a/doc/solarized.nvim.txt +++ b/doc/solarized.nvim.txt @@ -121,6 +121,7 @@ DEFAULT CONFIG *solarized.nvim-default-config* enables = { bufferline = true, cmp = true, + custom = true, -- solarized's custom highlights diagnostic = true, dashboard = true, editor = true, @@ -144,7 +145,10 @@ DEFAULT CONFIG *solarized.nvim-default-config* }, highlights = {}, colors = {}, - theme = 'default', -- or 'neosolarized' or 'neo' for short + theme = 'default', -- or 'neo' + extras = { + highlight_token = false, + }, }) vim.cmd.colorscheme = 'solarized' diff --git a/lua/solarized/autocmd.lua b/lua/solarized/autocmd.lua new file mode 100644 index 0000000..3536efd --- /dev/null +++ b/lua/solarized/autocmd.lua @@ -0,0 +1,36 @@ +vim.api.nvim_create_autocmd('LspTokenUpdate', { + callback = function(args) + local token = args.data.token + local buffer = args.buf + local text = vim.api.nvim_buf_get_text( + buffer, + token.line, + token.start_col, + token.line, + token.end_col, + {} + )[1] + + local highlights = { + 'TODO', + 'WARN', + 'TEST', + 'PERF', + 'NOTE', + 'HACK', + 'FIX', + } + local name = 'SolarizedTodo' + + for _, group_name in pairs(highlights) do + if text ~= nil and token.type == 'comment' and text:match(group_name) then + vim.lsp.semantic_tokens.highlight_token( + token, + buffer, + args.data.client_id, + name .. group_name + ) + end + end + end, +}) diff --git a/lua/solarized/command.lua b/lua/solarized/command.lua index df5dd95..aca698a 100644 --- a/lua/solarized/command.lua +++ b/lua/solarized/command.lua @@ -22,16 +22,16 @@ local subcommands = { } local desc = colors_desc[color] - if not desc then - return '' - end + if not desc then return '' end return desc end local function set_lines(color, hex, line) vim.api.nvim_buf_set_lines(buf, line, (line + 1), false, { - color .. string.rep('.', max_length - #color) .. ' = "' .. tostring(hex) .. '" ' .. color_desc(color), + color .. string.rep('.', max_length - #color) .. ' = "' .. tostring( + hex + ) .. '" ' .. color_desc(color), }) return line + 1 end diff --git a/lua/solarized/config/init.lua b/lua/solarized/config/init.lua index 6e8dffe..2d57040 100644 --- a/lua/solarized/config/init.lua +++ b/lua/solarized/config/init.lua @@ -26,6 +26,7 @@ function M.default_config() enables = { bufferline = true, cmp = true, + custom = true, diagnostic = true, dashboard = true, editor = true, @@ -50,17 +51,16 @@ function M.default_config() highlights = {}, colors = {}, theme = 'default', + extras = { + highlight_token = false, + }, } end function M.load() - if vim.g.colors_name then - vim.cmd('hi clear') - end + if vim.g.colors_name then vim.cmd('hi clear') end - if vim.fn.exists('syntax_on') then - vim.cmd('syntax reset') - end + if vim.fn.exists('syntax_on') then vim.cmd('syntax reset') end vim.o.termguicolors = true vim.g.colors_name = 'solarized' @@ -94,7 +94,8 @@ function M.setup(opts) M.colors = palette.extend_colors(colors, M.config.colors) end, fnc = function() - M.colors = palette.extend_colors(colors, M.config.colors(colors, colorhelper)) + M.colors = + palette.extend_colors(colors, M.config.colors(colors, colorhelper)) end, }, M.config.colors) end diff --git a/lua/solarized/highlights.lua b/lua/solarized/highlights.lua index d42c88c..9dcbac5 100644 --- a/lua/solarized/highlights.lua +++ b/lua/solarized/highlights.lua @@ -25,7 +25,8 @@ end function M.load_plugins(colors, config) for plugin, enabled in pairs(config.enables) do if enabled then - local highlight_groups = require(string.format('solarized.themes.%s.%s', config.theme, plugin)) + local highlight_groups = + require(string.format('solarized.themes.%s.%s', config.theme, plugin)) highlight_groups(colors, config) end @@ -44,6 +45,10 @@ function M.highlights(colors, config) M.load_plugins(colors, config) end + if vim.fn.has('nvim-0.9.4') and config.extras.highlight_token then + require('solarized.autocmd') + end + utils.on_config({ tbl = function() M.custom_hl(config.highlights) diff --git a/lua/solarized/themes/default/custom.lua b/lua/solarized/themes/default/custom.lua new file mode 100644 index 0000000..9fa36ee --- /dev/null +++ b/lua/solarized/themes/default/custom.lua @@ -0,0 +1,11 @@ +return function(c) + local set_hl = require('solarized.utils').set_hl + + set_hl('SolarizedTodoTODO', { fg = c.info }) + set_hl('SolarizedTodoWARN', { fg = c.warning }) + set_hl('SolarizedTodoTEST', { fg = c.violet }) + set_hl('SolarizedTodoPERF', { fg = c.magenta }) + set_hl('SolarizedTodoNOTE', { fg = c.hint }) + set_hl('SolarizedTodoHACK', { fg = c.cyan }) + set_hl('SolarizedTodoFIX', { fg = c.error }) +end diff --git a/lua/solarized/themes/default/diagnostic.lua b/lua/solarized/themes/default/diagnostic.lua index 5e1ee98..8edbf6e 100644 --- a/lua/solarized/themes/default/diagnostic.lua +++ b/lua/solarized/themes/default/diagnostic.lua @@ -22,11 +22,31 @@ return function(c, config) -- set_hl('DiagnosticFloatingInfo') -- Used to color "Info" diagnostic messages in diagnostics float. -- set_hl('DiagnosticFloatingHint') -- Used to color "Hint" diagnostic messages in diagnostics float. -- set_hl('DiagnosticFloatingOk') -- Used to color "Ok" diagnostic messages in diagnostics float. - set_hl('DiagnosticSignError', { fg = c.error, bg = c.base02 }, { transparent = config.transparent }) -- Used for "Error" signs in sign column. - set_hl('DiagnosticSignWarn', { fg = c.warning, bg = c.base02 }, { transparent = config.transparent }) -- Used for "Warn" signs in sign column. - set_hl('DiagnosticSignInfo', { fg = c.info, bg = c.base02 }, { transparent = config.transparent }) -- Used for "Info" signs in sign column. - set_hl('DiagnosticSignHint', { fg = c.hint, bg = c.base02 }, { transparent = config.transparent }) -- Used for "Hint" signs in sign column. - set_hl('DiagnosticSignOk', { fg = c.cyan, bg = c.base02 }, { transparent = config.transparent }) -- Used for "Ok" signs in sign column. + set_hl( + 'DiagnosticSignError', + { fg = c.error, bg = c.base02 }, + { transparent = config.transparent } + ) -- Used for "Error" signs in sign column. + set_hl( + 'DiagnosticSignWarn', + { fg = c.warning, bg = c.base02 }, + { transparent = config.transparent } + ) -- Used for "Warn" signs in sign column. + set_hl( + 'DiagnosticSignInfo', + { fg = c.info, bg = c.base02 }, + { transparent = config.transparent } + ) -- Used for "Info" signs in sign column. + set_hl( + 'DiagnosticSignHint', + { fg = c.hint, bg = c.base02 }, + { transparent = config.transparent } + ) -- Used for "Hint" signs in sign column. + set_hl( + 'DiagnosticSignOk', + { fg = c.cyan, bg = c.base02 }, + { transparent = config.transparent } + ) -- Used for "Ok" signs in sign column. -- set_hl('DiagnosticDeprecated') -- Used for deprecated or obsolete code. -- set_hl('DiagnosticUnnecessary') -- Used for unnecessary or unused code. end diff --git a/lua/solarized/themes/default/editor.lua b/lua/solarized/themes/default/editor.lua index 310c647..0d64bda 100644 --- a/lua/solarized/themes/default/editor.lua +++ b/lua/solarized/themes/default/editor.lua @@ -19,16 +19,35 @@ return function(c, config) set_hl('TermCursor', { link = 'Cursor' }) -- Cursor in a focused terminal set_hl('TermCursorNC', { fg = c.base03, bg = c.base0 }) -- Cursor in an unfocused terminal set_hl('ErrorMsg', { fg = c.error, reverse = true }) -- Error messages on the command line - set_hl('WinSeparator', { fg = c.base00, bg = c.base02 }, { transparent = config.transparent }) -- Separators between window splits - set_hl('Folded', { fg = c.base0, bg = c.base02, underline = true, bold = true }) -- Line used for closed folds + set_hl( + 'WinSeparator', + { fg = c.base00, bg = c.base02 }, + { transparent = config.transparent } + ) -- Separators between window splits + set_hl( + 'Folded', + { fg = c.base0, bg = c.base02, underline = true, bold = true } + ) -- Line used for closed folds set_hl('FoldColumn', { fg = c.base0, bg = c.base02, bold = true }) -- 'foldcolumn' - set_hl('SignColumn', { fg = c.base0, bg = c.base02 }, { transparent = config.transparent }) -- Column were signs are displayed + set_hl( + 'SignColumn', + { fg = c.base0, bg = c.base02 }, + { transparent = config.transparent } + ) -- Column were signs are displayed set_hl('IncSearch', { fg = c.orange, standout = true }) -- 'incsearch' highlighting, also for the text replaced set_hl('Substitute', { link = 'IncSearch' }) -- :substitute replacement text highlight - set_hl('LineNr', { fg = c.base01, bg = c.base02 }, { transparent = config.transparent }) -- Line number for ":number" and ":#" commands + set_hl( + 'LineNr', + { fg = c.base01, bg = c.base02 }, + { transparent = config.transparent } + ) -- Line number for ":number" and ":#" commands set_hl('LineNrAbove', { link = 'LineNr' }) -- Line number, above the cursor line set_hl('LineNrBelow', { link = 'LineNr' }) -- Line number, below the cursor - set_hl('CursorLineNr', { fg = c.base1, bg = c.base02, bold = true }, { transparent = config.transparent }) -- Like LineNr when 'cursorline' is set + set_hl( + 'CursorLineNr', + { fg = c.base1, bg = c.base02, bold = true }, + { transparent = config.transparent } + ) -- Like LineNr when 'cursorline' is set set_hl('CursorLineFold', { link = 'FoldColumn' }) -- Like FoldColumn when 'cursorline' is set set_hl('CursorLineSign', { link = 'SignColumn' }) -- Like SignColumn when 'cursorline' is set set_hl('MatchParen', { fg = c.red, bg = c.base01, bold = true }) -- Character under the cursor or just before it @@ -37,12 +56,20 @@ return function(c, config) set_hl('MsgSeparator', { link = 'Normal' }) -- Separator for scrolled messages msgsep. set_hl('MoreMsg', { fg = c.blue }) -- more-prompt set_hl('NonText', { fg = c.base1, bold = true }) -- '@' at the end of the window - set_hl('Normal', { fg = c.base0, bg = c.base03 }, { transparent = config.transparent }) -- Normal text + set_hl( + 'Normal', + { fg = c.base0, bg = c.base03 }, + { transparent = config.transparent } + ) -- Normal text set_hl('NormalFloat', { fg = c.base0, bg = c.base02 }) -- Normal text in floating windows set_hl('FloatBorder', { link = 'WinSeparator', bold = true }) -- Border of floating windows. set_hl('FloatTitle', { fg = c.orange }) -- Title of float windows. set_hl('NormalNC', { link = 'Normal' }) -- Normal text in non-current windows. - set_hl('Pmenu', { fg = c.base0, bg = c.base02 }, { transparent = config.transparent }) -- Popup menu: Normal item + set_hl( + 'Pmenu', + { fg = c.base0, bg = c.base02 }, + { transparent = config.transparent } + ) -- Popup menu: Normal item set_hl('PmenuSel', { fg = c.base2, bg = c.base01 }) -- Popup menu: Selected item set_hl('PmenuKind', { link = 'Pmenu' }) -- Popup menu: Normal item kind set_hl('PmenuKindSel', { link = 'PmenuSel' }) -- Popup menu: Selected item kind @@ -60,9 +87,18 @@ return function(c, config) set_hl('SpellRare', { sp = c.cyan, undercurl = true }) -- Word that is recognized by the spellchecker as one that is hardly ever used. set_hl('StatusLine', { fg = c.base02, bg = c.base1 }) -- Status line of current window. set_hl('StatusLineNC', { fg = c.base02, bg = c.base00 }) -- Status lines of not-current windows. - set_hl('TabLine', { fg = c.base0, bg = c.base02, sp = c.base0, underline = true }) -- Tab pages line, not active tab page label. - set_hl('TabLineFill', { fg = c.base0, bg = c.base02, sp = c.base0, underline = true }) -- Tab pages line, where there are no labels. - set_hl('TabLineSel', { fg = c.base2, bg = c.base01, sp = c.base0, underline = true }) -- Tab pages line, active tab page label. + set_hl( + 'TabLine', + { fg = c.base0, bg = c.base02, sp = c.base0, underline = true } + ) -- Tab pages line, not active tab page label. + set_hl( + 'TabLineFill', + { fg = c.base0, bg = c.base02, sp = c.base0, underline = true } + ) -- Tab pages line, where there are no labels. + set_hl( + 'TabLineSel', + { fg = c.base2, bg = c.base01, sp = c.base0, underline = true } + ) -- Tab pages line, active tab page label. set_hl('Title', { fg = c.orange, bold = true }) -- Titles for output from ":set all", ":autocmd" etc. set_hl('Visual', { bg = c.base02, standout = true }) -- Visual mode selection. set_hl('VisualNOS', { link = 'Visual' }) -- Visual mode selection when vim is "Not Owning the Selection". diff --git a/lua/solarized/themes/default/gitsign.lua b/lua/solarized/themes/default/gitsign.lua index d4d7041..879fc71 100644 --- a/lua/solarized/themes/default/gitsign.lua +++ b/lua/solarized/themes/default/gitsign.lua @@ -2,7 +2,19 @@ return function(c, config) local utils = require('solarized.utils') local set_hl = utils.set_hl - set_hl('GitSignsAdd', { fg = c.add, bg = c.base02 }, { transparent = config.transparent }) -- Used for the text of 'add' signs - set_hl('GitSignsChange', { fg = c.change, bg = c.base02 }, { transparent = config.transparent }) -- Used for the text of 'change' signs - set_hl('GitSignsDelete', { fg = c.delete, bg = c.base02 }, { transparent = config.transparent }) -- Used for the text of 'delete' signs + set_hl( + 'GitSignsAdd', + { fg = c.add, bg = c.base02 }, + { transparent = config.transparent } + ) -- Used for the text of 'add' signs + set_hl( + 'GitSignsChange', + { fg = c.change, bg = c.base02 }, + { transparent = config.transparent } + ) -- Used for the text of 'change' signs + set_hl( + 'GitSignsDelete', + { fg = c.delete, bg = c.base02 }, + { transparent = config.transparent } + ) -- Used for the text of 'delete' signs end diff --git a/lua/solarized/themes/default/indentblankline.lua b/lua/solarized/themes/default/indentblankline.lua index fa97ec3..814a4af 100644 --- a/lua/solarized/themes/default/indentblankline.lua +++ b/lua/solarized/themes/default/indentblankline.lua @@ -5,7 +5,10 @@ return function(c) set_hl('IndentBlanklineChar', { fg = c.base01 }) -- Highlight of indent character. Default: Whitespace set_hl('IndentBlanklineSpaceChar', { link = 'IndentBlanklineChar' }) -- Highlight of space character. Default: Whitespace set_hl('IndentBlanklineContextChar', { fg = c.base0 }) -- Highlight of indent character when base of current context. Default: Label - set_hl('IndentBlanklineContextSpaceChar', { link = 'IndentBlanklineContextChar' }) -- Highlight of space characters one indent level of the current context. Default: Label + set_hl( + 'IndentBlanklineContextSpaceChar', + { link = 'IndentBlanklineContextChar' } + ) -- Highlight of space characters one indent level of the current context. Default: Label set_hl('IblIndent', { fg = c.base0, nocombine = true }) set_hl('IblScope', { fg = c.base01, nocombine = true }) diff --git a/lua/solarized/themes/default/lspsaga.lua b/lua/solarized/themes/default/lspsaga.lua index 53449bf..227fb3a 100644 --- a/lua/solarized/themes/default/lspsaga.lua +++ b/lua/solarized/themes/default/lspsaga.lua @@ -4,7 +4,11 @@ return function(c, config) -- Float window set_hl('SagaNormal', { link = 'Pmenu' }) - set_hl('TitleString', { fg = c.orange, bold = true, bg = c.base02 }, { transparent = config.transparent }) + set_hl( + 'TitleString', + { fg = c.orange, bold = true, bg = c.base02 }, + { transparent = config.transparent } + ) -- Outline set_hl('OutlineIndent', { fg = c.green }) diff --git a/lua/solarized/themes/default/neogit.lua b/lua/solarized/themes/default/neogit.lua index 90b1112..fd368a9 100644 --- a/lua/solarized/themes/default/neogit.lua +++ b/lua/solarized/themes/default/neogit.lua @@ -7,12 +7,21 @@ return function(c) set_hl('NeogitCursorLine', { link = 'CursorLine' }) set_hl('NeogitBranch', { fg = c.magenta }) set_hl('NeogitRemote', { fg = c.violet }) - set_hl('NeogitHunkHeader', { fg = c.orange, bg = blend(c.orange, c.base03, alpha) }) + set_hl( + 'NeogitHunkHeader', + { fg = c.orange, bg = blend(c.orange, c.base03, alpha) } + ) set_hl('NeogitHunkHeaderHighlight', { link = 'Title' }) set_hl('NeogitDiffContextHighlight', { fg = c.base00, bg = c.base03 }) set_hl('NeogitDiffContext', { fg = c.base00, bg = c.base03 }) - set_hl('NeogitDiffDeleteHighlight', { fg = c.red, bg = blend(c.red, c.base03, alpha) }) + set_hl( + 'NeogitDiffDeleteHighlight', + { fg = c.red, bg = blend(c.red, c.base03, alpha) } + ) set_hl('NeogitDiffDelete', { fg = c.red }) - set_hl('NeogitDiffAddHighlight', { fg = c.green, bg = blend(c.green, c.base03, alpha) }) + set_hl( + 'NeogitDiffAddHighlight', + { fg = c.green, bg = blend(c.green, c.base03, alpha) } + ) set_hl('NeogitDiffAdd', { fg = c.green }) end diff --git a/lua/solarized/themes/default/semantic.lua b/lua/solarized/themes/default/semantic.lua index bee5853..321d3db 100644 --- a/lua/solarized/themes/default/semantic.lua +++ b/lua/solarized/themes/default/semantic.lua @@ -12,7 +12,11 @@ return function(c, config) set_hl('@lsp.type.macro', { link = 'Macro' }) -- Keyword set_hl('@lsp.type.method', { link = 'Function' }) -- Function set_hl('@lsp.type.namespace', { link = '@namespace' }) -- Namespace - set_hl('@lsp.type.parameter', { fg = c.base0, italic = true }, { styles = config.styles.parameters }) + set_hl( + '@lsp.type.parameter', + { fg = c.base0, italic = true }, + { styles = config.styles.parameters } + ) set_hl('@lsp.type.property', { link = '@field' }) -- Property set_hl('@lsp.type.struct', { link = 'Structure' }) -- Structure set_hl('@lsp.type.type', { link = 'Type' }) -- Type diff --git a/lua/solarized/themes/default/syntax.lua b/lua/solarized/themes/default/syntax.lua index 3c0a083..76af766 100644 --- a/lua/solarized/themes/default/syntax.lua +++ b/lua/solarized/themes/default/syntax.lua @@ -2,7 +2,11 @@ return function(c, config) local utils = require('solarized.utils') local set_hl = utils.set_hl - set_hl('Comment', { fg = c.base01, italic = true }, { styles = config.styles.comments }) -- any comment + set_hl( + 'Comment', + { fg = c.base01, italic = true }, + { styles = config.styles.comments } + ) -- any comment set_hl('Constant', { fg = c.cyan }, { styles = config.styles.constants }) -- any constant set_hl('String', { fg = c.cyan }) -- a string constant: "this is a string" set_hl('Character', { link = 'String' }) -- a character constant: 'c', '\n' @@ -16,7 +20,11 @@ return function(c, config) set_hl('Repeat', { link = 'Statement' }) -- for, do, while, etc. set_hl('Label', { link = 'Statement' }) -- case, default, etc. set_hl('Operator', { link = 'Statement' }) -- "sizeof", "+", "*", etc. - set_hl('Keyword', { fg = c.base1, bold = true }, { styles = config.styles.keywords }) -- any other keyword + set_hl( + 'Keyword', + { fg = c.base1, bold = true }, + { styles = config.styles.keywords } + ) -- any other keyword set_hl('Exception', { link = 'Statement' }) -- try, catch, throw set_hl('PreProc', { fg = c.orange }) -- generic Preprocessor set_hl('Include', { link = 'PreProc' }) -- preprocessor #include diff --git a/lua/solarized/themes/default/telescope.lua b/lua/solarized/themes/default/telescope.lua index ba05b16..3a0c407 100644 --- a/lua/solarized/themes/default/telescope.lua +++ b/lua/solarized/themes/default/telescope.lua @@ -8,7 +8,11 @@ return function(c, config) set_hl('TelescopeMultiIcon', { fg = c.cyan }) -- "Normal" in the floating windows created by telescope. - set_hl('TelescopeNormal', { fg = c.base0, bg = c.base02 }, { transparent = config.transparent }) + set_hl( + 'TelescopeNormal', + { fg = c.base0, bg = c.base02 }, + { transparent = config.transparent } + ) set_hl('TelescopePreviewNormal', { link = 'TelescopeNormal' }) set_hl('TelescopePromptNormal', { link = 'TelescopeNormal' }) set_hl('TelescopeResultsNormal', { link = 'TelescopeNormal' }) diff --git a/lua/solarized/themes/default/todo.lua b/lua/solarized/themes/default/todo.lua index 142ec62..75b0785 100644 --- a/lua/solarized/themes/default/todo.lua +++ b/lua/solarized/themes/default/todo.lua @@ -35,9 +35,15 @@ return function(c) set_hl('TodoSignFIX', { fg = c.error }) set_hl('TodoBgTODO', { fg = c.info, bg = colorFunc(c.info, percentage) }) - set_hl('TodoBgWARN', { fg = c.warning, bg = colorFunc(c.warning, percentage) }) + set_hl( + 'TodoBgWARN', + { fg = c.warning, bg = colorFunc(c.warning, percentage) } + ) set_hl('TodoBgTEST', { fg = c.violet, bg = colorFunc(c.violet, percentage) }) - set_hl('TodoBgPERF', { fg = c.magenta, bg = colorFunc(c.magenta, percentage) }) + set_hl( + 'TodoBgPERF', + { fg = c.magenta, bg = colorFunc(c.magenta, percentage) } + ) set_hl('TodoBgNOTE', { fg = c.hint, bg = colorFunc(c.hint, percentage) }) set_hl('TodoBgHACK', { fg = c.cyan, bg = colorFunc(c.cyan, percentage) }) set_hl('TodoBgFIX', { fg = c.error, bg = colorFunc(c.error, percentage) }) diff --git a/lua/solarized/themes/default/tree.lua b/lua/solarized/themes/default/tree.lua index e68eca0..7739dcf 100644 --- a/lua/solarized/themes/default/tree.lua +++ b/lua/solarized/themes/default/tree.lua @@ -31,13 +31,21 @@ return function(c, config) set_hl('NvimTreeGitDeleted', { fg = c.delete }) -- set_hl('NvimTreeGitIgnored') -- (Comment) -- set_hl('NvimTreeWindowPicker') - set_hl('NvimTreeNormal', { fg = c.base0, bg = c.base04 }, { transparent = config.transparent }) + set_hl( + 'NvimTreeNormal', + { fg = c.base0, bg = c.base04 }, + { transparent = config.transparent } + ) set_hl('NvimTreeNormalFloat', { link = 'NvimTreeNormal' }) set_hl('NvimTreeEndOfBuffer', { fg = c.base04 }) -- (NonText) -- set_hl('NvimTreeCursorLine') -- (CursorLine) -- set_hl('NvimTreeCursorLineNr') -- (CursorLineNr) -- set_hl('NvimTreeLineNr') -- (LineNr) - set_hl('NvimTreeWinSeparator', { fg = c.base04, bg = c.base04 }, { transparent = config.transparent }) -- (WinSeparator) + set_hl( + 'NvimTreeWinSeparator', + { fg = c.base04, bg = c.base04 }, + { transparent = config.transparent } + ) -- (WinSeparator) -- set_hl('NvimTreeCursorColumn') -- (CursorColumn) -- -- There are also links for file highlight with git properties, linked to their diff --git a/lua/solarized/themes/default/treesitter.lua b/lua/solarized/themes/default/treesitter.lua index 35729b6..a7b3572 100644 --- a/lua/solarized/themes/default/treesitter.lua +++ b/lua/solarized/themes/default/treesitter.lua @@ -36,7 +36,11 @@ return function(c, config) set_hl('@method.call', { link = 'Function' }) -- method calls set_hl('@constructor', { link = 'Function' }) -- constructor calls and definitions - set_hl('@parameter', { fg = c.base0, italic = true }, { styles = config.styles.parameters }) -- parameters of a function + set_hl( + '@parameter', + { fg = c.base0, italic = true }, + { styles = config.styles.parameters } + ) -- parameters of a function set_hl('@keyword', { link = 'Keyword' }) -- various keywords set_hl('@keyword.coroutine', { link = 'Statement' }) -- keywords related to coroutines (e.g. `go` in Go, `async/await` in Python) diff --git a/lua/solarized/themes/neo/custom.lua b/lua/solarized/themes/neo/custom.lua new file mode 100644 index 0000000..9fa36ee --- /dev/null +++ b/lua/solarized/themes/neo/custom.lua @@ -0,0 +1,11 @@ +return function(c) + local set_hl = require('solarized.utils').set_hl + + set_hl('SolarizedTodoTODO', { fg = c.info }) + set_hl('SolarizedTodoWARN', { fg = c.warning }) + set_hl('SolarizedTodoTEST', { fg = c.violet }) + set_hl('SolarizedTodoPERF', { fg = c.magenta }) + set_hl('SolarizedTodoNOTE', { fg = c.hint }) + set_hl('SolarizedTodoHACK', { fg = c.cyan }) + set_hl('SolarizedTodoFIX', { fg = c.error }) +end diff --git a/lua/solarized/themes/neo/editor.lua b/lua/solarized/themes/neo/editor.lua index 686eee5..1cb57bc 100644 --- a/lua/solarized/themes/neo/editor.lua +++ b/lua/solarized/themes/neo/editor.lua @@ -24,16 +24,36 @@ return function(c, config) set_hl('TermCursor', { link = 'Cursor' }) -- Cursor in a focused terminal set_hl('TermCursorNC', { fg = c.base03, bg = c.base0 }) -- Cursor in an unfocused terminal set_hl('ErrorMsg', { fg = c.error }) -- Error messages on the command line - set_hl('WinSeparator', { fg = c.cyan, bg = c.base04 }, { transparent = config.transparent }) -- Separators between window splits + set_hl( + 'WinSeparator', + { fg = c.cyan, bg = c.base04 }, + { transparent = config.transparent } + ) -- Separators between window splits set_hl('Folded', { fg = c.base0, bg = c.base02 }) -- Line used for closed folds set_hl('FoldColumn', { fg = c.base0, bg = c.base04 }) -- 'foldcolumn' - set_hl('SignColumn', { fg = c.base0, bg = c.base03 }, { transparent = config.transparent }) -- Column were signs are displayed - set_hl('IncSearch', { fg = c.base3, bg = c.base04, bold = true }, { transparent = config.transparent }) -- 'incsearch' highlighting, also for the text replaced + set_hl( + 'SignColumn', + { fg = c.base0, bg = c.base03 }, + { transparent = config.transparent } + ) -- Column were signs are displayed + set_hl( + 'IncSearch', + { fg = c.base3, bg = c.base04, bold = true }, + { transparent = config.transparent } + ) -- 'incsearch' highlighting, also for the text replaced set_hl('Substitute', { fg = c.orange, reverse = true }) -- :substitute replacement text highlight - set_hl('LineNr', { fg = c.base01, bg = c.base03 }, { transparent = config.transparent }) -- Line number for ":number" and ":#" commands + set_hl( + 'LineNr', + { fg = c.base01, bg = c.base03 }, + { transparent = config.transparent } + ) -- Line number for ":number" and ":#" commands set_hl('LineNrAbove', { link = 'LineNr' }) -- Line number, above the cursor line set_hl('LineNrBelow', { link = 'LineNr' }) -- Line number, below the cursor - set_hl('CursorLineNr', { fg = c.base2, bg = c.base03 }, { transparent = config.transparent }) -- Like LineNr when 'cursorline' is set + set_hl( + 'CursorLineNr', + { fg = c.base2, bg = c.base03 }, + { transparent = config.transparent } + ) -- Like LineNr when 'cursorline' is set set_hl('CursorLineFold', { link = 'FoldColumn' }) -- Like FoldColumn when 'cursorline' is set set_hl('CursorLineSign', { link = 'SignColumn' }) -- Like SignColumn when 'cursorline' is set set_hl('MatchParen', { fg = c.base2 }) -- Character under the cursor or just before it @@ -42,12 +62,20 @@ return function(c, config) set_hl('MsgSeparator', { link = 'Normal' }) -- Separator for scrolled messages msgsep. set_hl('MoreMsg', { fg = c.cyan }) -- more-prompt set_hl('NonText', { fg = c.base00 }) -- '@' at the end of the window - set_hl('Normal', { fg = c.base0, bg = c.base03 }, { transparent = config.transparent }) -- Normal text + set_hl( + 'Normal', + { fg = c.base0, bg = c.base03 }, + { transparent = config.transparent } + ) -- Normal text set_hl('NormalFloat', { fg = c.base0, bg = c.base04 }) -- Normal text in floating windows set_hl('FloatBorder', { link = 'WinSeparator' }) -- Border of floating windows. set_hl('FloatTitle', { fg = c.orange }) -- Title of float windows. set_hl('NormalNC', { link = 'Normal' }) -- Normal text in non-current windows. - set_hl('Pmenu', { fg = c.base0, bg = c.base04 }, { transparent = config.transparent }) -- Popup menu: Normal item + set_hl( + 'Pmenu', + { fg = c.base0, bg = c.base04 }, + { transparent = config.transparent } + ) -- Popup menu: Normal item set_hl('PmenuSel', { fg = c.base2 }) -- Popup menu: Selected item set_hl('PmenuKind', { link = 'Pmenu' }) -- Popup menu: Normal item kind set_hl('PmenuKindSel', { link = 'PmenuSel' }) -- Popup menu: Selected item kind diff --git a/lua/solarized/themes/neo/indentblankline.lua b/lua/solarized/themes/neo/indentblankline.lua index 81ed351..4f8c122 100644 --- a/lua/solarized/themes/neo/indentblankline.lua +++ b/lua/solarized/themes/neo/indentblankline.lua @@ -9,14 +9,20 @@ return function(c) set_hl('IndentBlanklineChar', { fg = darken(c.green, 20) }) -- Highlight of indent character. Default: Whitespace set_hl('IndentBlanklineSpaceChar', { link = 'IndentBlanklineChar' }) -- Highlight of space character. Default: Whitespace set_hl('IndentBlanklineContextChar', { fg = c.green }) -- Highlight of indent character when base of current context. Default: Label - set_hl('IndentBlanklineContextSpaceChar', { link = 'IndentBlanklineContextChar' }) -- Highlight of space characters one indent level of the current context. Default: Label + set_hl( + 'IndentBlanklineContextSpaceChar', + { link = 'IndentBlanklineContextChar' } + ) -- Highlight of space characters one indent level of the current context. Default: Label set_hl('IblIndent', { fg = darken(c.green, 20), nocombine = true }) set_hl('IblScope', { fg = c.green, nocombine = true }) else set_hl('IndentBlanklineChar', { fg = lighten(c.blue, 20) }) -- Highlight of indent character. Default: Whitespace set_hl('IndentBlanklineSpaceChar', { link = 'IndentBlanklineChar' }) -- Highlight of space character. Default: Whitespace set_hl('IndentBlanklineContextChar', { fg = c.blue }) -- Highlight of indent character when base of current context. Default: Label - set_hl('IndentBlanklineContextSpaceChar', { link = 'IndentBlanklineContextChar' }) -- Highlight of space characters one indent level of the current context. Default: Label + set_hl( + 'IndentBlanklineContextSpaceChar', + { link = 'IndentBlanklineContextChar' } + ) -- Highlight of space characters one indent level of the current context. Default: Label set_hl('IblIndent', { fg = lighten(c.blue, 20), nocombine = true }) set_hl('IblScope', { fg = c.blue, nocombine = true }) end diff --git a/lua/solarized/themes/neo/lspsaga.lua b/lua/solarized/themes/neo/lspsaga.lua index 79cc3dd..4becadc 100644 --- a/lua/solarized/themes/neo/lspsaga.lua +++ b/lua/solarized/themes/neo/lspsaga.lua @@ -4,7 +4,11 @@ return function(c, config) -- Float window set_hl('SagaNormal', { link = 'Pmenu' }) - set_hl('TitleString', { fg = c.orange, bold = true, bg = c.base02 }, { transparent = config.transparent }) + set_hl( + 'TitleString', + { fg = c.orange, bold = true, bg = c.base02 }, + { transparent = config.transparent } + ) -- Outline set_hl('OutlineIndent', { fg = c.green }) diff --git a/lua/solarized/themes/neo/neogit.lua b/lua/solarized/themes/neo/neogit.lua index 90b1112..fd368a9 100644 --- a/lua/solarized/themes/neo/neogit.lua +++ b/lua/solarized/themes/neo/neogit.lua @@ -7,12 +7,21 @@ return function(c) set_hl('NeogitCursorLine', { link = 'CursorLine' }) set_hl('NeogitBranch', { fg = c.magenta }) set_hl('NeogitRemote', { fg = c.violet }) - set_hl('NeogitHunkHeader', { fg = c.orange, bg = blend(c.orange, c.base03, alpha) }) + set_hl( + 'NeogitHunkHeader', + { fg = c.orange, bg = blend(c.orange, c.base03, alpha) } + ) set_hl('NeogitHunkHeaderHighlight', { link = 'Title' }) set_hl('NeogitDiffContextHighlight', { fg = c.base00, bg = c.base03 }) set_hl('NeogitDiffContext', { fg = c.base00, bg = c.base03 }) - set_hl('NeogitDiffDeleteHighlight', { fg = c.red, bg = blend(c.red, c.base03, alpha) }) + set_hl( + 'NeogitDiffDeleteHighlight', + { fg = c.red, bg = blend(c.red, c.base03, alpha) } + ) set_hl('NeogitDiffDelete', { fg = c.red }) - set_hl('NeogitDiffAddHighlight', { fg = c.green, bg = blend(c.green, c.base03, alpha) }) + set_hl( + 'NeogitDiffAddHighlight', + { fg = c.green, bg = blend(c.green, c.base03, alpha) } + ) set_hl('NeogitDiffAdd', { fg = c.green }) end diff --git a/lua/solarized/themes/neo/semantic.lua b/lua/solarized/themes/neo/semantic.lua index 1145d1c..9af96b2 100644 --- a/lua/solarized/themes/neo/semantic.lua +++ b/lua/solarized/themes/neo/semantic.lua @@ -12,7 +12,11 @@ return function(c, config) set_hl('@lsp.type.macro', { link = 'Keyword' }) -- Keyword set_hl('@lsp.type.method', { link = 'Function' }) -- Function set_hl('@lsp.type.namespace', { link = 'Constant' }) -- Constant - set_hl('@lsp.type.parameter', { fg = c.orange, italic = true }, { styles = config.styles.parameters }) + set_hl( + '@lsp.type.parameter', + { fg = c.orange, italic = true }, + { styles = config.styles.parameters } + ) set_hl('@lsp.type.property', { fg = c.blue }) -- Property set_hl('@lsp.type.struct', { link = 'Structure' }) -- Structure set_hl('@lsp.type.type', { link = 'Type' }) -- Type diff --git a/lua/solarized/themes/neo/syntax.lua b/lua/solarized/themes/neo/syntax.lua index 5931c1e..c43149c 100644 --- a/lua/solarized/themes/neo/syntax.lua +++ b/lua/solarized/themes/neo/syntax.lua @@ -2,7 +2,11 @@ return function(c, config) local utils = require('solarized.utils') local set_hl = utils.set_hl - set_hl('Comment', { fg = c.base01, italic = true }, { styles = config.styles.comments }) -- any comment + set_hl( + 'Comment', + { fg = c.base01, italic = true }, + { styles = config.styles.comments } + ) -- any comment set_hl('Constant', { fg = c.violet }, { styles = config.styles.constants }) -- any constant set_hl('String', { fg = c.cyan }) -- a string constant: "this is a string" set_hl('Character', { link = 'String' }) -- a character constant: 'c', '\n' diff --git a/lua/solarized/themes/neo/telescope.lua b/lua/solarized/themes/neo/telescope.lua index 6f0e5ba..2c98f98 100644 --- a/lua/solarized/themes/neo/telescope.lua +++ b/lua/solarized/themes/neo/telescope.lua @@ -8,7 +8,11 @@ return function(c, config) set_hl('TelescopeMultiIcon', { fg = c.cyan }) -- "Normal" in the floating windows created by telescope. - set_hl('TelescopeNormal', { fg = c.base0, bg = c.base04 }, { transparent = config.transparent }) + set_hl( + 'TelescopeNormal', + { fg = c.base0, bg = c.base04 }, + { transparent = config.transparent } + ) set_hl('TelescopePreviewNormal', { link = 'TelescopeNormal' }) set_hl('TelescopePromptNormal', { link = 'TelescopeNormal' }) set_hl('TelescopeResultsNormal', { link = 'TelescopeNormal' }) diff --git a/lua/solarized/themes/neo/todo.lua b/lua/solarized/themes/neo/todo.lua index 142ec62..75b0785 100644 --- a/lua/solarized/themes/neo/todo.lua +++ b/lua/solarized/themes/neo/todo.lua @@ -35,9 +35,15 @@ return function(c) set_hl('TodoSignFIX', { fg = c.error }) set_hl('TodoBgTODO', { fg = c.info, bg = colorFunc(c.info, percentage) }) - set_hl('TodoBgWARN', { fg = c.warning, bg = colorFunc(c.warning, percentage) }) + set_hl( + 'TodoBgWARN', + { fg = c.warning, bg = colorFunc(c.warning, percentage) } + ) set_hl('TodoBgTEST', { fg = c.violet, bg = colorFunc(c.violet, percentage) }) - set_hl('TodoBgPERF', { fg = c.magenta, bg = colorFunc(c.magenta, percentage) }) + set_hl( + 'TodoBgPERF', + { fg = c.magenta, bg = colorFunc(c.magenta, percentage) } + ) set_hl('TodoBgNOTE', { fg = c.hint, bg = colorFunc(c.hint, percentage) }) set_hl('TodoBgHACK', { fg = c.cyan, bg = colorFunc(c.cyan, percentage) }) set_hl('TodoBgFIX', { fg = c.error, bg = colorFunc(c.error, percentage) }) diff --git a/lua/solarized/themes/neo/tree.lua b/lua/solarized/themes/neo/tree.lua index ed316f2..656d1e8 100644 --- a/lua/solarized/themes/neo/tree.lua +++ b/lua/solarized/themes/neo/tree.lua @@ -31,13 +31,21 @@ return function(c, config) set_hl('NvimTreeGitDeleted', { fg = c.delete }) -- set_hl('NvimTreeGitIgnored') -- (Comment) -- set_hl('NvimTreeWindowPicker') - set_hl('NvimTreeNormal', { fg = c.base0, bg = c.base04 }, { transparent = config.transparent }) + set_hl( + 'NvimTreeNormal', + { fg = c.base0, bg = c.base04 }, + { transparent = config.transparent } + ) set_hl('NvimTreeNormalFloat', { link = 'NvimTreeNormal' }) set_hl('NvimTreeEndOfBuffer', { fg = c.base04 }) -- (NonText) -- set_hl('NvimTreeCursorLine') -- (CursorLine) -- set_hl('NvimTreeCursorLineNr') -- (CursorLineNr) -- set_hl('NvimTreeLineNr') -- (LineNr) - set_hl('NvimTreeWinSeparator', { fg = c.base04, bg = c.base04 }, { transparent = config.transparent }) -- (WinSeparator) + set_hl( + 'NvimTreeWinSeparator', + { fg = c.base04, bg = c.base04 }, + { transparent = config.transparent } + ) -- (WinSeparator) -- set_hl('NvimTreeCursorColumn') -- (CursorColumn) -- -- There are also links for file highlight with git properties, linked to their diff --git a/lua/solarized/themes/neo/treesitter.lua b/lua/solarized/themes/neo/treesitter.lua index 3834205..47e71c3 100644 --- a/lua/solarized/themes/neo/treesitter.lua +++ b/lua/solarized/themes/neo/treesitter.lua @@ -36,7 +36,11 @@ return function(c, config) set_hl('@method.call', { link = 'Function' }) -- method calls set_hl('@constructor', { fg = c.magenta }) -- constructor calls and definitions - set_hl('@parameter', { fg = c.orange, italic = true }, { styles = config.styles.parameters }) -- parameters of a function + set_hl( + '@parameter', + { fg = c.orange, italic = true }, + { styles = config.styles.parameters } + ) -- parameters of a function set_hl('@keyword', { link = 'Keyword' }) -- various keywords set_hl('@keyword.coroutine', { link = 'Keyword' }) -- keywords related to coroutines (e.g. `go` in Go, `async/await` in Python) diff --git a/lua/solarized/utils/colors.lua b/lua/solarized/utils/colors.lua index b5d3ba1..9057adb 100644 --- a/lua/solarized/utils/colors.lua +++ b/lua/solarized/utils/colors.lua @@ -78,7 +78,11 @@ function M.blend(hex_fg, hex_bg, alpha) return floor(min(max(0, ret), 255) + 0.5) end - return M.rgb_to_hex(blend_channel(red_fg, red_bg), blend_channel(green_fg, green_bg), blend_channel(blue_fg, blue_bg)) + return M.rgb_to_hex( + blend_channel(red_fg, red_bg), + blend_channel(green_fg, green_bg), + blend_channel(blue_fg, blue_bg) + ) end return M diff --git a/lua/solarized/utils/init.lua b/lua/solarized/utils/init.lua index e251cba..5a50a84 100644 --- a/lua/solarized/utils/init.lua +++ b/lua/solarized/utils/init.lua @@ -11,18 +11,12 @@ function M.set_hl(name, val, opts) local default_val = { fg = 'NONE', bg = 'NONE' } val = val or {} - if not val.link then - val = vim.tbl_extend('force', default_val, val) - end + if not val.link then val = vim.tbl_extend('force', default_val, val) end if opts then - if opts.styles then - val = vim.tbl_extend('force', val, opts.styles) - end + if opts.styles then val = vim.tbl_extend('force', val, opts.styles) end - if opts.transparent then - val.bg = 'NONE' - end + if opts.transparent then val.bg = 'NONE' end end vim.api.nvim_set_hl(0, name, val) @@ -32,11 +26,10 @@ end --- @param highlight_name string --- @return table highlight function M.get_hl(highlight_name) - local highlight = vim.api.nvim_get_hl(0, { name = highlight_name, link = true }) + local highlight = + vim.api.nvim_get_hl(0, { name = highlight_name, link = true }) - if highlight.link then - return M.get_hl(highlight.link) - end + if highlight.link then return M.get_hl(highlight.link) end return highlight end diff --git a/plugin/solarized.lua b/plugin/solarized.lua index 0a66113..c671e1b 100644 --- a/plugin/solarized.lua +++ b/plugin/solarized.lua @@ -1,5 +1,8 @@ vim.api.nvim_create_user_command('Solarized', function(args) - require('solarized.command').load(args.fargs[1], vim.list_slice(args.fargs, 2)) + require('solarized.command').load( + args.fargs[1], + vim.list_slice(args.fargs, 2) + ) end, { range = true, nargs = '+',