Additionally refactor the colors lua module into one with an init function that init.lua can invoke.
103 lines
3 KiB
Lua
103 lines
3 KiB
Lua
-- Eryn Wells <eryn@erynwells.me>
|
|
|
|
-- Allow using GUI style colors (#RRGGBB hex codes) in color terminals if we
|
|
-- know it can do it. This is required for most modern color themes. Apple's
|
|
-- Terminal.app doesn't have True Color support though, so make sure it's
|
|
-- off for that.
|
|
--vim.g.termguicolors = not vim.env.TERM_PROGRAM == "Apple_Terminal"
|
|
|
|
local function _highlight_trailing_whitespace()
|
|
local should_create_highlight_match = true
|
|
|
|
local group = vim.api.nvim_create_augroup("ListModeTrailingWhitespace", { clear = true })
|
|
|
|
local callback = function(env)
|
|
local list_mode_enabled = vim.api.nvim_get_option_value("list", { })
|
|
if list_mode_enabled then
|
|
vim.cmd [[ highlight link TrailingWhitespace ErrorMsg ]]
|
|
if should_create_highlight_match then
|
|
vim.cmd [[ match TrailingWhitespace /\v\s+$/ ]]
|
|
should_create_highlight_match = false
|
|
end
|
|
else
|
|
vim.cmd [[ highlight clear TrailingWhitespace ]]
|
|
end
|
|
end
|
|
|
|
vim.api.nvim_create_autocmd("OptionSet", {
|
|
pattern = "list",
|
|
group = group,
|
|
callback = callback,
|
|
})
|
|
|
|
vim.api.nvim_create_autocmd("BufWinEnter", {
|
|
group = group,
|
|
callback = callback,
|
|
})
|
|
end
|
|
|
|
local function _create_autocmds()
|
|
local colorscheme_group = vim.api.nvim_create_augroup("ColorSchemeOverrides", { clear = true })
|
|
|
|
vim.api.nvim_create_autocmd("ColorScheme", {
|
|
callback = function()
|
|
vim.cmd [[
|
|
hi! ColorColumn cterm=NONE ctermbg=233
|
|
hi! CursorColumn cterm=NONE ctermbg=233
|
|
hi! CursorLine cterm=NONE ctermbg=233
|
|
hi! CursorLineNr cterm=bold ctermfg=White ctermbg=233
|
|
hi! LineNr ctermfg=DarkGray ctermbg=233
|
|
]]
|
|
end,
|
|
group = colorscheme_group,
|
|
})
|
|
|
|
vim.api.nvim_create_autocmd("ColorScheme", {
|
|
pattern = "default",
|
|
callback = function()
|
|
vim.cmd [[ hi! NormalFloat ctermfg=8 ]]
|
|
end,
|
|
group = colorscheme_group,
|
|
})
|
|
|
|
vim.api.nvim_create_autocmd("ColorScheme", {
|
|
pattern = "dracula",
|
|
callback = function()
|
|
vim.cmd [[ highlight CursorLineNr guibg=#44475a ]]
|
|
end,
|
|
group = colorscheme_group,
|
|
})
|
|
|
|
vim.api.nvim_create_autocmd("ColorScheme", {
|
|
pattern = "witchhazel",
|
|
callback = function()
|
|
vim.cmd [[
|
|
hi! default link LineNr CursorLineNr
|
|
hi! default link CursorLineNr CursorLine
|
|
]]
|
|
end,
|
|
group = colorscheme_group,
|
|
})
|
|
|
|
vim.api.nvim_create_autocmd("ColorScheme", {
|
|
pattern = "zaibatsu",
|
|
callback = function()
|
|
vim.cmd [[
|
|
hi! Pmenu ctermbg=8
|
|
hi! VertSplit ctermbg=8
|
|
]]
|
|
end,
|
|
group = colorscheme_group,
|
|
})
|
|
end
|
|
|
|
local function init_colors()
|
|
_highlight_trailing_whitespace()
|
|
_create_autocmds()
|
|
|
|
vim.cmd [[ color zaibatsu ]]
|
|
end
|
|
|
|
return {
|
|
init = init_colors
|
|
}
|