vim: move color definitions to a separate module
This commit is contained in:
parent
bdc50e41ea
commit
388bfe43db
3 changed files with 65 additions and 61 deletions
|
@ -1,27 +1,3 @@
|
||||||
local gui = vim.opt.termguicolors:get()
|
|
||||||
|
|
||||||
local function color(tbl)
|
|
||||||
if gui then return tbl.gui end
|
|
||||||
return tbl.index
|
|
||||||
end
|
|
||||||
|
|
||||||
base03 = color { index = 8, gui = '#002b36' }
|
|
||||||
base02 = color { index = 0, gui = '#073642' }
|
|
||||||
base01 = color { index = 10, gui = '#586e75' }
|
|
||||||
base00 = color { index = 11, gui = '#657b83' }
|
|
||||||
base0 = color { index = 12, gui = '#839496' }
|
|
||||||
base1 = color { index = 14, gui = '#93a1a1' }
|
|
||||||
base2 = color { index = 7, gui = '#eee8d5' }
|
|
||||||
base3 = color { index = 15, gui = '#fdf6e3' }
|
|
||||||
yellow = color { index = 3, gui = '#b58900' }
|
|
||||||
orange = color { index = 9, gui = '#cb4b16' }
|
|
||||||
red = color { index = 1, gui = '#dc322f' }
|
|
||||||
magenta = color { index = 5, gui = '#d33682' }
|
|
||||||
violet = color { index = 13, gui = '#6c71c4' }
|
|
||||||
blue = color { index = 4, gui = '#268bd2' }
|
|
||||||
cyan = color { index = 6, gui = '#2aa198' }
|
|
||||||
green = color { index = 2, gui = '#859900' }
|
|
||||||
|
|
||||||
local paste = {
|
local paste = {
|
||||||
function() return 'P' end,
|
function() return 'P' end,
|
||||||
color = { fg = base3, bg = yellow, gui = 'bold' },
|
color = { fg = base3, bg = yellow, gui = 'bold' },
|
||||||
|
@ -46,6 +22,8 @@ local fileformat = { 'fileformat', padding = { left = 0, right = 1}}
|
||||||
|
|
||||||
local progress = '%3l/%L|%-2v' -- line / total |column
|
local progress = '%3l/%L|%-2v' -- line / total |column
|
||||||
|
|
||||||
|
local C = require'fs.colors'.colors()
|
||||||
|
|
||||||
require('lualine').setup {
|
require('lualine').setup {
|
||||||
options = {
|
options = {
|
||||||
icons_enabled = true,
|
icons_enabled = true,
|
||||||
|
@ -53,17 +31,17 @@ require('lualine').setup {
|
||||||
section_separators = { left = '', right = '' },
|
section_separators = { left = '', right = '' },
|
||||||
theme = {
|
theme = {
|
||||||
normal = {
|
normal = {
|
||||||
a = { fg = base03, bg = blue, gui='bold' },
|
a = { fg = C.base03, bg = C.blue, gui='bold' },
|
||||||
b = { fg = base2, bg = base00 },
|
b = { fg = C.base03, bg = C.base00 },
|
||||||
c = { fg = base1, bg = base02 },
|
c = { fg = C.base1, bg = C.base02 },
|
||||||
},
|
},
|
||||||
insert = { a = { fg = base03, bg = green, gui = 'bold' } },
|
insert = { a = { fg = C.base03, bg = C.green, gui = 'bold' } },
|
||||||
visual = { a = { fg = base03, bg = magenta, gui = 'bold' } },
|
visual = { a = { fg = C.base03, bg = C.magenta, gui = 'bold' } },
|
||||||
replace = { a = { fg = base03, bg = red, gui = 'bold' } },
|
replace = { a = { fg = C.base03, bg = C.red, gui = 'bold' } },
|
||||||
inactive = {
|
inactive = {
|
||||||
a = { fg = base1, bg = base00 },
|
a = { fg = C.base1, bg = C.base00 },
|
||||||
b = { fg = base0, bg = base01 },
|
b = { fg = C.base0, bg = C.base01 },
|
||||||
c = { fg = base00, bg = base02 },
|
c = { fg = C.base01, bg = C.base02 },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -41,36 +41,23 @@ require'nvim-tree'.setup {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
base03 = { cterm = 8, gui = '#002b36' }
|
|
||||||
base02 = { cterm = 0, gui = '#073642' }
|
|
||||||
base01 = { cterm = 10, gui = '#586e75' }
|
|
||||||
base00 = { cterm = 11, gui = '#657b83' }
|
|
||||||
base0 = { cterm = 12, gui = '#839496' }
|
|
||||||
base1 = { cterm = 14, gui = '#93a1a1' }
|
|
||||||
base2 = { cterm = 7, gui = '#eee8d5' }
|
|
||||||
base3 = { cterm = 15, gui = '#fdf6e3' }
|
|
||||||
yellow = { cterm = 3, gui = '#b58900' }
|
|
||||||
orange = { cterm = 9, gui = '#cb4b16' }
|
|
||||||
red = { cterm = 1, gui = '#dc322f' }
|
|
||||||
magenta = { cterm = 5, gui = '#d33682' }
|
|
||||||
violet = { cterm = 13, gui = '#6c71c4' }
|
|
||||||
blue = { cterm = 4, gui = '#268bd2' }
|
|
||||||
cyan = { cterm = 6, gui = '#2aa198' }
|
|
||||||
green = { cterm = 2, gui = '#859900' }
|
|
||||||
|
|
||||||
local function highlight(group, color)
|
local function highlight(group, color)
|
||||||
vim.cmd(
|
if vim.opt.termguicolors:get() then
|
||||||
vim.fn.printf(
|
vim.cmd(vim.fn.printf('highlight %s guifg=%s', group, color))
|
||||||
'highlight %s ctermfg=%d guifg=%s',
|
else
|
||||||
group, color.cterm, color.gui))
|
vim.cmd(vim.fn.printf('highlight %s ctermfg=%d', group, color))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
highlight('NvimTreeSpecialFile' , base2 )
|
local C = require'fs.colors'.colors()
|
||||||
highlight('NvimTreeIndentMarker' , base01 )
|
|
||||||
highlight('NvimTreeGitStaged' , green )
|
highlight('NvimTreeSpecialFile' , C.base2 )
|
||||||
highlight('NvimTreeGitRenamed' , yellow )
|
highlight('NvimTreeIndentMarker' , C.base01 )
|
||||||
highlight('NvimTreeGitNew' , yellow )
|
highlight('NvimTreeGitStaged' , C.green )
|
||||||
highlight('NvimTreeGitDirty' , yellow )
|
highlight('NvimTreeGitRenamed' , C.yellow )
|
||||||
highlight('NvimTreeGitDeleted' , orange )
|
highlight('NvimTreeGitNew' , C.yellow )
|
||||||
highlight('NvimTreeGitMerge' , red )
|
highlight('NvimTreeGitDirty' , C.yellow )
|
||||||
|
highlight('NvimTreeGitDeleted' , C.orange )
|
||||||
|
highlight('NvimTreeGitMerge' , C.red )
|
||||||
|
|
||||||
|
|
39
config/nvim/lua/fs/colors.lua
Normal file
39
config/nvim/lua/fs/colors.lua
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
local function generate(tbl, gui)
|
||||||
|
local cterm, gui = {}, {}
|
||||||
|
for name, color in pairs(tbl) do
|
||||||
|
cterm[name] = color.cterm
|
||||||
|
gui[name] = color.gui
|
||||||
|
end
|
||||||
|
return cterm, gui
|
||||||
|
end
|
||||||
|
|
||||||
|
local cterm_colors, gui_colors = generate {
|
||||||
|
base03 = { cterm = 8, gui = '#002b36' },
|
||||||
|
base02 = { cterm = 0, gui = '#073642' },
|
||||||
|
base01 = { cterm = 10, gui = '#586e75' },
|
||||||
|
base00 = { cterm = 11, gui = '#657b83' },
|
||||||
|
base0 = { cterm = 12, gui = '#839496' },
|
||||||
|
base1 = { cterm = 14, gui = '#93a1a1' },
|
||||||
|
base2 = { cterm = 7, gui = '#eee8d5' },
|
||||||
|
base3 = { cterm = 15, gui = '#fdf6e3' },
|
||||||
|
yellow = { cterm = 3, gui = '#b58900' },
|
||||||
|
orange = { cterm = 9, gui = '#cb4b16' },
|
||||||
|
red = { cterm = 1, gui = '#dc322f' },
|
||||||
|
magenta = { cterm = 5, gui = '#d33682' },
|
||||||
|
violet = { cterm = 13, gui = '#6c71c4' },
|
||||||
|
blue = { cterm = 4, gui = '#268bd2' },
|
||||||
|
cyan = { cterm = 6, gui = '#2aa198' },
|
||||||
|
green = { cterm = 2, gui = '#859900' },
|
||||||
|
}
|
||||||
|
|
||||||
|
M.colors = function(gui)
|
||||||
|
if gui or vim.opt.termguicolors:get() then
|
||||||
|
return gui_colors
|
||||||
|
end
|
||||||
|
return cterm_colors
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
Loading…
Add table
Reference in a new issue