Skip to content

Commit

Permalink
remove hard-coded colors from vim config
Browse files Browse the repository at this point in the history
  • Loading branch information
izumin5210 committed Mar 25, 2024
1 parent f627d9c commit 7a95eba
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 54 deletions.
23 changes: 14 additions & 9 deletions config/.config/nvim/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -305,11 +305,12 @@ require('lazy').setup({
cond = not vim.g.vscode,
event = 'BufReadPost',
config = function()
local palette = require("colors").palette
require('scrollbar').setup({
marks = {
Search = { color_nr = '3', color = '#c57339' },
Error = { color_nr = '9', color = '#cc3768' },
Warn = { color_nr = '11', color = '#b6662d' },
Search = { color_nr = '3', color = palette.yellow },
Error = { color_nr = '9', color = palette.red },
Warn = { color_nr = '11', color = palette.peach },
},
handlers = {
cursor = true,
Expand Down Expand Up @@ -497,17 +498,18 @@ require('lazy').setup({
cond = not vim.g.vscode,
event = { 'CursorMoved', 'CursorMovedI' },
init = function()
local palette = require('colors').palette
vim.api.nvim_create_autocmd('Colorscheme', {
pattern = '*',
command = 'highlight IlluminatedWordText ctermbg=238 guibg=#33374c'
command = string.format("highlight IlluminatedWordText ctermbg=238 guibg=%s", palette.overlay0)
})
vim.api.nvim_create_autocmd('Colorscheme', {
pattern = '*',
command = 'highlight IlluminatedWordRead ctermbg=238 guibg=#33374c'
command = string.format("highlight IlluminatedWordRead ctermbg=238 guibg=%s", palette.overlay0)
})
vim.api.nvim_create_autocmd('Colorscheme', {
pattern = '*',
command = 'highlight IlluminatedWordWrite ctermbg=238 guibg=#33374c'
command = string.format("highlight IlluminatedWordWrite ctermbg=238 guibg=%s", palette.overlay0)
})
end,
config = function()
Expand All @@ -519,9 +521,10 @@ require('lazy').setup({
cond = not vim.g.vscode,
event = 'VeryLazy',
init = function()
local palette = require('colors').palette
vim.api.nvim_create_autocmd('Colorscheme', {
pattern = '*',
command = 'highlight ExtraWhitespace guibg=#e27878'
command = string.format('highlight ExtraWhitespace guibg=%s', palette.red)
})
end,
config = function()
Expand Down Expand Up @@ -661,6 +664,8 @@ if not vim.g.vscode then
end
})

local palette = require('colors').palette

-- clear bg
vim.api.nvim_create_autocmd('Colorscheme', {
pattern = '*',
Expand All @@ -685,11 +690,11 @@ if not vim.g.vscode then
-- floating
vim.api.nvim_create_autocmd('Colorscheme', {
pattern = '*',
command = 'highlight NormalFloat guibg=#1e2132'
command = string.format('highlight NormalFloat guibg=%s', palette.mantle)
})
vim.api.nvim_create_autocmd('Colorscheme', {
pattern = '*',
command = 'highlight FloatBorder guibg=#1e2132 blend=20'
command = string.format('highlight FloatBorder guibg=%s blend=20', palette.mantle)
})
vim.opt.termguicolors = true
vim.opt.winblend = 20
Expand Down
8 changes: 8 additions & 0 deletions config/.config/nvim/lua/colors.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
local M = {}

local palletes = require("catppuccin.palettes")
local palette = palletes.get_palette("frappe")

M.palette = palette

return M
4 changes: 3 additions & 1 deletion config/.config/nvim/lua/pluginconfig/bufferline.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
local M = {}

function M.setup()
local palette = require('colors').palette

local hl_selected = { bg = 'none', italic = false, bold = true }
local hl_normal_fg = { highlight = 'Normal', attribute = 'fg' }
local hl_comment_fg = { highlight = 'Comment', attribute = 'fg' }
local hl_separator = { fg = '#262a3f', bg = 'none' }
local hl_separator = { fg = palette.surface1, bg = 'none' }

require('bufferline').setup({
options = {
Expand Down
61 changes: 31 additions & 30 deletions config/.config/nvim/lua/pluginconfig/cmp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,48 +26,49 @@ end

function M.init()
local augroup = vim.api.nvim_create_augroup('cmp_init', { clear = true })
local palette = require('colors').palette

-- https://github.com/hrsh7th/nvim-cmp/wiki/Menu-Appearance#how-to-get-types-on-the-left-and-offset-the-menu
local tbl = {
CmpItemAbbrDeprecated = { fg = '#6b7089', bg = 'NONE', fmt = 'strikethrough' },
CmpItemAbbrMatch = { fg = '#91acd1', bg = 'NONE', fmt = 'bold' },
CmpItemAbbrMatchFuzzy = { fg = '#91acd1', bg = 'NONE', fmt = 'bold' },
CmpItemMenu = { fg = '#ada0d3', bg = 'NONE', fmt = 'italic' },
CmpItemAbbrDeprecated = { fg = palette.overlay0, bg = "NONE", strikethrough = true },
CmpItemAbbrMatch = { fg = palette.blue, bg = "NONE", bold = true },
CmpItemAbbrMatchFuzzy = { fg = palette.blue, bg = "NONE", bold = true },
CmpItemMenu = { fg = palette.mauve, bg = "NONE", italic = true },

CmpItemKindField = { fg = '#c6c8d1', bg = '#e27878' },
CmpItemKindProperty = { fg = '#c6c8d1', bg = '#e27878' },
CmpItemKindEvent = { fg = '#c6c8d1', bg = '#e27878' },
CmpItemKindField = { fg = palette.text, bg = palette.red },
CmpItemKindProperty = { fg = palette.text, bg = palette.red },
CmpItemKindEvent = { fg = palette.text, bg = palette.red },

CmpItemKindText = { fg = '#c6c8d1', bg = '#b4be82' },
CmpItemKindEnum = { fg = '#c6c8d1', bg = '#b4be82' },
CmpItemKindKeyword = { fg = '#c6c8d1', bg = '#b4be82' },
CmpItemKindText = { fg = palette.text, bg = palette.green },
CmpItemKindEnum = { fg = palette.text, bg = palette.green },
CmpItemKindKeyword = { fg = palette.text, bg = palette.green },

CmpItemKindConstant = { fg = '#c6c8d1', bg = '#e2a478' },
CmpItemKindConstructor = { fg = '#c6c8d1', bg = '#e2a478' },
CmpItemKindReference = { fg = '#c6c8d1', bg = '#e2a478' },
CmpItemKindConstant = { fg = palette.text, bg = palette.yellow },
CmpItemKindConstructor = { fg = palette.text, bg = palette.yellow },
CmpItemKindReference = { fg = palette.text, bg = palette.yellow },

CmpItemKindFunction = { fg = '#c6c8d1', bg = '#a093c7' },
CmpItemKindStruct = { fg = '#c6c8d1', bg = '#a093c7' },
CmpItemKindClass = { fg = '#c6c8d1', bg = '#a093c7' },
CmpItemKindModule = { fg = '#c6c8d1', bg = '#a093c7' },
CmpItemKindOperator = { fg = '#c6c8d1', bg = '#a093c7' },
CmpItemKindFunction = { fg = palette.text, bg = palette.mauve },
CmpItemKindStruct = { fg = palette.text, bg = palette.mauve },
CmpItemKindClass = { fg = palette.text, bg = palette.mauve },
CmpItemKindModule = { fg = palette.text, bg = palette.mauve },
CmpItemKindOperator = { fg = palette.text, bg = palette.mauve },

CmpItemKindVariable = { fg = '#c6c8d1', bg = '#6b7089' },
CmpItemKindFile = { fg = '#c6c8d1', bg = '#6b7089' },
CmpItemKindVariable = { fg = palette.text, bg = palette.overlay0 },
CmpItemKindFile = { fg = palette.text, bg = palette.overlay0 },

CmpItemKindUnit = { fg = '#c6c8d1', bg = '#6b7089' },
CmpItemKindSnippet = { fg = '#c6c8d1', bg = '#6b7089' },
CmpItemKindFolder = { fg = '#c6c8d1', bg = '#6b7089' },
CmpItemKindUnit = { fg = palette.text, bg = palette.peach },
CmpItemKindSnippet = { fg = palette.text, bg = palette.peach },
CmpItemKindFolder = { fg = palette.text, bg = palette.peach },

CmpItemKindMethod = { fg = '#c6c8d1', bg = '#84a0c6' },
CmpItemKindValue = { fg = '#c6c8d1', bg = '#84a0c6' },
CmpItemKindEnumMember = { fg = '#c6c8d1', bg = '#84a0c6' },
CmpItemKindMethod = { fg = palette.text, bg = palette.blue },
CmpItemKindValue = { fg = palette.text, bg = palette.blue },
CmpItemKindEnumMember = { fg = palette.text, bg = palette.blue },

CmpItemKindInterface = { fg = '#c6c8d1', bg = '#89b8c2' },
CmpItemKindColor = { fg = '#c6c8d1', bg = '#89b8c2' },
CmpItemKindTypeParameter = { fg = '#c6c8d1', bg = '#89b8c2' },
CmpItemKindInterface = { fg = palette.text, bg = palette.teal },
CmpItemKindColor = { fg = palette.text, bg = palette.teal },
CmpItemKindTypeParameter = { fg = palette.text, bg = palette.teal },

CmpItemKindCopilot = { fg = '#c6c8d1', bg = '#a093c7' },
CmpItemKindCopilot = { fg = palette.text, bg = palette.lavender },
}

for key, colors in pairs(tbl) do
Expand Down
4 changes: 3 additions & 1 deletion config/.config/nvim/lua/pluginconfig/lualine.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
local M = {}

function M.setup()
local palette = require('colors').palette
local codicons = require('codicons')

require('lualine').setup({
options = {
icons_enabled = true,
Expand All @@ -19,7 +21,7 @@ function M.setup()
require('pluginconfig.dap').status,
icon = { codicons.get('debug') },
cond = require('pluginconfig.dap').is_loaded,
color = { fg = '#b4be82' }
color = { fg = palette.teal }
},
'filename',
{ 'aerial', sep = '', dence = true }, -- the same as copmonent separator
Expand Down
18 changes: 10 additions & 8 deletions config/.config/nvim/lua/pluginconfig/modes.lua
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
local M = {}

function M.setup()
local palette = require('colors').palette

require('modes').setup({
colors = {
copy = '#e2a478', -- yellow
delete = '#e27878', -- red
insert = '#89b8c2', -- cyan
visual = '#a093c7', -- purple
copy = palette.yellow,
delete = palette.red,
insert = palette.sky,
visual = palette.mauve,
},
line_opacity = {
copy = 0.15,
delete = 0.15,
insert = 0.15,
visual = 0.25,
copy = 0.4,
delete = 0.4,
insert = 0.4,
visual = 0.4,
}
})
end
Expand Down
10 changes: 5 additions & 5 deletions config/.config/nvim/lua/pluginconfig/treesitter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@ end

function M.init_rainbow_delimiters()
local augroup = vim.api.nvim_create_augroup('ts_rainbow2_init', { clear = true })
local palette = require('colors').palette

vim.api.nvim_create_autocmd('Colorscheme', {
group = augroup,
pattern = '*',
command = 'highlight link RainbowDelimiterRed DiagnosticError'
command = string.format('highlight RainbowDelimiterRed guifg=%s', palette.maroon),
})
vim.api.nvim_create_autocmd('Colorscheme', {
group = augroup,
pattern = '*',
command = 'highlight link RainbowDelimiterYellow DiagnosticWarn'
command = string.format('highlight RainbowDelimiterYellow guifg=%s', palette.yellow),
})
vim.api.nvim_create_autocmd('Colorscheme', {
group = augroup,
pattern = '*',
command = 'highlight RainbowDelimiterGreen guifg=#b4be82'
command = string.format('highlight RainbowDelimiterGreen guifg=%s', palette.green),
})
vim.api.nvim_create_autocmd('Colorscheme', {
group = augroup,
pattern = '*',

command = 'highlight RainbowDelimiterBlue guifg=#84a0c6'
command = string.format('highlight RainbowDelimiterBlue guifg=%s', palette.sapphire),
})

local rainbow_delimiters = require('rainbow-delimiters')
Expand Down

0 comments on commit 7a95eba

Please sign in to comment.