Feature to add a custom theme (#19)
Closes #21 Co-authored-by: Olivier Roques <olivier@oroques.dev>
This commit is contained in:
@@ -8,6 +8,7 @@ local g, o, wo = vim.g, vim.o, vim.wo
|
||||
local fmt = string.format
|
||||
local common = require('hardline.common')
|
||||
local bufferline = require('hardline.bufferline')
|
||||
local custom_colors = require('hardline.themes.custom_colors')
|
||||
local M = {}
|
||||
|
||||
-------------------- OPTIONS -------------------------------
|
||||
@@ -19,6 +20,19 @@ M.options = {
|
||||
separator = '|',
|
||||
},
|
||||
theme = 'default',
|
||||
custom_theme = {
|
||||
text = {gui = "NONE", cterm = "NONE", cterm16 = "NONE"},
|
||||
normal = {gui = "NONE", cterm = "NONE", cterm16 = "NONE"},
|
||||
insert = {gui = "NONE", cterm = "NONE", cterm16 = "NONE"},
|
||||
replace = {gui = "NONE", cterm = "NONE", cterm16 = "NONE"},
|
||||
inactive_comment = {gui = "NONE", cterm = "NONE", cterm16 = "NONE"},
|
||||
inactive_cursor = {gui = "NONE", cterm = "NONE", cterm16 = "NONE"},
|
||||
inactive_menu = {gui = "NONE", cterm = "NONE", cterm16 = "NONE"},
|
||||
visual = {gui = "NONE", cterm = "NONE", cterm16 = "NONE"},
|
||||
command = {gui = "NONE", cterm = "NONE", cterm16 = "NONE"},
|
||||
alt_text = {gui = "NONE", cterm = "NONE", cterm16 = "NONE"},
|
||||
warning = {gui = "NONE", cterm = "NONE", cterm16 = "NONE"},
|
||||
},
|
||||
sections = {
|
||||
{class = 'mode', item = require('hardline.parts.mode').get_item},
|
||||
{class = 'high', item = require('hardline.parts.git').get_item, hide = 80},
|
||||
@@ -182,8 +196,12 @@ local function set_theme()
|
||||
if type(M.options.theme) ~= 'string' then
|
||||
return
|
||||
end
|
||||
local theme = fmt('hardline.themes.%s', M.options.theme)
|
||||
M.options.theme = require(theme)
|
||||
if M.options.theme == 'custom' then
|
||||
M.options.theme = custom_colors.set(M.options.custom_theme)
|
||||
else
|
||||
local theme = fmt('hardline.themes.%s', M.options.theme)
|
||||
M.options.theme = require(theme)
|
||||
end
|
||||
end
|
||||
|
||||
local function set_hlgroups()
|
||||
|
||||
122
lua/hardline/themes/custom_colors.lua
Normal file
122
lua/hardline/themes/custom_colors.lua
Normal file
@@ -0,0 +1,122 @@
|
||||
-- Custom colorscheme
|
||||
|
||||
local M = {}
|
||||
|
||||
M.set = function(color_table)
|
||||
local inactive = {
|
||||
guifg = color_table.inactive_comment.gui,
|
||||
guibg = color_table.inactive_cursor.gui,
|
||||
ctermfg = color_table.inactive_comment.cterm,
|
||||
ctermbg = color_table.inactive_cursor.cterm,
|
||||
}
|
||||
|
||||
return {
|
||||
mode = {
|
||||
inactive = inactive,
|
||||
normal = {
|
||||
guifg = color_table.text.gui,
|
||||
guibg = color_table.normal.gui,
|
||||
ctermfg = color_table.text.cterm,
|
||||
ctermbg = color_table.normal.cterm,
|
||||
},
|
||||
insert = {
|
||||
guifg = color_table.text.gui,
|
||||
guibg = color_table.insert.gui,
|
||||
ctermfg = color_table.text.cterm,
|
||||
ctermbg = color_table.insert.cterm,
|
||||
},
|
||||
replace = {
|
||||
guifg = color_table.text.gui,
|
||||
guibg = color_table.replace.gui,
|
||||
ctermfg = color_table.text.cterm,
|
||||
ctermbg = color_table.replace.cterm,
|
||||
},
|
||||
visual = {
|
||||
guifg = color_table.text.gui,
|
||||
guibg = color_table.visual.gui,
|
||||
ctermfg = color_table.text.cterm,
|
||||
ctermbg = color_table.visual.cterm,
|
||||
},
|
||||
command = {
|
||||
guifg = color_table.text.gui,
|
||||
guibg = color_table.command.gui,
|
||||
ctermfg = color_table.text.cterm,
|
||||
ctermbg = color_table.command.cterm,
|
||||
},
|
||||
},
|
||||
low = {
|
||||
active = {
|
||||
guifg = color_table.alt_text.gui,
|
||||
guibg = color_table.inactive_cursor.gui,
|
||||
ctermfg = color_table.alt_text.cterm,
|
||||
ctermbg = color_table.inactive_cursor.cterm,
|
||||
},
|
||||
inactive = inactive,
|
||||
},
|
||||
med = {
|
||||
active = {
|
||||
guifg = color_table.alt_text.gui,
|
||||
guibg = color_table.inactive_cursor.gui,
|
||||
ctermfg = color_table.alt_text.cterm,
|
||||
ctermbg = color_table.inactive_cursor.cterm,
|
||||
},
|
||||
inactive = inactive,
|
||||
},
|
||||
high = {
|
||||
active = {
|
||||
guifg = color_table.alt_text.gui,
|
||||
guibg = color_table.inactive_menu.gui,
|
||||
ctermfg = color_table.alt_text.cterm,
|
||||
ctermbg = color_table.inactive_menu.cterm,
|
||||
},
|
||||
inactive = inactive,
|
||||
},
|
||||
error = {
|
||||
active = {
|
||||
guifg = color_table.text.gui,
|
||||
guibg = color_table.command.gui,
|
||||
ctermfg = color_table.text.cterm,
|
||||
ctermbg = color_table.command.cterm,
|
||||
},
|
||||
inactive = inactive,
|
||||
},
|
||||
warning = {
|
||||
active = {
|
||||
guifg = color_table.text.gui,
|
||||
guibg = color_table.warning.gui,
|
||||
ctermfg = color_table.text.cterm,
|
||||
ctermbg = color_table.warning.cterm,
|
||||
},
|
||||
inactive = inactive,
|
||||
},
|
||||
bufferline = {
|
||||
separator = inactive,
|
||||
current = {
|
||||
guifg = color_table.text.gui,
|
||||
guibg = color_table.normal.gui,
|
||||
ctermfg = color_table.text.cterm,
|
||||
ctermbg = color_table.normal.cterm,
|
||||
},
|
||||
current_modified = {
|
||||
guifg = color_table.text.gui,
|
||||
guibg = color_table.insert.gui,
|
||||
ctermfg = color_table.text.cterm,
|
||||
ctermbg = color_table.insert.cterm,
|
||||
},
|
||||
background = {
|
||||
guifg = color_table.normal.gui,
|
||||
guibg = color_table.text.gui,
|
||||
ctermfg = color_table.normal.cterm,
|
||||
ctermbg = color_table.text.cterm,
|
||||
},
|
||||
background_modified = {
|
||||
guifg = color_table.insert.gui,
|
||||
guibg = color_table.text.gui,
|
||||
ctermfg = color_table.insert.cterm,
|
||||
ctermbg = color_table.text.cterm,
|
||||
},
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
return M
|
||||
Reference in New Issue
Block a user