refactor: removed cterm colors from themes (#115)

This commit is contained in:
Shadman 2021-02-23 02:28:29 +06:00 committed by GitHub
parent d5ac4a8ffd
commit e59ac51ca9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 137 additions and 147 deletions

View File

@ -19,11 +19,6 @@
To create a custom theme you need to define a colorscheme for each of vim's modes. Each mode has a `fg` and `bg` field for every lualine section. To create a custom theme you need to define a colorscheme for each of vim's modes. Each mode has a `fg` and `bg` field for every lualine section.
You can add special effects with `gui`. You can add special effects with `gui`.
You can provide colors in two ways
1. As a table like `{'hexcode', 256_color_code}`
2. As a String like `'hexcode'`
Note : You can use `lualine.util.get_cterm_color(hex_color)` function to genarate 256_color_codes from hex_codes.
When method 2 is used 256_color_codes are genarated with that .
Adding theme is really easy in lua. Here is and example of a gruvbox theme. Adding theme is really easy in lua. Here is and example of a gruvbox theme.
@ -31,15 +26,12 @@ Adding theme is really easy in lua. Here is and example of a gruvbox theme.
local gruvbox = { } local gruvbox = { }
local colors = { local colors = {
-- color format { hex_color, 256_color_code} black = "#282828",
black = {"#282828", 235}, white = '#ebdbb2',
white = {'#ebdbb2', 223}, red = '#fb4934',
red = {'#fb4934', 203}, green = '#b8bb26',
green = {'#b8bb26', 143}, blue = '#83a598',
blue = {'#83a598', 108}, yellow = '#fe8019',
yellow = {'#fe8019', 209},
-- color format 'hex_color'
gray = '#a89984', gray = '#a89984',
darkgray = '#3c3836', darkgray = '#3c3836',
lightgray = '#504945', lightgray = '#504945',

View File

@ -8,19 +8,17 @@ local section_highlight_map = {x = 'c', y = 'b', z = 'a'}
local function highlight (name, foreground, background, gui) local function highlight (name, foreground, background, gui)
local command = { 'highlight', name, } local command = { 'highlight', name, }
if foreground then if foreground and foreground ~= 'none' then
table.insert(command, 'ctermfg=' .. (foreground[2] or table.insert(command, 'ctermfg=' .. utils_colors.get_cterm_color(foreground))
(foreground ~= 'none' and utils_colors.get_cterm_color(foreground)) or 'none')) table.insert(command, 'guifg=' .. foreground)
table.insert(command, 'guifg=' .. (foreground[1] or foreground))
end end
if background then if background and background ~= 'none' then
table.insert(command, 'ctermbg=' .. (background[2] or table.insert(command, 'ctermbg=' .. utils_colors.get_cterm_color(background))
(background ~= 'none' and utils_colors.get_cterm_color(background)) or 'none')) table.insert(command, 'guibg=' .. background)
table.insert(command, 'guibg=' .. (background[1] or background))
end end
if gui then if gui then
table.insert(command, 'cterm=' .. (gui or 'none')) table.insert(command, 'cterm=' .. gui )
table.insert(command, 'gui=' .. (gui or 'none')) table.insert(command, 'gui=' .. gui )
end end
vim.cmd(table.concat(command, ' ')) vim.cmd(table.concat(command, ' '))
utils.save_highlight(name) utils.save_highlight(name)

View File

@ -5,22 +5,22 @@
local M = {} local M = {}
local colors = { local colors = {
black = { '#000000', 0 }, black = '#000000',
maroon = { '#800000', 1 }, maroon = '#800000',
green = { '#008000', 2 }, green = '#008000',
olive = { '#808000', 3 }, olive = '#808000',
navy = { '#000080', 4 }, navy = '#000080',
purple = { '#800080', 5 }, purple = '#800080',
teal = { '#008080', 6 }, teal = '#008080',
silver = { '#c0c0c0', 7 }, silver = '#c0c0c0',
gray = { '#808080', 8}, gray = '#808080',
red = { '#ff0000', 9 }, red = '#ff0000',
lime = { '#00ff00', 10 }, lime = '#00ff00',
yellow = { '#ffff00', 11 }, yellow = '#ffff00',
blue = { '#0000ff', 12 }, blue = '#0000ff',
fuchsia = { '#ff00ff', 13 }, fuchsia = '#ff00ff',
aqua = { '#00ffff', 14 }, aqua = '#00ffff',
white = { '#ffffff', 15 }, white = '#ffffff',
} }
M.normal = { M.normal = {

View File

@ -5,15 +5,15 @@
local dracula = {} local dracula = {}
local colors = { local colors = {
grey = {"#44475a", 238}, grey = "#44475a",
light_gray = {"#5f6a8e", 60 }, light_gray = "#5f6a8e",
orange = {"#ffb86c", 215}, orange = "#ffb86c",
purple = {"#bd93f9", 141}, purple = "#bd93f9",
red = {"#ff5555", 203}, red = "#ff5555",
yellow = {"#f1fa8c", 228}, yellow = "#f1fa8c",
green = {"#50fa7b", 84 }, green = "#50fa7b",
white = {"#f8f8f2", 255}, white = "#f8f8f2",
black = {"#282a36", 236}, black = "#282a36",
} }
dracula.normal = { dracula.normal = {

View File

@ -4,16 +4,16 @@
local forest_night = {} local forest_night = {}
local colors = { local colors = {
bg0 = {"#323d43", 237}, bg0 = "#323d43",
bg1 = {"#3c474d", 238}, bg1 = "#3c474d",
bg3 = {"#505a60", 240}, bg3 = "#505a60",
fg = {"#d8caac", 187}, fg = "#d8caac",
aqua = {"#87c095", 108}, aqua = "#87c095",
green = {"#a7c080", 144}, green = "#a7c080",
orange = {"#e39b7b", 180}, orange = "#e39b7b",
purple = {"#d39bb6", 181}, purple = "#d39bb6",
red = {"#e68183", 174}, red = "#e68183",
grey1 = {"#868d80", 102}, grey1 = "#868d80",
} }
forest_night.normal = { forest_night.normal = {

View File

@ -4,16 +4,16 @@
local gruvbox = {} local gruvbox = {}
local colors = { local colors = {
black = {"#282828", 235}, black = "#282828",
white = {'#ebdbb2', 223}, white = '#ebdbb2',
red = {'#fb4934', 203}, red = '#fb4934',
green = {'#b8bb26', 143}, green = '#b8bb26',
blue = {'#83a598', 108}, blue = '#83a598',
yellow = {'#fe8019', 209}, yellow = '#fe8019',
gray = {'#a89984', 144}, gray = '#a89984',
darkgray = {'#3c3836', 237}, darkgray = '#3c3836',
lightgray = {'#504945', 239}, lightgray = '#504945',
inactivegray = {'#7c6f64', 242}, inactivegray = '#7c6f64',
} }
gruvbox.normal = { gruvbox.normal = {

View File

@ -5,15 +5,15 @@
local molokai = {} local molokai = {}
local colors = { local colors = {
black = { '#232526', 233 }, black = '#232526',
gray = { '#808080', 244 }, gray = '#808080',
white = { '#f8f8f2', 234 }, white = '#f8f8f2',
cyan = { '#66d9ef', 81 }, cyan = '#66d9ef',
green = { '#a6e22e', 118 }, green = '#a6e22e',
orange = { '#ef5939', 166 }, orange = '#ef5939',
pink = { '#f92672', 161 }, pink = '#f92672',
red = { '#ff0000', 160 }, red = '#ff0000',
yellow = { '#e6db74', 229 }, yellow = '#e6db74',
} }
molokai.normal = { molokai.normal = {

View File

@ -4,13 +4,13 @@
local nord = {} local nord = {}
local colors = { local colors = {
nord1 = {"#3B4252", 237}, nord1 = "#3B4252",
nord3 = {"#4C566A", 240}, nord3 = "#4C566A",
nord5 = {"#E5E9F0", 254}, nord5 = "#E5E9F0",
nord6 = {"#ECEFF4", 255}, nord6 = "#ECEFF4",
nord7 = {"#8FBCBB", 158}, nord7 = "#8FBCBB",
nord8 = {"#88C0D0", 159}, nord8 = "#88C0D0",
nord13 = {"#EBCB8B", 221}, nord13 = "#EBCB8B",
} }
nord.normal = { nord.normal = {

View File

@ -5,17 +5,17 @@
local M = {} local M = {}
local colors = { local colors = {
blue = { '#61afef', 75 }, blue = '#61afef',
green = { '#98c379', 76 }, green = '#98c379',
purple = { '#c678dd', 176 }, purple = '#c678dd',
red1 = { '#e06c75', 168 }, red1 = '#e06c75',
red2 = { '#be5046', 168 }, red2 = '#be5046',
yellow = { '#e5c07b', 180 }, yellow = '#e5c07b',
fg = { '#abb2bf', 145 }, fg = '#abb2bf',
bg = { '#282c34', 235 }, bg = '#282c34',
gray1 = { '#5c6370', 241 }, gray1 = '#5c6370',
gray2 = { '#2c323d', 235 }, gray2 = '#2c323d',
gray3 = { '#3e4452', 240 }, gray3 = '#3e4452',
} }
M.normal = { M.normal = {

View File

@ -5,17 +5,17 @@
local M = {} local M = {}
local colors = { local colors = {
blue = { '#61afef', 75 }, blue = '#61afef',
green = { '#98c379', 35 }, green = '#98c379',
purple = { '#c678dd', 176 }, purple = '#c678dd',
red1 = { '#e06c75', 168 }, red1 = '#e06c75',
red2 = { '#be5046', 168 }, red2 = '#be5046',
yellow = { '#e5c07b', 180 }, yellow = '#e5c07b',
fg = { '#494b53', 238 }, fg = '#494b53',
bg = { '#fafafa', 255 }, bg = '#fafafa',
gray1 = { '#494b53', 238 }, gray1 = '#494b53',
gray2 = { '#f0f0f0', 255 }, gray2 = '#f0f0f0',
gray3 = { '#d0d0d0', 250 }, gray3 = '#d0d0d0',
} }
M.normal = { M.normal = {

View File

@ -4,21 +4,21 @@
local powerline = { } local powerline = { }
local Colors = { local Colors = {
white = {'#ffffff', 231}, white = '#ffffff',
darkestgreen = {'#005f00', 22 }, darkestgreen = '#005f00',
brightgreen = {'#afdf00', 148}, brightgreen = '#afdf00',
darkestcyan = {'#005f5f', 23 }, darkestcyan = '#005f5f',
mediumcyan = {'#87dfff', 117}, mediumcyan = '#87dfff',
darkestblue = {'#005f87', 24 }, darkestblue = '#005f87',
darkred = {'#870000', 88 }, darkred = '#870000',
brightred = {'#df0000', 160}, brightred = '#df0000',
brightorange = {'#ff8700', 214}, brightorange = '#ff8700',
gray1 = {'#262626', 235}, gray1 = '#262626',
gray2 = {'#303030', 236}, gray2 = '#303030',
gray4 = {'#585858', 240}, gray4 = '#585858',
gray5 = {'#606060', 241}, gray5 = '#606060',
gray7 = {'#9e9e9e', 245}, gray7 = '#9e9e9e',
gray10 = {'#f0f0f0', 252}, gray10 = '#f0f0f0',
} }
powerline.normal = { powerline.normal = {

View File

@ -5,22 +5,22 @@
local M = {} local M = {}
local colors = { local colors = {
base03 = { '#242424', 235 }, base03 = '#242424',
base023 = { '#353535', 236 }, base023 = '#353535',
base02 = { '#444444', 238 }, base02 = '#444444',
base01 = { '#585858', 240 }, base01 = '#585858',
base00 = { '#666666', 242 }, base00 = '#666666',
base0 = { '#808080', 244 }, base0 = '#808080',
base1 = { '#969696', 247 }, base1 = '#969696',
base2 = { '#a8a8a8', 248 }, base2 = '#a8a8a8',
base3 = { '#d0d0d0', 252 }, base3 = '#d0d0d0',
yellow = { '#cae682', 180 }, yellow = '#cae682',
orange = { '#e5786d', 173 }, orange = '#e5786d',
red = { '#e5786d', 203 }, red = '#e5786d',
magenta = { '#f2c68a', 216 }, magenta = '#f2c68a',
blue = { '#8ac6f2', 117 }, blue = '#8ac6f2',
cyan = { '#8ac6f2', 117 }, cyan = '#8ac6f2',
green = { '#95e454', 119 }, green = '#95e454',
} }
M.normal = { M.normal = {