From e7b8f8f44a63489aa800682b370b45e132a69029 Mon Sep 17 00:00:00 2001 From: Michael Chris Lopez Date: Fri, 5 Nov 2021 17:03:11 +0800 Subject: [PATCH] add runner for lightline --- lua/zenbones/shipwright/init.lua | 2 +- lua/zenbones/shipwright/runners/lightline.lua | 92 +++++++++++++++++++ 2 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 lua/zenbones/shipwright/runners/lightline.lua diff --git a/lua/zenbones/shipwright/init.lua b/lua/zenbones/shipwright/init.lua index c70cfcb..3387153 100644 --- a/lua/zenbones/shipwright/init.lua +++ b/lua/zenbones/shipwright/init.lua @@ -55,7 +55,7 @@ local function make_runners(config) end M.run = function() - local runner_files = { "alacritty", "kitty", "wezterm", "lualine" } + local runner_files = { "alacritty", "kitty", "wezterm", "lualine", "lightline" } local colorschemes = { { name = "zenbones" }, { name = "neobones" }, diff --git a/lua/zenbones/shipwright/runners/lightline.lua b/lua/zenbones/shipwright/runners/lightline.lua new file mode 100644 index 0000000..6ba07bf --- /dev/null +++ b/lua/zenbones/shipwright/runners/lightline.lua @@ -0,0 +1,92 @@ +local template = [[let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} + +let s:p.normal.left = [ [ "$common_fg", "$normal_a_bg", "bold" ], [ "$common_fg", "$normal_b_bg" ] ] +let s:p.normal.middle = [ [ "$normal_c_fg", "$normal_c_bg" ] ] +let s:p.normal.right = [ [ "$common_fg", "$normal_b_bg" ], [ "$common_fg", "$normal_b_bg" ] ] +let s:p.normal.warning = [ [ "$warning_fg", "$warning_bg" ] ] +let s:p.normal.error = [ [ "$error_fg", "$error_bg" ] ] + +let s:p.inactive.left = [ [ "$inactive_fg", "$inactive_bg" ], [ "$inactive_fg", "$inactive_bg" ] ] +let s:p.inactive.middle = [ [ "$inactive_fg", "$inactive_bg" ] ] +let s:p.inactive.right = [ [ "$inactive_fg", "$inactive_bg" ] ] + +let s:p.insert.left = [ [ "$common_fg", "$insert_a_bg", "bold" ], [ "$common_fg", "$normal_b_bg" ] ] +let s:p.replace.left = [ [ "$common_fg", "$replace_a_bg", "bold" ], [ "$common_fg", "$normal_b_bg" ] ] +let s:p.visual.left = [ [ "$common_fg", "$visual_a_bg", "bold" ], [ "$common_fg", "$normal_b_bg" ] ] + +let s:p.tabline.left = [ [ "$tabline_left_fg", "$tabline_left_bg", "italic" ] ] +let s:p.tabline.middle = [ [ "$inactive_fg", "$inactive_bg" ] ] +let s:p.tabline.right = [ [ "$tabline_right_fg", "$tabline_right_bg" ] ] +let s:p.tabline.tabsel = [ [ "$tabsel_fg", "$tabsel_bg", "bold" ] ] + +let g:lightline#colorscheme#$name#palette = lightline#colorscheme#fill(s:p) +]] + +local helpers = require "shipwright.transform.helpers" + +local check_keys = { + "name", + "common_fg", + "inactive_bg", + "inactive_fg", + "normal_a_bg", + "normal_b_bg", + "normal_c_bg", + "normal_c_fg", + "insert_a_bg", + "visual_a_bg", + "replace_a_bg", + "tabline_left_bg", + "tabline_left_fg", + "tabline_right_bg", + "tabline_right_fg", + "tabsel_bg", + "tabsel_fg", + "warning_bg", + "warning_fg", + "error_bg", + "error_fg", +} + +local function transform(colors) + for _, key in ipairs(check_keys) do + assert(colors[key], "lightline colors table missing key: " .. key) + end + + local text = helpers.apply_template(template, colors) + return helpers.split_newlines(text) +end + +local function specs_to_colors(specs) + return { + name = name, + common_fg = specs.Folded.fg.hex, + inactive_bg = specs.StatusLineNC.bg.hex, + inactive_fg = specs.StatusLineNC.fg.hex, + normal_a_bg = specs.PmenuSbar.bg.hex, + normal_b_bg = specs.PmenuSel.bg.hex, + normal_c_bg = specs.StatusLine.bg.hex, + normal_c_fg = specs.StatusLine.fg.hex, + insert_a_bg = specs.DiffText.bg.hex, + visual_a_bg = specs.Visual.bg.hex, + replace_a_bg = specs.DiffDelete.bg.hex, + tabline_left_bg = specs.PmenuSel.bg.hex, + tabline_left_fg = specs.Normal.fg.hex, + tabline_right_bg = specs.PmenuSel.bg.hex, + tabline_right_fg = specs.Normal.fg.hex, + tabsel_bg = specs.Normal.bg.hex, + tabsel_fg = specs.Normal.fg.hex, + warning_bg = specs.DiagnosticVirtualTextWarn.bg.hex, + warning_fg = specs.DiagnosticVirtualTextWarn.fg.hex, + error_bg = specs.DiagnosticVirtualTextError.bg.hex, + error_fg = specs.DiagnosticVirtualTextError.fg.hex, + } +end + +run( + specs, + specs_to_colors, + transform, + { prepend, [[" This file is auto-generated by shipwright.nvim]] }, + { overwrite, string.format("autoload/lightline/colorscheme/%s.vim", name) } +)