breaking change: moved highlight stuff to base16 repo | rewrote whole base16 repo

Just run :PackerSync, check https://nvchad.github.io/config/Custom%20config#local-themes and the section below it for newly added features
This commit is contained in:
siduck 2022-05-03 00:13:38 +05:30
parent e557dc3af9
commit 02d545cd42
10 changed files with 12 additions and 304 deletions

View file

@ -1,203 +0,0 @@
local cmd = vim.cmd
local colors = require("colors").get()
local ui = require("core.utils").load_config().ui
local black = colors.black
local black2 = colors.black2
local blue = colors.blue
local darker_black = colors.darker_black
local folder_bg = colors.folder_bg
local green = colors.green
local grey = colors.grey
local grey_fg = colors.grey_fg
local light_grey = colors.light_grey
local line = colors.line
local nord_blue = colors.nord_blue
local one_bg = colors.one_bg
local one_bg2 = colors.one_bg2
local pmenu_bg = colors.pmenu_bg
local purple = colors.purple
local red = colors.red
local white = colors.white
local yellow = colors.yellow
local orange = colors.orange
-- Disable cursor line
cmd "hi clear CursorLine"
-- highlight groups & colors
local hl_cols = {
Comment = { fg = grey_fg },
-- line numbers
CursorLineNr = { fg = white },
LineNr = { fg = grey },
-- those ugly ~'s
EndOfBuffer = { fg = black },
-- floating windows
FloatBorder = { fg = blue },
NormalFloat = { bg = darker_black },
-- Pmenu i.e completion menu
Pmenu = { bg = one_bg },
PmenuSbar = { bg = one_bg2 },
PmenuSel = { bg = pmenu_bg, fg = black },
PmenuThumb = { bg = nord_blue },
-- nvim cmp
CmpItemAbbr = { fg = white },
CmpItemAbbrMatch = { fg = white },
CmpItemKind = { fg = white },
CmpItemMenu = { fg = white },
NvimInternalError = { fg = red },
WinSeparator = { fg = one_bg2 },
-- Dashboard i.e alpha.nvim
AlphaHeader = { fg = grey_fg },
AlphaButtons = { fg = light_grey },
-- Gitsigns.nvim
DiffAdd = {
fg = blue,
bg = "NONE",
},
DiffChange = {
fg = light_grey,
bg = "NONE",
},
DiffChangeDelete = {
fg = red,
bg = "NONE",
},
DiffModified = {
fg = orange,
bg = "NONE",
},
DiffDelete = {
fg = red,
bg = "NONE",
},
-- Indent blankline
IndentBlanklineChar = { fg = line },
IndentBlanklineSpaceChar = { fg = line },
-- Lsp Diagnostics
DiagnosticHint = { fg = purple },
DiagnosticError = { fg = red },
DiagnosticWarn = { fg = yellow },
DiagnosticInformation = { fg = green },
-- NvimTree
NvimTreeEmptyFolderName = { fg = folder_bg },
NvimTreeEndOfBuffer = { fg = darker_black },
NvimTreeFolderIcon = { fg = folder_bg },
NvimTreeFolderName = { fg = folder_bg },
NvimTreeGitDirty = { fg = red },
NvimTreeIndentMarker = { fg = one_bg2 },
NvimTreeNormal = { bg = darker_black },
NvimTreeNormalNC = { bg = darker_black },
NvimTreeOpenedFolderName = { fg = folder_bg },
NvimTreeWinSeparator = {
fg = darker_black,
bg = darker_black,
},
NvimTreeWindowPicker = {
fg = red,
bg = black2,
},
-- Telescope
TelescopeBorder = {
fg = darker_black,
bg = darker_black,
},
TelescopePromptBorder = {
fg = black2,
bg = black2,
},
TelescopePromptNormal = {
fg = white,
bg = black2,
},
TelescopePromptPrefix = {
fg = red,
bg = black2,
},
TelescopeNormal = { bg = darker_black },
TelescopePreviewTitle = {
fg = black,
bg = green,
},
TelescopePromptTitle = {
fg = black,
bg = red,
},
TelescopeResultsTitle = {
fg = darker_black,
bg = darker_black,
},
TelescopeSelection = { bg = black2 },
}
if ui.transparency then
local hl_groups = {
"NormalFloat",
"Normal",
"Folded",
"NvimTreeNormal",
"NvimTreeNormalNC",
"TelescopeNormal",
"TelescopePrompt",
"TelescopeResults",
"TelescopeBorder",
"TelescopePromptBorder",
"TelescopePromptNormal",
"TelescopePromptPrefix",
}
for index, _ in ipairs(hl_groups) do
hl_cols[hl_groups[index]] = {
bg = "NONE",
}
end
hl_cols.NvimTreeWinSeparator = {
fg = grey,
bg = "NONE",
}
hl_cols.TelescopeResultsTitle = {
fg = black,
bg = blue,
}
end
local utils = require "core.utils"
local user_highlights = utils.load_config().ui.hl_override
-- override user highlights if there are any
hl_cols = vim.tbl_deep_extend("force", hl_cols, user_highlights)
for hl, col in pairs(hl_cols) do
vim.api.nvim_set_hl(0, hl, col)
end

View file

@ -1,52 +0,0 @@
local colors = require("core.utils").load_config().ui.colors
local override = require("core.utils").load_config().ui.hl_override
local M = {}
-- if theme given, load given theme if given, otherwise nvchad_theme
M.init = function(theme)
if not theme then
theme = require("core.utils").load_config().ui.theme
end
-- set the global theme, used at various places like theme switcher, highlights
vim.g.nvchad_theme = theme
local present, base16 = pcall(require, "base16")
if present then
-- first load the base16 theme
local ok, array = pcall(base16.themes, theme)
if ok then
base16(array, true)
-- unload to force reload
package.loaded["colors.highlights" or false] = nil
-- then load the highlights
require "colors.highlights"
else
pcall(vim.cmd, "colo " .. theme)
end
else
pcall(vim.cmd, "colo " .. theme)
end
if #override ~= 0 then
package.loaded[override] = nil
require(override)
end
end
-- returns a table of colors for given or current theme
M.get = function(theme)
if #colors ~= 0 then
return require(colors)
else
if not theme then
theme = vim.g.nvchad_theme
end
return require("hl_themes." .. theme)
end
end
return M

View file

@ -19,6 +19,7 @@ M.options = {
M.ui = { M.ui = {
hl_override = {}, hl_override = {},
changed_themes = {},
colors = "", -- path of your file that contains colors colors = "", -- path of your file that contains colors
theme = "onedark", -- default theme theme = "onedark", -- default theme
transparency = false, transparency = false,

View file

@ -1,7 +1,5 @@
local M = {} local M = {}
local cmd = vim.cmd
M.close_buffer = function(force) M.close_buffer = function(force)
if vim.bo.buftype == "terminal" then if vim.bo.buftype == "terminal" then
vim.api.nvim_win_hide(0) vim.api.nvim_win_hide(0)
@ -69,43 +67,6 @@ M.packer_lazy_load = function(plugin, timer)
end end
end end
-- Highlights functions
-- Define bg color
-- @param group Group
-- @param color Color
M.bg = function(group, col)
cmd("hi " .. group .. " guibg=" .. col)
end
-- Define fg color
-- @param group Group
-- @param color Color
M.fg = function(group, col)
cmd("hi " .. group .. " guifg=" .. col)
end
-- Define bg and fg color
-- @param group Group
-- @param fgcol Fg Color
-- @param bgcol Bg Color
M.fg_bg = function(group, fgcol, bgcol)
cmd("hi " .. group .. " guifg=" .. fgcol .. " guibg=" .. bgcol)
end
M.load_ifExists = function(module)
if #module ~= 0 then
if type(module) == "string" then
require(module)
-- file[1] = module & file[2] = function
elseif type(module) == "table" then
require(module[1])[module[2]]()
end
end
end
-- remove plugins defined in chadrc -- remove plugins defined in chadrc
M.remove_default_plugins = function(plugins) M.remove_default_plugins = function(plugins)
local removals = require("core.utils").load_config().plugins.remove or {} local removals = require("core.utils").load_config().plugins.remove or {}

View file

@ -3,7 +3,7 @@ if not present then
return return
end end
local colors = require("colors").get() local colors = require("base16").get_colors("base_30")
local options = { local options = {
options = { options = {

View file

@ -4,7 +4,7 @@ if not present then
return return
end end
local colors = require("colors").get() local colors = require("base16").get_colors("base_30")
local options = { local options = {
override = { override = {

View file

@ -2,11 +2,7 @@ local M = {}
require("plugins.configs.others").lsp_handlers() require("plugins.configs.others").lsp_handlers()
function M.on_attach(client, bufnr) function M.on_attach(client, _)
local function buf_set_option(...)
vim.api.nvim_buf_set_option(bufnr, ...)
end
client.resolved_capabilities.document_formatting = false client.resolved_capabilities.document_formatting = false
client.resolved_capabilities.document_range_formatting = false client.resolved_capabilities.document_range_formatting = false

View file

@ -34,7 +34,7 @@ g.nvim_tree_icons = {
default = "", default = "",
empty = "", empty = "",
empty_open = "", empty_open = "",
open = "", open = "",
symlink = "", symlink = "",
symlink_open = "", symlink_open = "",
}, },

View file

@ -4,7 +4,8 @@ if not present then
return return
end end
local colors = require("colors").get() local colors = require("base16").get_colors("base_30")
local lsp = require "feline.providers.lsp" local lsp = require "feline.providers.lsp"
local lsp_severity = vim.diagnostic.severity local lsp_severity = vim.diagnostic.severity

View file

@ -18,7 +18,11 @@ local plugins = {
["NvChad/nvim-base16.lua"] = { ["NvChad/nvim-base16.lua"] = {
after = "packer.nvim", after = "packer.nvim",
config = function() config = function()
require("colors").init() local ok, base16 = pcall(require, "base16")
if ok then
base16.load_theme()
end
end, end,
}, },