From c623e9ff93ef0a45919d945c6afd46c509190347 Mon Sep 17 00:00:00 2001 From: Michael Chris Lopez Date: Sat, 6 Nov 2021 13:06:54 +0800 Subject: [PATCH] replace util interpolation with shipwright --- lua/zenbones/shipwright/runners/iterm.lua | 16 ++++++++-------- lua/zenbones/util.lua | 7 ------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/lua/zenbones/shipwright/runners/iterm.lua b/lua/zenbones/shipwright/runners/iterm.lua index 38a3be5..ed7023c 100644 --- a/lua/zenbones/shipwright/runners/iterm.lua +++ b/lua/zenbones/shipwright/runners/iterm.lua @@ -1,20 +1,18 @@ -local util = require "zenbones.util" - local key_template = [[ - ${k} Color + $k Color ]] local color_template = [[ Alpha Component 1 Blue Component - ${b} + $b Color Space sRGB Green Component - ${g} + $g Red Component - ${r} + $r ]] local start_template = [[ @@ -27,6 +25,8 @@ local end_template = [[ ]] +local helpers = require "shipwright.transform.helpers" + local function hex_to_rgb(hex) local _, r, g, b = hex:match "(.)(..)(..)(..)" r, g, b = @@ -37,9 +37,9 @@ local function hex_to_rgb(hex) end local function key_to_xml(key, color) - local xml = util.interp(key_template, { k = key }) + local xml = helpers.apply_template(key_template, { k = key }) local rgb = hex_to_rgb(color.hex) - xml = xml .. util.interp(color_template, rgb) + xml = xml .. helpers.apply_template(color_template, rgb) return xml end diff --git a/lua/zenbones/util.lua b/lua/zenbones/util.lua index b14e301..7225fcc 100644 --- a/lua/zenbones/util.lua +++ b/lua/zenbones/util.lua @@ -1,12 +1,5 @@ local M = {} --- got from http://lua-users.org/wiki/StringInterpolation -function M.interp(s, tab) - return (s:gsub("($%b{})", function(w) - return tab[w:sub(3, -2)] or w - end)) -end - function M.apply_colorscheme() local colors_name = vim.api.nvim_get_var "colors_name" package.loaded[colors_name] = nil