Move local function out to broader scope

This commit is contained in:
Iron_E 2020-07-15 21:55:06 -04:00
parent f88f0d1ead
commit 52531761ef
No known key found for this signature in database
GPG Key ID: B0B37DE7EDC2335F
1 changed files with 12 additions and 12 deletions

View File

@ -26,6 +26,16 @@ local BIT_16 = 3
local BIT_256 = 2 local BIT_256 = 2
local HEX = 1 local HEX = 1
-- This function appends `selected_attributes` to the end of some `command`.
local function append_style(command, selected_attributes)
command[#command + 1] = ' cterm=' .. selected_attributes
-- If we're using hex populate the gui* attr args.
if use_hex_and_256 then command[#command + 1] =
' gui=' .. selected_attributes
end
end
-- Get the color value of a color variable, or "NONE" as a default. -- Get the color value of a color variable, or "NONE" as a default.
local function get(color, index) local function get(color, index)
if type(color) == 'table' and color[index] then if type(color) == 'table' and color[index] then
@ -64,28 +74,18 @@ local function highlight(highlight_group, attributes) -- {{{ †
.. ' ctermfg=' .. get(fg, BIT_16) .. ' ctermfg=' .. get(fg, BIT_16)
end end
-- This function appends `selected_attributes` to the end of the `highlight_cmd`.
local function append_style(selected_attributes)
highlight_cmd[#highlight_cmd + 1] = ' cterm=' .. selected_attributes
-- If we're using hex populate the gui* attr args.
if use_hex_and_256 then highlight_cmd[#highlight_cmd + 1] =
' gui=' .. selected_attributes
end
end
if type(style) == 'table' then if type(style) == 'table' then
-- Concat all of the entries together with a comma between. -- Concat all of the entries together with a comma between.
local style_all = table.concat(style, ',') local style_all = table.concat(style, ',')
-- There will always be a cterm attr arg. -- There will always be a cterm attr arg.
append_style(style_all) append_style(highlight_cmd, style_all)
-- There won't always be a `guisp`. -- There won't always be a `guisp`.
if style.color then highlight_cmd[#highlight_cmd + 1] = if style.color then highlight_cmd[#highlight_cmd + 1] =
' guisp=' .. get(style.color, HEX) ' guisp=' .. get(style.color, HEX)
end end
else append_style(style) else append_style(highlight_cmd, style)
end end
end end