1
0
Fork 0
dot/nvim/colors/basic.lua

346 lines
12 KiB
Lua

-- basic neovim colorscheme template
--
-- A simple neovim colorscheme template that defines highlight groups
-- from a list of 8 colors.
-- colors ----------------------------------------------------------------------
local C = {
{ 0, "#292526" }, -- black
{ 1, "#ff404f" }, -- red
{ 2, "#00a147" }, -- green
{ 3, "#e06e00" }, -- orange
{ 4, "#6185ff" }, -- blue
{ 5, "#ff3e8b" }, -- magenta
{ 6, "#0095d7" }, -- cyan
{ 7, "#e3e0e1" }, -- white
{ 8, "#958a8d" }, -- black
{ 9, "#ffb3b6" }, -- red
{ 10, "#00e46a" }, -- green
{ 11, "#ffb598" }, -- orange
{ 12, "#b8c3ff" }, -- blue
{ 13, "#ffb1c5" }, -- magenta
{ 14, "#92ccff" }, -- cyan
{ 15, "#f4f3f3" }, -- white
}
local black_c = C[1]
local red_c = C[2]
local green_c = C[3]
local orange_c = C[4]
local blue_c = C[5]
local magenta_c = C[6]
local cyan_c = C[7]
local white_c = C[8]
-- init ------------------------------------------------------------------------
vim.cmd.highlight("clear")
if vim.fn.exists("syntax_on") then
vim.cmd.syntax("reset")
end
vim.opt.background = "dark"
vim.g.colors_name = "basic"
if
vim.env.TERM == "linux" or
vim.env.TERM == "screen" or
vim.env.TERM == "screen.linux"
then
vim.opt.termguicolors = false
else
vim.opt.termguicolors = true
end
local tty = vim.env.TERM == "linux" or vim.env.TERM == "screen.linux"
for _, v in ipairs(C) do
local key = ("terminal_color_%i"):format(v[1])
vim.g[key] = v[2]
end
-- highlights ------------------------------------------------------------------
local H = {}
function H:new(o)
o = o or {}
setmetatable(o, self)
self.__index = self
return o
end
function H:fg(c)
self.ctermfg = c[1]
self.fg = c[2]
if c[1] == 4 and tty then
self.bold = true
end
return self
end
function H:bg(c)
self.ctermbg = c[1]
self.bg = c[2]
if c[1] == 4 and tty then
self.bold = true
end
return self
end
function H:attr(a)
if tty then
if a == "underline" then return self end
end
self[a] = true
return self
end
local fg_c = white_c
local bg_c = black_c
local accent_c = magenta_c
local dimmed_c = blue_c
local function set_hl(group, def) vim.api.nvim_set_hl(0, group, def) end
-- normal ----------------------------------------------------------------------
local normal_h = {}
set_hl("Normal", normal_h)
set_hl("NormalNC", normal_h)
-- tui -------------------------------------------------------------------------
local tui_normal_h = {}
local tui_accent_h = H:new():fg(accent_c)
local tui_dimmed_h = H:new():fg(dimmed_c)
set_hl("StatusLine", tui_dimmed_h)
set_hl("StatusLineNC", tui_dimmed_h)
set_hl("TabLine", tui_dimmed_h)
set_hl("TabLineFill", tui_dimmed_h)
set_hl("TabLineSel", tui_accent_h)
set_hl("WinBar", tui_accent_h)
set_hl("WinBarNC", tui_dimmed_h)
set_hl("WinSeparator", tui_dimmed_h)
set_hl("LineNr", tui_accent_h)
set_hl("LineNrAbove", tui_dimmed_h)
set_hl("LineNrBelow", tui_dimmed_h)
set_hl("SignColumn", tui_dimmed_h)
set_hl("FoldColumn", tui_dimmed_h)
set_hl("WildMenu", tui_accent_h)
-- float -----------------------------------------------------------------------
local float_normal_h = H:new():fg(bg_c):bg(fg_c)
local float_accent_h = H:new():fg(accent_c):bg(fg_c)
set_hl("NormalFloat", float_normal_h)
set_hl("FloatBorder", float_normal_h)
set_hl("FloatTitle", float_accent_h)
-- menu ------------------------------------------------------------------------
local menu_normal_h = H:new():fg(bg_c):bg(fg_c)
local menu_accent_h = H:new():fg(accent_c):bg(fg_c)
local menu_accent_r_h = H:new():fg(accent_c):bg(fg_c):attr("reverse")
set_hl("Pmenu", menu_normal_h)
set_hl("PmenuSel", menu_accent_h)
set_hl("PmenuKind", menu_normal_h)
set_hl("PmenuKindSel", menu_accent_h)
set_hl("PmenuExtra", menu_normal_h)
set_hl("PmenuExtraSel", menu_accent_h)
set_hl("PmenuSbar", menu_accent_h)
set_hl("PmenuThumb", menu_accent_r_h)
-- messages --------------------------------------------------------------------
local message_normal_h = {}
local message_accent_h = H:new():fg(accent_c)
local message_error_h = H:new():fg(red_c)
local message_warn_h = H:new():fg(orange_c)
set_hl("MsgArea", message_normal_h)
set_hl("MsgSeparator", message_normal_h)
set_hl("ModeMsg", message_accent_h)
set_hl("MoreMsg", message_accent_h)
set_hl("WarningMsg", message_warn_h)
set_hl("ErrorMsg", message_error_h)
set_hl("Question", message_accent_h)
set_hl("Title", message_accent_h)
-- buffer ----------------------------------------------------------------------
local buffer_normal_h = H:new():fg(dimmed_c)
local buffer_normal_bg_h = H:new():bg(dimmed_c)
local buffer_accent_h = H:new():fg(accent_c)
set_hl("Conceal", buffer_normal_h)
set_hl("NonText", buffer_normal_h)
set_hl("EndOfBuffer", buffer_normal_h)
set_hl("Whitespace", buffer_normal_h)
set_hl("Folded", buffer_normal_h)
set_hl("SpecialKey", buffer_accent_h)
set_hl("ColorColumn", buffer_normal_bg_h)
-- cursor ----------------------------------------------------------------------
local cursor_normal_h = H:new():attr("reverse")
set_hl("CursorLine", cursor_normal_h)
set_hl("CursorLineNr", cursor_normal_h)
set_hl("CursorLineSign", cursor_normal_h)
set_hl("CursorLineFold", cursor_normal_h)
set_hl("CursorColumn", cursor_normal_h)
set_hl("QuickFixLine", cursor_normal_h)
set_hl("Cursor", cursor_normal_h)
set_hl("lCursor", cursor_normal_h)
set_hl("CursorIM", cursor_normal_h)
set_hl("TermCursor", cursor_normal_h)
set_hl("TermCursorNC", cursor_normal_h)
-- match -----------------------------------------------------------------------
local match_normal_h = H:new():fg(black_c):bg(orange_c)
local match_cur_h = H:new():fg(black_c):bg(cyan_c)
local match_reverse_h = H:new():fg(black_c):bg(orange_c):attr("reverse")
set_hl("Search", match_normal_h)
set_hl("Substitute", match_normal_h)
set_hl("IncSearch", match_normal_h)
set_hl("CurSearch", match_cur_h)
set_hl("MatchParen", match_reverse_h)
-- selection -------------------------------------------------------------------
local selection_normal_h = H:new():fg(black_c):bg(magenta_c)
set_hl("visual", selection_normal_h)
set_hl("visualnos", selection_normal_h)
-- diff ------------------------------------------------------------------------
local diff_add_h = H:new():fg(green_c)
local diff_change_h = H:new():fg(orange_c)
local diff_delete_h = H:new():fg(red_c)
local diff_text_h = H:new():fg(orange_c):attr("underline")
set_hl("DiffAdd", diff_add_h)
set_hl("DiffChange", diff_change_h)
set_hl("DiffDelete", diff_delete_h)
set_hl("DiffText", diff_text_h)
-- spell -----------------------------------------------------------------------
local spell_error_h = H:new():fg(red_c):attr("underline")
local spell_warn_h = H:new():fg(orange_c):attr("underline")
set_hl("SpellBad", spell_error_h)
set_hl("SpellCap", spell_warn_h)
set_hl("SpellLocal", spell_warn_h)
set_hl("SpellRare", spell_warn_h)
-- diagnostic ------------------------------------------------------------------
local diagnostic_error_h = H:new():fg(red_c)
local diagnostic_warn_h = H:new():fg(orange_c)
local diagnostic_info_h = H:new():fg(blue_c)
local diagnostic_hint_h = H:new():fg(white_c)
local diagnostic_ok_h = H:new():fg(green_c)
local diagnostic_error_u_h = H:new():fg(red_c):attr("underline")
local diagnostic_warn_u_h = H:new():fg(orange_c):attr("underline")
local diagnostic_info_u_h = H:new():fg(blue_c):attr("underline")
local diagnostic_hint_u_h = H:new():fg(white_c):attr("underline")
local diagnostic_ok_u_h = H:new():fg(green_c):attr("underline")
set_hl("DiagnosticError", diagnostic_error_h)
set_hl("DiagnosticWarn", diagnostic_warn_h)
set_hl("DiagnosticInfo", diagnostic_info_h)
set_hl("DiagnosticHint", diagnostic_hint_h)
set_hl("DiagnosticOk", diagnostic_ok_h)
set_hl("DiagnosticVirtualError", diagnostic_error_h)
set_hl("DiagnosticVirtualWarn", diagnostic_warn_h)
set_hl("DiagnosticVirtualInfo", diagnostic_info_h)
set_hl("DiagnosticVirtualHint", diagnostic_hint_h)
set_hl("DiagnosticVirtualOk", diagnostic_ok_h)
set_hl("DiagnosticUnderlineError", diagnostic_error_u_h)
set_hl("DiagnosticUnderlineWarn", diagnostic_warn_u_h)
set_hl("DiagnosticUnderlineInfo", diagnostic_info_u_h)
set_hl("DiagnosticUnderlineHint", diagnostic_hint_u_h)
set_hl("DiagnosticUnderlineOk", diagnostic_ok_u_h)
set_hl("DiagnosticFloatingError", diagnostic_error_h)
set_hl("DiagnosticFloatingWarn", diagnostic_warn_h)
set_hl("DiagnosticFloatingInfo", diagnostic_info_h)
set_hl("DiagnosticFloatingHint", diagnostic_hint_h)
set_hl("DiagnosticFloatingOk", diagnostic_ok_h)
set_hl("DiagnosticSingError", diagnostic_error_h)
set_hl("DiagnosticSingWarn", diagnostic_warn_h)
set_hl("DiagnosticSingInfo", diagnostic_info_h)
set_hl("DiagnosticSingHint", diagnostic_hint_h)
set_hl("DiagnosticSingOk", diagnostic_ok_h)
set_hl("DiagnosticDeprecated", diagnostic_hint_u_h)
set_hl("DiagnosticUnnecessary", diagnostic_hint_u_h)
-- misc ------------------------------------------------------------------------
set_hl("Directory", H:new():fg(blue_c):attr("bold"))
-- syntax ----------------------------------------------------------------------
local syntax_normal_h = {}
local syntax_comment_h = H:new():fg(blue_c):attr("bold")
-- local syntax_constant_h = H:new():fg(magenta_c)
-- local syntax_identifier_h = H:new():fg(white_c)
-- local syntax_statement_h = H:new():fg(magenta_c)
-- local syntax_preproc_h = H:new():fg(magenta_c)
-- local syntax_type_h = H:new():fg(green_c)
-- local syntax_special_h = H:new():fg(cyan_c)
local syntax_constant_h = H:new():fg(red_c)
local syntax_identifier_h = H:new():fg(cyan_c)
local syntax_statement_h = H:new():fg(orange_c)
local syntax_preproc_h = H:new():fg(magenta_c)
local syntax_type_h = H:new():fg(green_c)
local syntax_special_h = H:new():fg(orange_c)
local syntax_underline_h = H:new():attr("underline")
local syntax_ignore_h = H:new():fg(black_c)
local syntax_error_h = H:new():fg(black_c):bg(red_c)
local syntax_warn_h = H:new():fg(black_c):bg(orange_c)
local syntax_italic_h = H:new():attr("italic")
local syntax_bold_h = H:new():attr("bold")
local syntax_bolditalic_h = H:new():attr("bold"):attr("italic")
set_hl("Comment", syntax_comment_h)
set_hl("Constant", syntax_constant_h)
set_hl("String", syntax_constant_h)
set_hl("Character", syntax_constant_h)
set_hl("Number", syntax_constant_h)
set_hl("Boolean", syntax_constant_h)
set_hl("Float", syntax_constant_h)
set_hl("Identifier", syntax_identifier_h)
set_hl("Function", syntax_identifier_h)
set_hl("Statement", syntax_statement_h)
set_hl("Conditional", syntax_statement_h)
set_hl("Repeat", syntax_statement_h)
set_hl("Label", syntax_statement_h)
set_hl("Operator", syntax_statement_h)
set_hl("Keyword", syntax_statement_h)
set_hl("Exception", syntax_statement_h)
set_hl("PreProc", syntax_preproc_h)
set_hl("Include", syntax_preproc_h)
set_hl("Define", syntax_preproc_h)
set_hl("Macro", syntax_preproc_h)
set_hl("PreCondit", syntax_preproc_h)
set_hl("Type", syntax_type_h)
set_hl("StorageClass", syntax_type_h)
set_hl("Structure", syntax_type_h)
set_hl("Typedef", syntax_type_h)
set_hl("Special", syntax_special_h)
set_hl("SpecialChar", syntax_special_h)
set_hl("Tag", syntax_special_h)
set_hl("Delimiter", syntax_special_h)
set_hl("SpecialComment", syntax_special_h)
set_hl("Debug", syntax_special_h)
set_hl("Underlined", syntax_underline_h)
set_hl("Ignore", syntax_ignore_h)
set_hl("Error", syntax_error_h)
set_hl("Todo", syntax_warn_h)
set_hl("Italic", syntax_italic_h)
set_hl("Bold", syntax_bold_h)
set_hl("BoldItalic", syntax_bolditalic_h)
-- markdown --------------------------------------------------------------------
local markdown_label_h = H:new():fg(magenta_c)
local markdown_delimiter_h = H:new():fg(blue_c):attr("bold")
local markdown_underline_h = H:new():fg(blue_c):attr("underline"):attr("bold")
set_hl("markdownLabel", markdown_label_h)
set_hl("markdownDelimiter", markdown_delimiter_h)
set_hl("markdownUnderlined", markdown_underline_h)