From 083d18269be775cc7f343a13a1d19ffe71bc7c10 Mon Sep 17 00:00:00 2001 From: krolyxon Date: Sat, 10 Sep 2022 14:16:11 +0530 Subject: [PATCH] integrate colors into the config instead of plugin --- init.lua | 3 + lua/colors/integrations/cmp.lua | 45 ++++++ lua/colors/integrations/nvim.lua | 127 +++++++++++++++++ lua/colors/integrations/syntax.lua | 130 +++++++++++++++++ lua/colors/integrations/treesitter.lua | 185 +++++++++++++++++++++++++ lua/colors/kdark.lua | 44 ++++++ lua/core/utils.lua | 16 +++ lua/plugins/configs/cmp.lua | 2 + lua/plugins/configs/treesitter.lua | 2 + lua/plugins/init.lua | 10 -- 10 files changed, 554 insertions(+), 10 deletions(-) create mode 100644 lua/colors/integrations/cmp.lua create mode 100644 lua/colors/integrations/nvim.lua create mode 100644 lua/colors/integrations/syntax.lua create mode 100644 lua/colors/integrations/treesitter.lua create mode 100644 lua/colors/kdark.lua diff --git a/init.lua b/init.lua index 273a59e..3a17825 100644 --- a/init.lua +++ b/init.lua @@ -30,3 +30,6 @@ for _, module in ipairs(modules) do end require("core.utils").load_mappings() +-- require("core.utils").load_highlight "syntax" +-- require("core.utils").load_highlight "nvim" +require("core.utils").load_highlight "core" diff --git a/lua/colors/integrations/cmp.lua b/lua/colors/integrations/cmp.lua new file mode 100644 index 0000000..1adcd70 --- /dev/null +++ b/lua/colors/integrations/cmp.lua @@ -0,0 +1,45 @@ +local theme = require("colors.kdark").colors + +local black = theme.black +local red = theme.red +local green = theme.green +local yellow = theme.yellow +local blue = theme.blue +local magenta = theme.magenta +local cyan = theme.cyan +local white = theme.white +local bright_black = theme.bright_black +local bright_red = theme.bright_red +local bright_green = theme.bright_green +local bright_yellow = theme.bright_yellow +local bright_blue = theme.bright_blue +local bright_magenta = theme.bright_magenta +local bright_cyan = theme.bright_cyan +local bright_white = theme.bright_white + + +return { + CmpItemKindConstant = { fg = bright_red }, + CmpItemKindFunction = { fg = bright_magenta }, + CmpItemKindIdentifier = { fg = bright_black }, + CmpItemKindField = { fg = bright_black }, + CmpItemKindVariable = { fg = bright_cyan }, + Special = { fg = bright_blue }, + CmpItemKindSnippet = { fg = red }, + CmpItemKindText = { fg = bright_yellow }, + CmpItemKindStructure = { fg = bright_cyan }, + CmpItemKindType = { fg = bright_green }, + CmpItemKindKeyword = { fg = white }, + CmpItemKindMethod = { fg = bright_magenta }, + CmpItemKindConstructor = { fg = blue }, + CmpItemKindFolder = { fg = white }, + CmpItemKindModule = { fg = bright_green }, + CmpItemKindProperty = { fg = bright_black }, + CmpItemKindUnit = { fg = bright_cyan }, + CmpItemKindFile = { fg = white }, + CmpItemKindColor = { fg = red }, + CmpItemKindReference = { fg = magenta }, + CmpItemKindStruct = { fg = bright_cyan }, + CmpItemKindOperator = { fg = magenta }, + CmpItemKindTypeParameter = { fg = bright_black }, +} diff --git a/lua/colors/integrations/nvim.lua b/lua/colors/integrations/nvim.lua new file mode 100644 index 0000000..a5016ff --- /dev/null +++ b/lua/colors/integrations/nvim.lua @@ -0,0 +1,127 @@ +local theme = require("colors.kdark").colors + +local black = theme.black -- base00 +local red = theme.red -- base01 +local green = theme.green -- base02 +local yellow = theme.yellow -- base03 +local blue = theme.blue -- base04 +local magenta = theme.magenta -- base05 +local cyan = theme.cyan -- base06 +local white = theme.white -- base07 +local bright_black = theme.bright_black -- base08 +local bright_red = theme.bright_red -- base09 +local bright_green = theme.bright_green -- base0A +local bright_yellow = theme.bright_yellow -- base0B +local bright_blue = theme.bright_blue -- base0C +local bright_magenta = theme.bright_magenta -- base0D +local bright_cyan = theme.bright_cyan -- base0E +local bright_white = theme.bright_white -- base0F + +return { + + Comment = { fg = bright_black }, + + SignColumn = { + bg = '#000000', + }, + + -- line number + LineNr = { fg = bright_black }, + CursorLineNr = { fg = white }, + + CursorLine = { + bg = black, + sp = "none", + }, + + -- those ugly ~'s + EndOfBuffer = { fg = black }, + + -- floating windows + FloatBorder = { fg = blue }, + NormalFloat = { bg = black }, + + -- Pmenu i.e completion menu + Pmenu = { bg = black }, + PmenuSbar = { bg = black }, + PmenuSel = { bg = black, fg = white }, + PmenuThumb = { bg = bright_black }, + + -- nvim cmp + CmpItemAbbr = { fg = white }, + CmpItemAbbrMatch = { fg = blue, bold = true }, + CmpBorder = { fg = bright_black }, + CmpDocBorder = { fg = bright_black }, + + NvimInternalError = { fg = red }, + WinSeparator = { fg = bright_black }, + + -- Dashboard i.e alpha.nvim + AlphaHeader = { fg = bright_black }, + AlphaButtons = { fg = bright_black }, + + -- Gitsigns.nvim + DiffAdd = { + fg = blue, + }, + + DiffAdded = { + fg = green, + }, + + DiffChange = { + fg = bright_black, + }, + + DiffChangeDelete = { + fg = red, + }, + + DiffModified = { + fg = yellow, + }, + + DiffDelete = { + fg = red, + }, + + DiffRemoved = { + fg = red, + }, + + -- Indent blankline + IndentBlanklineChar = { fg = bright_black }, + IndentBlanklineSpaceChar = { fg = bright_black }, + + -- Lsp Diagnostics + DiagnosticHint = { fg = magenta }, + DiagnosticError = { fg = red }, + DiagnosticWarn = { fg = yellow }, + DiagnosticInformation = { fg = green }, + + -- NvimTree + NvimTreeEmptyFolderName = { fg = bright_blue }, + NvimTreeEndOfBuffer = { fg = black }, + NvimTreeFolderIcon = { fg = bright_blue }, + NvimTreeFolderName = { fg = bright_blue }, + NvimTreeGitDirty = { fg = red }, + NvimTreeIndentMarker = { fg = bright_black }, + NvimTreeNormal = { bg = '#000000' }, + NvimTreeNormalNC = { bg = '#000000' }, + NvimTreeOpenedFolderName = { fg = bright_blue }, + NvimTreeGitIgnored = { fg = bright_black }, + + NvimTreeWinSeparator = { + fg = '#000000', + bg = '#000000', + }, + + NvimTreeWindowPicker = { + fg = red, + bg = black, + }, + + NvimTreeCursorLine = { + bg = black, + }, +} diff --git a/lua/colors/integrations/syntax.lua b/lua/colors/integrations/syntax.lua new file mode 100644 index 0000000..82ae572 --- /dev/null +++ b/lua/colors/integrations/syntax.lua @@ -0,0 +1,130 @@ +local theme = require("colors.kdark").colors + +-- Standard syntax highlighting +local black = theme.black +local red = theme.red +local green = theme.green +local yellow = theme.yellow +local blue = theme.blue +local magenta = theme.magenta +local cyan = theme.cyan +local white = theme.white +local bright_black = theme.bright_black +local bright_red = theme.bright_red +local bright_green = theme.bright_green +local bright_yellow = theme.bright_yellow +local bright_blue = theme.bright_blue +local bright_magenta = theme.bright_magenta +local bright_cyan = theme.bright_cyan +local bright_white = theme.bright_white + +return { + Boolean = { + fg = yellow, + }, + + Character = { + fg = magenta, + }, + + Conditional = { + fg = magenta, + }, + + Constant = { + fg = magenta, + }, + + Define = { + fg = magenta, + sp = "none", + }, + + Delimiter = { + fg = yellow, + }, + + Float = { + fg = yellow, + }, + + Function = { + fg = bright_blue, + }, + + Identifier = { + fg = magenta, + sp = "none", + }, + + Include = { + fg = bright_blue, + }, + + Keyword = { + fg = magenta, + }, + + Label = { + fg = yellow, + }, + + Number = { + fg = yellow, + }, + + Operator = { + fg = bright_black, + sp = "none", + }, + + PreProc = { + fg = yellow, + }, + + Repeat = { + fg = yellow, + }, + + Special = { + fg = bright_blue, + }, + + SpecialChar = { + fg = magenta, + }, + + Statement = { + fg = magenta, + }, + + StorageClass = { + fg = yellow, + }, + + String = { + fg = bright_green, + }, + + Structure = { + fg = magenta, + }, + + Tag = { + fg = yellow, + }, + + Todo = { + fg = yellow, + bg = bright_black, + }, + + Type = { + fg = yellow, + sp = "none", + }, + + Typedef = { + fg = yellow, + }, +} diff --git a/lua/colors/integrations/treesitter.lua b/lua/colors/integrations/treesitter.lua new file mode 100644 index 0000000..dbe26c3 --- /dev/null +++ b/lua/colors/integrations/treesitter.lua @@ -0,0 +1,185 @@ +local theme = require("colors.kdark").colors + +local black = theme.black -- base00 +local red = theme.red -- base01 +local green = theme.green -- base02 +local yellow = theme.yellow -- base03 +local blue = theme.blue -- base04 +local magenta = theme.magenta -- base05 +local cyan = theme.cyan -- base06 +local white = theme.white -- base07 +local bright_black = theme.bright_black -- base08 +local bright_red = theme.bright_red -- base09 +local bright_green = theme.bright_green -- base0A +local bright_yellow = theme.bright_yellow -- base0B +local bright_blue = theme.bright_blue -- base0C +local bright_magenta = theme.bright_magenta -- base0D +local bright_cyan = theme.bright_cyan -- base0E +local bright_white = theme.bright_white -- base0F + +return { + TSAnnotation = { + fg = bright_magenta, + sp = "none", + }, + + TSAttribute = { + fg = bright_green, + sp = "none", + }, + + TSCharacter = { + fg = magenta, + sp = "none", + }, + + TSConstBuiltin = { + fg = bright_yellow, + sp = "none", + }, + + TSConstMacro = { + fg = magenta, + sp = "none", + }, + + TSError = { + fg = red, + sp = "none", + }, + + TSException = { + fg = magenta, + sp = "none", + }, + + TSFloat = { + fg = bright_yellow, + sp = "none", + }, + + TSFuncBuiltin = { + fg = bright_blue, + sp = "none", + }, + + TSFuncMacro = { + fg = magenta, + sp = "none", + }, + + TSKeywordOperator = { + fg = bright_magenta, + sp = "none", + }, + + TSMethod = { + fg = bright_blue, + sp = "none", + }, + + TSNamespace = { + fg = magenta, + sp = "none", + }, + + TSNone = { + fg = bright_black, + sp = "none", + }, + + TSParameter = { + fg = magenta, + sp = "none", + }, + + TSParameterReference = { + fg = yellow, + sp = "none", + }, + + TSPunctDelimiter = { + fg = yellow, + sp = "none", + }, + + TSPunctSpecial = { + fg = white, + sp = "none", + }, + + TSStringRegex = { + fg = cyan, + sp = "none", + }, + + TSStringEscape = { + fg = cyan, + sp = "none", + }, + + TSSymbol = { + fg = bright_green, + sp = "none", + }, + + TSTagDelimiter = { + fg = bright_red, + sp = "none", + }, + + TSText = { + fg = white, + sp = "none", + }, + + TSStrong = { + bold = true, + }, + + TSEmphasis = { + fg = theme.base09, + sp = "none", + }, + + TSStrike = { + fg = black, + sp = "none", + strikethrough = true, + }, + + TSLiteral = { + fg = bright_magenta, + sp = "none", + }, + + TSURI = { + fg = bright_magenta, + sp = "none", + underline = true, + }, + + TSTypeBuiltin = { + fg = yellow, + sp = "none", + }, + + TSVariableBuiltin = { + fg = bright_yellow, + sp = "none", + }, + + TSDefinition = { + sp = blue, + underline = true, + }, + + TSDefinitionUsage = { + sp = bright_black, + underline = true, + }, + + TSCurrentScope = { + bold = true, + }, +} diff --git a/lua/colors/kdark.lua b/lua/colors/kdark.lua new file mode 100644 index 0000000..37a0028 --- /dev/null +++ b/lua/colors/kdark.lua @@ -0,0 +1,44 @@ +local M = {} + +M.colors= { + -- black = "#131313", -- base00 + black = "#000000", -- base00 + red = "#cd0000", -- base01 + green = "#00cd00", -- base02 + yellow = "#cdcd00", -- base03 + blue = "#0000ee", -- base04 + magenta = "#cd00cd", -- base05 + cyan = "#00cdcd", -- base06 + white = "#e5e5e5", -- base07 + bright_black = "#7f7f7f", -- base08 + bright_red = "#ff0000", -- base09 + bright_green = "#00ff00", -- base0A + bright_yellow = "#ffff00", -- base0B + bright_blue = "#5c5cff", -- base0C + bright_magenta = "#ff00ff", -- base0D + bright_cyan = "#00ffff", -- base0E + bright_white = "#ffffff", -- base0F + +} + +-- M.colors= { +-- black = "#131313", -- base00 +-- red = "#353b45", -- base01 +-- green = "#3e4451", -- base02 +-- yellow = "#545862", -- base03 +-- blue = "#565c64", -- base04 +-- magenta = "#abb2bf", -- base05 +-- cyan = "#b6bdca", -- base06 +-- white = "#c8ccd4", -- base07 +-- bright_black = "#cd00cd", -- base08 +-- bright_red = "#d19a66", -- base09 +-- bright_green = "#cdcd00", -- base0A +-- bright_yellow = "#00ff00", -- base0B +-- bright_blue = "#56b6c2", -- base0C +-- bright_magenta = "#5c5cff", -- base0D +-- bright_cyan = "#cd00cd", -- base0E +-- bright_white = "#be5046", -- base0F +-- } + + +return M diff --git a/lua/core/utils.lua b/lua/core/utils.lua index d9085f3..89bc7c8 100644 --- a/lua/core/utils.lua +++ b/lua/core/utils.lua @@ -1,6 +1,22 @@ local M = {} local merge_tb = vim.tbl_deep_extend + +M.load_highlight = function(group) + if type(group) == "string" and group == "core" then + local syntax = require("colors.integrations.syntax") + local nvim = require("colors.integrations.nvim") + group = merge_tb("force", syntax, nvim) + end + if type(group) == "string" then + group = require("colors.integrations." .. group) + end + + for hl, col in pairs(group) do + vim.api.nvim_set_hl(0, hl, col) + end +end + M.close_buffer = function(bufnr) if vim.bo.buftype == "terminal" then vim.cmd(vim.bo.buflisted and "set nobl | enew" or "hide") diff --git a/lua/plugins/configs/cmp.lua b/lua/plugins/configs/cmp.lua index a40fa5b..dd27467 100644 --- a/lua/plugins/configs/cmp.lua +++ b/lua/plugins/configs/cmp.lua @@ -4,6 +4,8 @@ if not present then return end +require("core.utils").load_highlight "cmp" + vim.opt.completeopt = "menuone,noselect" local function border(hl_name) diff --git a/lua/plugins/configs/treesitter.lua b/lua/plugins/configs/treesitter.lua index 49c2c2d..9fcdae3 100644 --- a/lua/plugins/configs/treesitter.lua +++ b/lua/plugins/configs/treesitter.lua @@ -4,6 +4,8 @@ if not present then return end +require("core.utils").load_highlight "treesitter" + local options = { ensure_installed = { "lua", diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 5510ac2..b1cfeb1 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -162,16 +162,6 @@ local plugins = { -- UI stuff - ["krolyxon/kdark"] = { - config = function() - local ok, kdark = pcall(require, "kdark") - - if ok then - kdark.load_theme() - end - end, - }, - ["lukas-reineke/indent-blankline.nvim"] = { event = "BufRead", config = function()