From db448f41e66b1a58941c231fbb47198f2b7f2f6a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 4 Sep 2021 00:28:20 +0600 Subject: [PATCH] chore: formated with stylua (#32) Apply initial stylua format Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- examples/bubbles.lua | 44 ++- examples/evil_lualine.lua | 121 ++++--- lua/lualine.lua | 96 ++++-- lua/lualine/component.lua | 57 ++-- lua/lualine/components/branch.lua | 44 +-- lua/lualine/components/diagnostics.lua | 81 ++--- lua/lualine/components/diff.lua | 93 ++--- lua/lualine/components/encoding.lua | 4 +- lua/lualine/components/filename.lua | 19 +- lua/lualine/components/filesize.lua | 12 +- lua/lualine/components/filetype.lua | 49 +-- lua/lualine/components/location.lua | 4 +- lua/lualine/components/mode.lua | 2 +- lua/lualine/components/progress.lua | 4 +- .../special/eval_func_component.lua | 12 +- .../components/special/function_component.lua | 8 +- .../components/special/vim_var_component.lua | 16 +- lua/lualine/config.lua | 55 +-- lua/lualine/extensions/chadtree.lua | 4 +- lua/lualine/extensions/fugitive.lua | 21 +- lua/lualine/extensions/fzf.lua | 18 +- lua/lualine/extensions/nerdtree.lua | 18 +- lua/lualine/extensions/nvim-tree.lua | 4 +- lua/lualine/extensions/quickfix.lua | 24 +- lua/lualine/extensions/toggleterm.lua | 18 +- lua/lualine/highlight.lua | 115 ++++--- lua/lualine/themes/16color.lua | 20 +- lua/lualine/themes/OceanicNext.lua | 32 +- lua/lualine/themes/Tomorrow.lua | 26 +- lua/lualine/themes/auto.lua | 87 +++-- lua/lualine/themes/ayu_dark.lua | 26 +- lua/lualine/themes/ayu_light.lua | 26 +- lua/lualine/themes/ayu_mirage.lua | 26 +- lua/lualine/themes/codedark.lua | 28 +- lua/lualine/themes/dracula.lua | 38 +-- lua/lualine/themes/everforest.lua | 44 +-- lua/lualine/themes/gruvbox-material.lua | 18 +- lua/lualine/themes/gruvbox_dark.lua | 38 +-- lua/lualine/themes/gruvbox_light.lua | 38 +-- lua/lualine/themes/horizon.lua | 38 +-- lua/lualine/themes/iceberg_dark.lua | 26 +- lua/lualine/themes/iceberg_light.lua | 26 +- lua/lualine/themes/jellybeans.lua | 26 +- lua/lualine/themes/material.lua | 26 +- lua/lualine/themes/modus-vivendi.lua | 38 +-- lua/lualine/themes/molokai.lua | 20 +- lua/lualine/themes/moonfly.lua | 26 +- lua/lualine/themes/nightfly.lua | 26 +- lua/lualine/themes/nord.lua | 21 +- lua/lualine/themes/onedark.lua | 20 +- lua/lualine/themes/onelight.lua | 21 +- lua/lualine/themes/palenight.lua | 26 +- lua/lualine/themes/papercolor_dark.lua | 21 +- lua/lualine/themes/papercolor_light.lua | 21 +- lua/lualine/themes/powerline.lua | 24 +- lua/lualine/themes/powerline_dark.lua | 38 +-- lua/lualine/themes/seoul256.lua | 26 +- lua/lualine/themes/solarized_dark.lua | 20 +- lua/lualine/themes/solarized_light.lua | 20 +- lua/lualine/themes/wombat.lua | 20 +- lua/lualine/utils/color_utils.lua | 6 +- lua/lualine/utils/job.lua | 28 +- lua/lualine/utils/loader.lua | 58 ++-- lua/lualine/utils/mode.lua | 4 +- lua/lualine/utils/notices.lua | 23 +- lua/lualine/utils/section.lua | 65 ++-- lua/lualine/utils/utils.lua | 22 +- lua/lualine_require.lua | 40 ++- lua/tests/helpers.lua | 46 ++- lua/tests/minimal_init.lua | 7 +- lua/tests/spec/component_spec.lua | 321 +++++++++--------- lua/tests/spec/config_spec.lua | 101 +++--- lua/tests/spec/utils_spec.lua | 101 +++--- 73 files changed, 1481 insertions(+), 1261 deletions(-) diff --git a/examples/bubbles.lua b/examples/bubbles.lua index 4b32f15..ae0d7e2 100644 --- a/examples/bubbles.lua +++ b/examples/bubbles.lua @@ -15,54 +15,48 @@ local colors = { local bubbles_theme = { normal = { - a = {fg = colors.black, bg = colors.violet}, - b = {fg = colors.white, bg = colors.grey}, - c = {fg = colors.black, bg = colors.black}, + a = { fg = colors.black, bg = colors.violet }, + b = { fg = colors.white, bg = colors.grey }, + c = { fg = colors.black, bg = colors.black }, }, - insert = {a = {fg = colors.black, bg = colors.blue}}, - visual = {a = {fg = colors.black, bg = colors.cyan}}, - replace = {a = {fg = colors.black, bg = colors.red}}, + insert = { a = { fg = colors.black, bg = colors.blue } }, + visual = { a = { fg = colors.black, bg = colors.cyan } }, + replace = { a = { fg = colors.black, bg = colors.red } }, inactive = { - a = {fg = colors.white, bg = colors.black}, - b = {fg = colors.white, bg = colors.black}, - c = {fg = colors.black, bg = colors.black}, - } + a = { fg = colors.white, bg = colors.black }, + b = { fg = colors.white, bg = colors.black }, + c = { fg = colors.black, bg = colors.black }, + }, } -require'lualine'.setup { +require('lualine').setup { options = { theme = bubbles_theme, component_separators = '|', - section_separators = {'', ''}, + section_separators = { '', '' }, }, sections = { lualine_a = { - {'mode', - separator = {'', ''}, - right_padding = 2, - } + { 'mode', separator = { '', '' }, right_padding = 2 }, }, - lualine_b = {'filename', 'branch'}, - lualine_c = {'fileformat'}, + lualine_b = { 'filename', 'branch' }, + lualine_c = { 'fileformat' }, lualine_x = {}, lualine_y = { 'filetype', 'progress' }, lualine_z = { - {'location', - separator = {'', ''}, - left_padding = 2, - } + { 'location', separator = { '', '' }, left_padding = 2 }, }, }, inactive_sections = { - lualine_a = {'filename'}, + lualine_a = { 'filename' }, lualine_b = {}, lualine_c = {}, lualine_x = {}, lualine_y = {}, - lualine_z = {'location'} + lualine_z = { 'location' }, }, tabline = {}, - extensions = {} + extensions = {}, } diff --git a/examples/evil_lualine.lua b/examples/evil_lualine.lua index 190dc83..7a03711 100644 --- a/examples/evil_lualine.lua +++ b/examples/evil_lualine.lua @@ -4,43 +4,48 @@ local lualine = require 'lualine' -- Color table for highlights +-- stylua: ignore local colors = { - bg = '#202328', - fg = '#bbc2cf', - yellow = '#ECBE7B', - cyan = '#008080', + bg = '#202328', + fg = '#bbc2cf', + yellow = '#ECBE7B', + cyan = '#008080', darkblue = '#081633', - green = '#98be65', - orange = '#FF8800', - violet = '#a9a1e1', - magenta = '#c678dd', - blue = '#51afef', - red = '#ec5f67' + green = '#98be65', + orange = '#FF8800', + violet = '#a9a1e1', + magenta = '#c678dd', + blue = '#51afef', + red = '#ec5f67', } local conditions = { - buffer_not_empty = function() return vim.fn.empty(vim.fn.expand('%:t')) ~= 1 end, - hide_in_width = function() return vim.fn.winwidth(0) > 80 end, + buffer_not_empty = function() + return vim.fn.empty(vim.fn.expand '%:t') ~= 1 + end, + hide_in_width = function() + return vim.fn.winwidth(0) > 80 + end, check_git_workspace = function() - local filepath = vim.fn.expand('%:p:h') + local filepath = vim.fn.expand '%:p:h' local gitdir = vim.fn.finddir('.git', filepath .. ';') return gitdir and #gitdir > 0 and #gitdir < #filepath - end + end, } -- Config local config = { options = { -- Disable sections and component separators - component_separators = "", - section_separators = "", + component_separators = '', + section_separators = '', theme = { -- We are going to use lualine_c an lualine_x as left and -- right section. Both are highlighted by c theme . So we -- are just setting default looks o statusline - normal = {c = {fg = colors.fg, bg = colors.bg}}, - inactive = {c = {fg = colors.fg, bg = colors.bg}} - } + normal = { c = { fg = colors.fg, bg = colors.bg } }, + inactive = { c = { fg = colors.fg, bg = colors.bg } }, + }, }, sections = { -- these are to remove the defaults @@ -50,7 +55,7 @@ local config = { lualine_z = {}, -- These will be filled later lualine_c = {}, - lualine_x = {} + lualine_x = {}, }, inactive_sections = { -- these are to remove the defaults @@ -59,8 +64,8 @@ local config = { lualine_y = {}, lualine_z = {}, lualine_c = {}, - lualine_x = {} - } + lualine_x = {}, + }, } -- Inserts a component in lualine_c at left section @@ -74,9 +79,11 @@ local function ins_right(component) end ins_left { - function() return '▊' end, - color = {fg = colors.blue}, -- Sets highlighting of component - left_padding = 0 -- We don't need space before this + function() + return '▊' + end, + color = { fg = colors.blue }, -- Sets highlighting of component + left_padding = 0, -- We don't need space before this } ins_left { @@ -103,45 +110,47 @@ ins_left { rm = colors.cyan, ['r?'] = colors.cyan, ['!'] = colors.red, - t = colors.red + t = colors.red, } - vim.api.nvim_command( - 'hi! LualineMode guifg=' .. mode_color[vim.fn.mode()] .. " guibg=" .. - colors.bg) + vim.api.nvim_command('hi! LualineMode guifg=' .. mode_color[vim.fn.mode()] .. ' guibg=' .. colors.bg) return '' end, - color = "LualineMode", - left_padding = 0 + color = 'LualineMode', + left_padding = 0, } ins_left { -- filesize component 'filesize', - condition = conditions.buffer_not_empty + condition = conditions.buffer_not_empty, } ins_left { 'filename', condition = conditions.buffer_not_empty, - color = {fg = colors.magenta, gui = 'bold'} + color = { fg = colors.magenta, gui = 'bold' }, } -ins_left {'location'} +ins_left { 'location' } -ins_left {'progress', color = {fg = colors.fg, gui = 'bold'}} +ins_left { 'progress', color = { fg = colors.fg, gui = 'bold' } } ins_left { 'diagnostics', - sources = {'nvim_lsp'}, - symbols = {error = ' ', warn = ' ', info = ' '}, - color_error = {fg = colors.red}, - color_warn = {fg = colors.yellow}, - color_info = {fg = colors.cyan} + sources = { 'nvim_lsp' }, + symbols = { error = ' ', warn = ' ', info = ' ' }, + color_error = { fg = colors.red }, + color_warn = { fg = colors.yellow }, + color_info = { fg = colors.cyan }, } -- Insert mid section. You can make any number of sections in neovim :) -- for lualine it's any number greater then 2 -ins_left {function() return '%=' end} +ins_left { + function() + return '%=' + end, +} ins_left { -- Lsp server name . @@ -149,7 +158,9 @@ ins_left { local msg = 'No Active Lsp' local buf_ft = vim.api.nvim_buf_get_option(0, 'filetype') local clients = vim.lsp.get_active_clients() - if next(clients) == nil then return msg end + if next(clients) == nil then + return msg + end for _, client in ipairs(clients) do local filetypes = client.config.filetypes if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then @@ -159,7 +170,7 @@ ins_left { return msg end, icon = ' LSP:', - color = {fg = '#ffffff', gui = 'bold'} + color = { fg = '#ffffff', gui = 'bold' }, } -- Add components to right sections @@ -167,37 +178,39 @@ ins_right { 'o:encoding', -- option component same as &encoding in viml upper = true, -- I'm not sure why it's upper case either ;) condition = conditions.hide_in_width, - color = {fg = colors.green, gui = 'bold'} + color = { fg = colors.green, gui = 'bold' }, } ins_right { 'fileformat', upper = true, icons_enabled = false, -- I think icons are cool but Eviline doesn't have them. sigh - color = {fg = colors.green, gui = 'bold'} + color = { fg = colors.green, gui = 'bold' }, } ins_right { 'branch', icon = '', condition = conditions.check_git_workspace, - color = {fg = colors.violet, gui = 'bold'} + color = { fg = colors.violet, gui = 'bold' }, } ins_right { 'diff', -- Is it me or the symbol for modified us really weird - symbols = {added = ' ', modified = '柳 ', removed = ' '}, - color_added = {fg = colors.green}, - color_modified = {fg = colors.orange}, - color_removed = {fg = colors.red}, - condition = conditions.hide_in_width + symbols = { added = ' ', modified = '柳 ', removed = ' ' }, + color_added = { fg = colors.green }, + color_modified = { fg = colors.orange }, + color_removed = { fg = colors.red }, + condition = conditions.hide_in_width, } ins_right { - function() return '▊' end, - color = {fg = colors.blue}, - right_padding = 0 + function() + return '▊' + end, + color = { fg = colors.blue }, + right_padding = 0, } -- Now don't forget to initialize lualine diff --git a/lua/lualine.lua b/lua/lualine.lua index d6438da..a99c192 100644 --- a/lua/lualine.lua +++ b/lua/lualine.lua @@ -1,7 +1,7 @@ -- Copyright (c) 2020-2021 hoob3rt -- MIT license, see LICENSE for more details. -local lualine_require = require'lualine_require' -local modules = lualine_require.lazy_require{ +local lualine_require = require 'lualine_require' +local modules = lualine_require.lazy_require { highlight = 'lualine.highlight', loader = 'lualine.utils.loader', utils_section = 'lualine.utils.section', @@ -9,19 +9,23 @@ local modules = lualine_require.lazy_require{ utils_notices = 'lualine.utils.notices', config_module = 'lualine.config', } -local config -- Stores cureently applied config -local new_config = true -- Stores config that will be applied +local config -- Stores cureently applied config +local new_config = true -- Stores config that will be applied -- Helper for apply_transitional_separators() local function find_next_hl(status, str_checked) -- Gets the next valid hl group from str_checked local hl_pos_start, hl_pos_end = status:find('%%#.-#', str_checked) while true do - if not hl_pos_start then return nil end + if not hl_pos_start then + return nil + end -- When there are more that one hl group next to one another like -- %#HL1#%#HL2#%#HL3# we need to return HL3. This makes that happen. local next_start, next_end = status:find('^%%#.-#', hl_pos_end + 1) - if next_start == nil then break end + if next_start == nil then + break + end hl_pos_start, hl_pos_end = next_start, next_end end return status:sub(hl_pos_start + 2, hl_pos_end - 1) @@ -31,12 +35,18 @@ end local function fill_section_separator(status, str_checked, last_hl, sep, reverse) -- Inserts transitional separator along with transitional highlight local next_hl = find_next_hl(status, str_checked) - if last_hl == nil then last_hl = 'Normal' end - if next_hl == nil then next_hl = 'Normal' end - if #next_hl == 0 or #last_hl == 0 then return end + if last_hl == nil then + last_hl = 'Normal' + end + if next_hl == nil then + next_hl = 'Normal' + end + if #next_hl == 0 or #last_hl == 0 then + return + end local transitional_highlight = reverse -- lua ternary assignment x ? y : z - and modules.highlight.get_transitional_highlights(last_hl, next_hl) - or modules.highlight.get_transitional_highlights(next_hl, last_hl) + and modules.highlight.get_transitional_highlights(last_hl, next_hl) + or modules.highlight.get_transitional_highlights(next_hl, last_hl) if transitional_highlight then return transitional_highlight .. sep end @@ -44,20 +54,21 @@ end local function apply_transitional_separators(status) local status_applied = {} -- Collects all the pieces for concatation - local last_hl -- Stores lash highligjt group that we found - local copied_pos = 1 -- Tracks how much we've copied over to status_applied + local last_hl -- Stores lash highligjt group that we found + local copied_pos = 1 -- Tracks how much we've copied over to status_applied local str_checked = 1 -- Tracks where the searcher head is at - -- Process entire status replace the %s{sep} & %S{sep} placeholders -- with proper transitional separator. while str_checked ~= nil do str_checked = status:find('%%', str_checked) - if str_checked == nil then break end + if str_checked == nil then + break + end table.insert(status_applied, status:sub(copied_pos, str_checked - 1)) - -- -1 so we don't copy '%' + -- -1 so we don't copy '%' copied_pos = str_checked - local next_char = modules.utils.charAt(status, str_checked +1) + local next_char = modules.utils.charAt(status, str_checked + 1) if next_char == '#' then -- %#hl_name# highlights last_hl = status:match('^%%#(.-)#', str_checked) @@ -67,7 +78,9 @@ local function apply_transitional_separators(status) local sep = status:match('^%%s{(.-)}', str_checked) str_checked = str_checked + #sep + 4 -- 4 = len(%{}) local trans_sep = fill_section_separator(status, str_checked, last_hl, sep, false) - if trans_sep then table.insert(status_applied, trans_sep) end + if trans_sep then + table.insert(status_applied, trans_sep) + end copied_pos = str_checked elseif next_char == 'S' then -- %S{sep} is marker for right separator and @@ -79,12 +92,13 @@ local function apply_transitional_separators(status) str_checked = status:find('}', str_checked) + 1 end local trans_sep = fill_section_separator(status, str_checked, last_hl, sep, true) - if trans_sep then table.insert(status_applied, trans_sep) end + if trans_sep then + table.insert(status_applied, trans_sep) + end copied_pos = str_checked elseif next_char == '%' then str_checked = str_checked + 2 -- Skip the following % too - elseif next_char == '=' and last_hl and - (last_hl:find('^lualine_a') or last_hl:find('^lualine_b')) then + elseif next_char == '=' and last_hl and (last_hl:find '^lualine_a' or last_hl:find '^lualine_b') then -- TODO: Fix this properly -- This check for lualine_a and lualine_b is dumb. It doesn't garantee -- c or x section isn't present. Worst case sinario after this patch @@ -102,7 +116,7 @@ end local function statusline(sections, is_focused) -- The sequence sections should maintain [SECTION_SEQUENCE] - local section_sequence = {'a', 'b', 'c', 'x', 'y', 'z'} + local section_sequence = { 'a', 'b', 'c', 'x', 'y', 'z' } local status = {} local applied_midsection_devider = false local applied_trunc = false @@ -110,16 +124,18 @@ local function statusline(sections, is_focused) if sections['lualine_' .. section_name] then -- insert highlight+components of this section to status_builder local section_data = modules.utils_section.draw_section( - sections['lualine_' .. section_name], - section_name, is_focused) + sections['lualine_' .. section_name], + section_name, + is_focused + ) if #section_data > 0 then if not applied_midsection_devider and section_name > 'c' then applied_midsection_devider = true - section_data = '%='..section_data + section_data = '%=' .. section_data end if not applied_trunc and section_name > 'b' then applied_trunc = true - section_data = '%<'..section_data + section_data = '%<' .. section_data end table.insert(status, section_data) end @@ -143,13 +159,17 @@ local function get_extension_sections(current_ft, is_focused) return nil end -local function tabline() return statusline(config.tabline, true) end +local function tabline() + return statusline(config.tabline, true) +end local function notify_theme_error(theme_name) - local message_template = theme_name ~= 'auto' and [[ + local message_template = theme_name ~= 'auto' + and [[ ### options.theme Theme `%s` not found, falling back to `auto`. Check if spelling is right. -]] or [[ +]] + or [[ ### options.theme Theme `%s` failed, falling back to `gruvbox`. This shouldn't happen. @@ -164,7 +184,9 @@ local function setup_theme() local theme_name = config.options.theme if type(theme_name) == 'string' then local ok, theme = pcall(modules.loader.load_theme, theme_name) - if ok and theme then return theme end + if ok and theme then + return theme + end elseif type(theme_name) == 'table' then -- use the provided theme as-is return config.options.theme @@ -172,10 +194,12 @@ local function setup_theme() if theme_name ~= 'auto' then notify_theme_error(theme_name) local ok, theme = pcall(modules.loader.load_theme, 'auto') - if ok and theme then return theme end + if ok and theme then + return theme + end end - notify_theme_error('auto') - return modules.loader.load_theme('gruvbox') + notify_theme_error 'auto' + return modules.loader.load_theme 'gruvbox' end local theme = get_theme_from_config() modules.highlight.create_highlight_groups(theme) @@ -192,7 +216,7 @@ end local function set_statusline() if next(config.sections) ~= nil or next(config.inactive_sections) ~= nil then - vim.cmd('autocmd lualine VimResized * redrawstatus') + vim.cmd 'autocmd lualine VimResized * redrawstatus' else vim.go.statusline = nil end @@ -219,7 +243,9 @@ end local function status_dispatch(focused) -- disable on specific filetypes - if new_config then reset_lualine() end + if new_config then + reset_lualine() + end local current_ft = vim.bo.filetype local is_focused = focused ~= nil and focused or modules.utils.is_focused() for _, ft in pairs(config.options.disabled_filetypes) do diff --git a/lua/lualine/component.lua b/lua/lualine/component.lua index 864f31e..997a5e9 100644 --- a/lua/lualine/component.lua +++ b/lua/lualine/component.lua @@ -11,7 +11,7 @@ local Component = { local new_component = {} new_component.options = options new_component._parent = child or self - setmetatable(new_component, {__index = new_component._parent}) + setmetatable(new_component, { __index = new_component._parent }) -- Operation that are required for creating new components but not for inheritence if options ~= nil then component_no = component_no + 1 @@ -41,16 +41,19 @@ local Component = { -- set custom highlights if self.options.color then self.options.color_highlight = highlight.create_component_highlight_group( - self.options.color, - self.options.component_name, - self.options) + self.options.color, + self.options.component_name, + self.options + ) end end, -- set upper or lower case apply_case = function(self) -- Donn't work on components that emit vim statusline escaped chars - if self.status:find('%%') and not self.status:find('%%%%') then return end + if self.status:find '%%' and not self.status:find '%%%%' then + return + end if self.options.upper == true then self.status = self.status:upper() elseif self.options.lower == true then @@ -63,27 +66,26 @@ local Component = { local l_padding = (self.options.left_padding or self.options.padding or 1) local r_padding = (self.options.right_padding or self.options.padding or 1) if l_padding then - if self.status:find('%%#.*#') == 1 then + if self.status:find '%%#.*#' == 1 then -- When component has changed the highlight at begining -- we will add the padding after the highlight - local pre_highlight = - vim.fn.matchlist(self.status, [[\(%#.\{-\}#\)]])[2] - self.status = pre_highlight .. string.rep(' ', l_padding) .. - self.status:sub(#pre_highlight + 1, #self.status) + local pre_highlight = vim.fn.matchlist(self.status, [[\(%#.\{-\}#\)]])[2] + self.status = pre_highlight .. string.rep(' ', l_padding) .. self.status:sub(#pre_highlight + 1, #self.status) else self.status = string.rep(' ', l_padding) .. self.status end end - if r_padding then self.status = self.status .. string.rep(' ', r_padding) end + if r_padding then + self.status = self.status .. string.rep(' ', r_padding) + end end, -- Applies custom highlights for component apply_highlights = function(self, default_highlight) if self.options.color_highlight then - self.status = highlight.component_format_highlight( - self.options.color_highlight) .. self.status + self.status = highlight.component_format_highlight(self.options.color_highlight) .. self.status end - if type(self.options.separator) ~= 'table' and self.status:find('%%#') then + if type(self.options.separator) ~= 'table' and self.status:find '%%#' then -- Apply default highlight only when we aren't applying trans sep and -- the component has changed it's hl. since we won't be applying -- regular sep in those cases so ending with default hl isn't neccessay @@ -93,7 +95,9 @@ local Component = { end -- Prepend default hl when the component doesn't start with hl otherwise -- color in previous component can cause side effect - if not self.status:find('^%%#') then self.status = default_highlight .. self.status end + if not self.status:find '^%%#' then + self.status = default_highlight .. self.status + end end, -- Apply icon in front of component @@ -125,22 +129,23 @@ local Component = { end, apply_section_separators = function(self) - if type(self.options.separator) ~= 'table' then return end + if type(self.options.separator) ~= 'table' then + return + end if self.options.separator[1] ~= '' then - self.status = string.format('%%s{%s}%s', self.options.separator[1], - self.status) + self.status = string.format('%%s{%s}%s', self.options.separator[1], self.status) self.strip_previous_separator = true end if self.options.separator[2] ~= '' then - self.status = string.format('%s%%S{%s}', self.status, - self.options.separator[2]) + self.status = string.format('%s%%S{%s}', self.status, self.options.separator[2]) end end, strip_separator = function(self) - if not self.applied_separator then self.applied_separator = '' end - self.status = self.status:sub(1, (#self.status - - (#self.applied_separator))) + if not self.applied_separator then + self.applied_separator = '' + end + self.status = self.status:sub(1, (#self.status - #self.applied_separator)) self.applied_separator = nil return self.status end, @@ -161,7 +166,9 @@ local Component = { return self.status end local status = self:update_status(is_focused) - if self.options.format then status = self.options.format(status or '') end + if self.options.format then + status = self.options.format(status or '') + end if type(status) == 'string' and #status > 0 then self.status = status self:apply_icon() @@ -172,7 +179,7 @@ local Component = { self:apply_separator() end return self.status - end + end, } return Component diff --git a/lua/lualine/components/branch.lua b/lua/lualine/components/branch.lua index 38a4199..fdd9f63 100644 --- a/lua/lualine/components/branch.lua +++ b/lua/lualine/components/branch.lua @@ -9,7 +9,7 @@ Branch.sep = package.config:sub(1, 1) -- event watcher to watch head file -- Use file wstch for non windows and poll for windows. -- windows doesn't like file watch for some reason. -Branch.file_changed = Branch.sep ~= "\\" and vim.loop.new_fs_event() or vim.loop.new_fs_poll() +Branch.file_changed = Branch.sep ~= '\\' and vim.loop.new_fs_event() or vim.loop.new_fs_poll() Branch.active_bufnr = '0' local branch_cache = {} -- stores last known branch for a buffer -- Initilizer @@ -28,7 +28,9 @@ Branch.update_status = function(_, is_focused) -- Sync buffer Branch.find_git_dir() end - if not is_focused then return branch_cache[vim.fn.bufnr()] or '' end + if not is_focused then + return branch_cache[vim.fn.bufnr()] or '' + end return Branch.git_branch end @@ -36,39 +38,41 @@ local git_dir_cache = {} -- Stores git paths that we already know of -- returns full path to git directory for current directory function Branch.find_git_dir() -- get file dir so we can search from that dir - local file_dir = vim.fn.expand('%:p:h') + local file_dir = vim.fn.expand '%:p:h' local root_dir = file_dir local git_dir -- Search upward for .git file or folder - while (root_dir) do + while root_dir do if git_dir_cache[root_dir] then git_dir = git_dir_cache[root_dir] break end - local git_path = root_dir..Branch.sep..'.git' + local git_path = root_dir .. Branch.sep .. '.git' local git_file_stat = vim.loop.fs_stat(git_path) - if (git_file_stat) then + if git_file_stat then if git_file_stat.type == 'directory' then git_dir = git_path elseif git_file_stat.type == 'file' then -- separate git-dir or submodule is used local file = io.open(git_path) git_dir = file:read() - git_dir = git_dir:match('gitdir: (.+)$') + git_dir = git_dir:match 'gitdir: (.+)$' file:close() -- submodule / relative file path - if git_dir and git_dir:sub(1, 1) ~= Branch.sep and not git_dir:match('^%a:.*$') then - git_dir = git_path:match('(.*).git') .. git_dir + if git_dir and git_dir:sub(1, 1) ~= Branch.sep and not git_dir:match '^%a:.*$' then + git_dir = git_path:match '(.*).git' .. git_dir end end if git_dir then - local head_file_stat = vim.loop.fs_stat(git_dir..Branch.sep..'HEAD') + local head_file_stat = vim.loop.fs_stat(git_dir .. Branch.sep .. 'HEAD') if head_file_stat and head_file_stat.type == 'file' then break - else git_dir = nil end + else + git_dir = nil + end end end - root_dir = root_dir:match('(.*)'..Branch.sep..'.-') + root_dir = root_dir:match('(.*)' .. Branch.sep .. '.-') end git_dir_cache[file_dir] = git_dir @@ -85,7 +89,7 @@ function Branch.get_git_head(head_file) if f_head then local HEAD = f_head:read() f_head:close() - local branch = HEAD:match('ref: refs/heads/(.+)$') + local branch = HEAD:match 'ref: refs/heads/(.+)$' if branch then Branch.git_branch = branch else @@ -103,12 +107,14 @@ function Branch.update_branch() if git_dir and #git_dir > 0 then local head_file = git_dir .. Branch.sep .. 'HEAD' Branch.get_git_head(head_file) - Branch.file_changed:start(head_file, - Branch.sep ~= "\\" and {} or 1000, - vim.schedule_wrap( function() - -- reset file-watch - Branch.update_branch() - end)) + Branch.file_changed:start( + head_file, + Branch.sep ~= '\\' and {} or 1000, + vim.schedule_wrap(function() + -- reset file-watch + Branch.update_branch() + end) + ) else -- set to '' when git dir was not found Branch.git_branch = '' diff --git a/lua/lualine/components/diagnostics.lua b/lua/lualine/components/diagnostics.lua index 1fa5826..60ce31f 100644 --- a/lua/lualine/components/diagnostics.lua +++ b/lua/lualine/components/diagnostics.lua @@ -1,7 +1,7 @@ -- Copyright (c) 2020-2021 hoob3rt -- MIT license, see LICENSE for more details. -local lualine_require = require'lualine_require' -local modules = lualine_require.lazy_require{ +local lualine_require = require 'lualine_require' +local modules = lualine_require.lazy_require { highlight = 'lualine.highlight', utils = 'lualine.utils.utils', utils_notices = 'lualine.utils.notices', @@ -14,35 +14,35 @@ local default_symbols = { error = ' ', -- xf659 warn = ' ', -- xf529 info = ' ', -- xf7fc - hint = ' ' -- xf838 + hint = ' ', -- xf838 }, - no_icons = {error = 'E:', warn = 'W:', info = 'I:', hint = 'H:'}, + no_icons = { error = 'E:', warn = 'W:', info = 'I:', hint = 'H:' }, } local default_options = { colored = true, update_in_insert = false, sources = nil, - sections = {'error', 'warn', 'info', 'hint'}, + sections = { 'error', 'warn', 'info', 'hint' }, color_error = { fg = modules.utils.extract_highlight_colors('LspDiagnosticsDefaultError', 'fg') - or modules.utils.extract_highlight_colors('DiffDelete', 'fg') - or '#e32636', + or modules.utils.extract_highlight_colors('DiffDelete', 'fg') + or '#e32636', }, color_warn = { fg = modules.utils.extract_highlight_colors('LspDiagnosticsDefaultWarning', 'fg') - or modules.utils.extract_highlight_colors('DiffText', 'fg') - or '#ffdf00', + or modules.utils.extract_highlight_colors('DiffText', 'fg') + or '#ffdf00', }, color_info = { fg = modules.utils.extract_highlight_colors('LspDiagnosticsDefaultInformation', 'fg') - or modules.utils.extract_highlight_colors('Normal', 'fg') - or '#ffffff', + or modules.utils.extract_highlight_colors('Normal', 'fg') + or '#ffffff', }, color_hint = { fg = modules.utils.extract_highlight_colors('LspDiagnosticsDefaultHint', 'fg') - or modules.utils.extract_highlight_colors('DiffChange', 'fg') - or '#d7afaf', + or modules.utils.extract_highlight_colors('DiffChange', 'fg') + or '#d7afaf', }, } -- Initializer @@ -50,34 +50,42 @@ Diagnostics.new = function(self, options, child) -- Run super() local new_diagnostics = self._parent:new(options, child or Diagnostics) -- Apply default options - new_diagnostics.options = - vim.tbl_deep_extend('keep', new_diagnostics.options or {}, default_options) + new_diagnostics.options = vim.tbl_deep_extend('keep', new_diagnostics.options or {}, default_options) -- Apply default symbols - new_diagnostics.symbols = - vim.tbl_extend('keep', new_diagnostics.options.symbols or {}, - new_diagnostics.options.icons_enabled ~= false - and default_symbols.icons or default_symbols.no_icons) + new_diagnostics.symbols = vim.tbl_extend( + 'keep', + new_diagnostics.options.symbols or {}, + new_diagnostics.options.icons_enabled ~= false and default_symbols.icons or default_symbols.no_icons + ) -- Initialize highlight groups if new_diagnostics.options.colored then new_diagnostics.highlight_groups = { error = modules.highlight.create_component_highlight_group( - new_diagnostics.options.color_error, 'diagnostics_error', - new_diagnostics.options), + new_diagnostics.options.color_error, + 'diagnostics_error', + new_diagnostics.options + ), warn = modules.highlight.create_component_highlight_group( - new_diagnostics.options.color_warn, 'diagnostics_warn', - new_diagnostics.options), + new_diagnostics.options.color_warn, + 'diagnostics_warn', + new_diagnostics.options + ), info = modules.highlight.create_component_highlight_group( - new_diagnostics.options.color_info, 'diagnostics_info', - new_diagnostics.options), + new_diagnostics.options.color_info, + 'diagnostics_info', + new_diagnostics.options + ), hint = modules.highlight.create_component_highlight_group( - new_diagnostics.options.color_hint, 'diagnostics_hint', - new_diagnostics.options) + new_diagnostics.options.color_hint, + 'diagnostics_hint', + new_diagnostics.options + ), } end -- Error out no source if new_diagnostics.options.sources == nil then - print('no sources for diagnostics configured') + print 'no sources for diagnostics configured' return '' end -- Initialize variable to store last update so we can use it in insert @@ -87,8 +95,7 @@ Diagnostics.new = function(self, options, child) end Diagnostics.update_status = function(self) - if not self.options.update_in_insert - and vim.api.nvim_get_mode().mode:sub(1,1) == 'i' then + if not self.options.update_in_insert and vim.api.nvim_get_mode().mode:sub(1, 1) == 'i' then return self.last_update end local error_count, warning_count, info_count, hint_count = 0, 0, 0, 0 @@ -104,7 +111,7 @@ Diagnostics.update_status = function(self) error = error_count, warn = warning_count, info = info_count, - hint = hint_count + hint = hint_count, } if self.options.colored then local colors = {} @@ -113,8 +120,7 @@ Diagnostics.update_status = function(self) end for _, section in ipairs(self.options.sections) do if data[section] ~= nil and data[section] > 0 then - table.insert(result, - colors[section] .. self.symbols[section] .. data[section]) + table.insert(result, colors[section] .. self.symbols[section] .. data[section]) end end else @@ -154,20 +160,19 @@ Diagnostics.diagnostic_sources = { else return 0, 0, 0, 0 end - end + end, } Diagnostics.get_diagnostics = function(sources) local result = {} for index, source in ipairs(sources) do if type(source) == 'string' then - local error_count, warning_count, info_count, hint_count = - Diagnostics.diagnostic_sources[source]() + local error_count, warning_count, info_count, hint_count = Diagnostics.diagnostic_sources[source]() result[index] = { error = error_count, warn = warning_count, info = info_count, - hint = hint_count + hint = hint_count, } elseif type(source) == 'function' then local source_result = source() @@ -176,7 +181,7 @@ Diagnostics.get_diagnostics = function(sources) error = source_result.error or 0, warn = source_result.warning or 0, info = source_result.info or 0, - hint = source_result.hin or 0 + hint = source_result.hin or 0, } end end diff --git a/lua/lualine/components/diff.lua b/lua/lualine/components/diff.lua index 9337caa..c7104b8 100644 --- a/lua/lualine/components/diff.lua +++ b/lua/lualine/components/diff.lua @@ -1,11 +1,11 @@ -- Copyright (c) 2020-2021 shadmansaleh -- MIT license, see LICENSE for more details. -local lualine_require = require'lualine_require' -local modules = lualine_require.lazy_require{ - utils = 'lualine.utils.utils', +local lualine_require = require 'lualine_require' +local modules = lualine_require.lazy_require { + utils = 'lualine.utils.utils', utils_notices = 'lualine.utils.notices', - highlight = 'lualine.highlight', - Job = 'lualine.utils.job', + highlight = 'lualine.highlight', + Job = 'lualine.utils.job', } local Diff = lualine_require.require('lualine.component'):new() @@ -22,39 +22,40 @@ local diff_cache = {} -- Stores last known value of diff of a buffer local default_options = { colored = true, - symbols = {added = '+', modified = '~', removed = '-'}, + symbols = { added = '+', modified = '~', removed = '-' }, color_added = { - fg = modules.utils.extract_highlight_colors('DiffAdd', 'fg') - or '#f0e130', + fg = modules.utils.extract_highlight_colors('DiffAdd', 'fg') or '#f0e130', }, color_modified = { - fg = modules.utils.extract_highlight_colors('DiffChange', 'fg') - or '#ff0038', + fg = modules.utils.extract_highlight_colors('DiffChange', 'fg') or '#ff0038', }, color_removed = { - fg = modules.utils.extract_highlight_colors('DiffDelete', 'fg') - or '#ff0038', + fg = modules.utils.extract_highlight_colors('DiffDelete', 'fg') or '#ff0038', }, } -- Initializer Diff.new = function(self, options, child) local new_instance = self._parent:new(options, child or Diff) - new_instance.options = vim.tbl_deep_extend('keep', - new_instance.options or {}, - default_options) + new_instance.options = vim.tbl_deep_extend('keep', new_instance.options or {}, default_options) -- create highlights and save highlight_name in highlights table if new_instance.options.colored then new_instance.highlights = { added = modules.highlight.create_component_highlight_group( - new_instance.options.color_added, 'diff_added', - new_instance.options), + new_instance.options.color_added, + 'diff_added', + new_instance.options + ), modified = modules.highlight.create_component_highlight_group( - new_instance.options.color_modified, 'diff_modified', - new_instance.options), + new_instance.options.color_modified, + 'diff_modified', + new_instance.options + ), removed = modules.highlight.create_component_highlight_group( - new_instance.options.color_removed, 'diff_removed', - new_instance.options) + new_instance.options.color_removed, + 'diff_removed', + new_instance.options + ), } end @@ -82,8 +83,12 @@ Diff.update_status = function(self, is_focused) git_diff = self.options.source() end - if not is_focused then git_diff = diff_cache[vim.fn.bufnr()] or {} end - if git_diff == nil then return '' end + if not is_focused then + git_diff = diff_cache[vim.fn.bufnr()] or {} + end + if git_diff == nil then + return '' + end local colors = {} if self.options.colored then @@ -95,11 +100,10 @@ Diff.update_status = function(self, is_focused) local result = {} -- loop though data and load available sections in result table - for _, name in ipairs {'added', 'modified', 'removed'} do + for _, name in ipairs { 'added', 'modified', 'removed' } do if git_diff[name] and git_diff[name] > 0 then if self.options.colored then - table.insert(result, colors[name] .. self.options.symbols[name] .. - git_diff[name]) + table.insert(result, colors[name] .. self.options.symbols[name] .. git_diff[name]) else table.insert(result, self.options.symbols[name] .. git_diff[name]) end @@ -121,8 +125,10 @@ end -- } -- error_code = { added = -1, modified = -1, removed = -1 } function Diff.get_sign_count() - if Diff.diff_checker_enabled then Diff.update_diff_args() end - return Diff.git_diff or {added = -1, modified = -1, removed = -1} + if Diff.diff_checker_enabled then + Diff.update_diff_args() + end + return Diff.git_diff or { added = -1, modified = -1, removed = -1 } end -- process diff data and update git_diff{ added, removed, modified } @@ -131,11 +137,10 @@ function Diff.process_diff(data) local added, removed, modified = 0, 0, 0 for _, line in ipairs(data) do if string.find(line, [[^@@ ]]) then - local tokens = vim.fn.matchlist(line, - [[^@@ -\v(\d+),?(\d*) \+(\d+),?(\d*)]]) + local tokens = vim.fn.matchlist(line, [[^@@ -\v(\d+),?(\d*) \+(\d+),?(\d*)]]) local line_stats = { mod_count = tokens[3] == '' and 1 or tonumber(tokens[3]), - new_count = tokens[5] == '' and 1 or tonumber(tokens[5]) + new_count = tokens[5] == '' and 1 or tonumber(tokens[5]), } if line_stats.mod_count == 0 and line_stats.new_count > 0 then @@ -150,22 +155,24 @@ function Diff.process_diff(data) end end end - Diff.git_diff = {added = added, modified = modified, removed = removed} + Diff.git_diff = { added = added, modified = modified, removed = removed } end -- Updates the job args function Diff.update_diff_args() -- Donn't show git diff when current buffer doesn't have a filename Diff.active_bufnr = tostring(vim.fn.bufnr()) - if #vim.fn.expand('%') == 0 then - Diff.diff_args = nil; - Diff.git_diff = nil; + if #vim.fn.expand '%' == 0 then + Diff.diff_args = nil + Diff.git_diff = nil return end Diff.diff_args = { cmd = string.format( - [[git -C %s --no-pager diff --no-color --no-ext-diff -U0 -- %s]], - vim.fn.expand('%:h'), vim.fn.expand('%:t')), + [[git -C %s --no-pager diff --no-color --no-ext-diff -U0 -- %s]], + vim.fn.expand '%:h', + vim.fn.expand '%:t' + ), on_stdout = function(_, data) if next(data) then Diff.diff_output_cache = vim.list_extend(Diff.diff_output_cache, data) @@ -182,10 +189,10 @@ function Diff.update_diff_args() if #Diff.diff_output_cache > 0 then Diff.process_diff(Diff.diff_output_cache) else - Diff.git_diff = {added = 0, modified = 0, removed = 0} + Diff.git_diff = { added = 0, modified = 0, removed = 0 } end diff_cache[vim.fn.bufnr()] = Diff.git_diff - end + end, } Diff.update_git_diff() end @@ -194,9 +201,13 @@ end function Diff.update_git_diff() if Diff.diff_args then Diff.diff_output_cache = {} - if Diff.diff_job then Diff.diff_job:stop() end + if Diff.diff_job then + Diff.diff_job:stop() + end Diff.diff_job = modules.Job(Diff.diff_args) - if Diff.diff_job then Diff.diff_job:start() end + if Diff.diff_job then + Diff.diff_job:start() + end end end diff --git a/lua/lualine/components/encoding.lua b/lua/lualine/components/encoding.lua index b792c96..a2f5fdd 100644 --- a/lua/lualine/components/encoding.lua +++ b/lua/lualine/components/encoding.lua @@ -2,6 +2,8 @@ -- MIT license, see LICENSE for more details. local Encoding = require('lualine.component'):new() -Encoding.update_status = function() return [[%{strlen(&fenc)?&fenc:&enc}]] end +Encoding.update_status = function() + return [[%{strlen(&fenc)?&fenc:&enc}]] +end return Encoding diff --git a/lua/lualine/components/filename.lua b/lua/lualine/components/filename.lua index 64410bd..2f4f6f3 100644 --- a/lua/lualine/components/filename.lua +++ b/lua/lualine/components/filename.lua @@ -3,7 +3,7 @@ local FileName = require('lualine.component'):new() local default_options = { - symbols = {modified = '[+]', readonly = '[-]'}, + symbols = { modified = '[+]', readonly = '[-]' }, file_status = true, path = 0, shorting_target = 40, @@ -15,15 +15,12 @@ end local function shorten_path(path, sep) -- ('([^/])[^/]+%/', '%1/', 1) - return path:gsub( - string.format('([^%s])[^%s]+%%%s', sep, sep, sep), '%1' .. sep, 1) + return path:gsub(string.format('([^%s])[^%s]+%%%s', sep, sep, sep), '%1' .. sep, 1) end FileName.new = function(self, options, child) local new_instance = self._parent:new(options, child or FileName) - new_instance.options = vim.tbl_deep_extend('keep', - new_instance.options or {}, - default_options) + new_instance.options = vim.tbl_deep_extend('keep', new_instance.options or {}, default_options) return new_instance end @@ -31,16 +28,18 @@ FileName.update_status = function(self) local data if self.options.path == 1 then -- relative path - data = vim.fn.expand('%:~:.') + data = vim.fn.expand '%:~:.' elseif self.options.path == 2 then -- absolute path - data = vim.fn.expand('%:p') + data = vim.fn.expand '%:p' else -- just filename - data = vim.fn.expand('%:t') + data = vim.fn.expand '%:t' end - if data == '' then data = '[No Name]' end + if data == '' then + data = '[No Name]' + end if self.options.shorting_target ~= 0 then local windwidth = vim.fn.winwidth(0) diff --git a/lua/lualine/components/filesize.lua b/lua/lualine/components/filesize.lua index cc87905..523dda2 100644 --- a/lua/lualine/components/filesize.lua +++ b/lua/lualine/components/filesize.lua @@ -3,13 +3,17 @@ local M = require('lualine.component'):new() M.update_status = function() - local file = vim.fn.expand('%:p') - if file == nil or #file == 0 then return '' end + local file = vim.fn.expand '%:p' + if file == nil or #file == 0 then + return '' + end local size = vim.fn.getfsize(file) - if size <= 0 then return '' end + if size <= 0 then + return '' + end - local sufixes = {'b', 'k', 'm', 'g'} + local sufixes = { 'b', 'k', 'm', 'g' } local i = 1 while size > 1024 and i < #sufixes do diff --git a/lua/lualine/components/filetype.lua b/lua/lualine/components/filetype.lua index e46d8cf..d09a732 100644 --- a/lua/lualine/components/filetype.lua +++ b/lua/lualine/components/filetype.lua @@ -1,9 +1,9 @@ -- Copyright (c) 2020-2021 hoob3rt -- MIT license, see LICENSE for more details. -local lualine_require = require'lualine_require' -local modules = lualine_require.lazy_require{ +local lualine_require = require 'lualine_require' +local modules = lualine_require.lazy_require { highlight = 'lualine.highlight', - utils = 'lualine.utils.utils', + utils = 'lualine.utils.utils', } local FileType = lualine_require.require('lualine.component'):new() @@ -14,47 +14,50 @@ local default_options = { function FileType:new(options, child) local new_instance = self._parent:new(options, child or FileType) - new_instance.options = vim.tbl_deep_extend('keep', - new_instance.options or {}, - default_options) + new_instance.options = vim.tbl_deep_extend('keep', new_instance.options or {}, default_options) return new_instance end -function FileType.update_status() return vim.bo.filetype or '' end +function FileType.update_status() + return vim.bo.filetype or '' +end function FileType:apply_icon() - if not self.options.icons_enabled then return end + if not self.options.icons_enabled then + return + end local icon, icon_highlight_group local ok, devicons = pcall(require, 'nvim-web-devicons') if ok then - local f_name, f_extension = vim.fn.expand('%:t'), vim.fn.expand('%:e') + local f_name, f_extension = vim.fn.expand '%:t', vim.fn.expand '%:e' icon, icon_highlight_group = devicons.get_icon(f_name, f_extension) if icon and self.options.colored then - local highlight_color = modules.utils.extract_highlight_colors( - icon_highlight_group, 'fg') + local highlight_color = modules.utils.extract_highlight_colors(icon_highlight_group, 'fg') local is_focused = modules.utils.is_focused() - local default_highlight = modules.highlight.format_highlight(is_focused, - self.options.self - .section) - local icon_highlight = self.options.self.section .. '_' .. - icon_highlight_group + local default_highlight = modules.highlight.format_highlight(is_focused, self.options.self.section) + local icon_highlight = self.options.self.section .. '_' .. icon_highlight_group if not modules.highlight.highlight_exists(icon_highlight .. '_normal') then icon_highlight = modules.highlight.create_component_highlight_group( - {fg = highlight_color}, icon_highlight_group, - self.options) + { fg = highlight_color }, + icon_highlight_group, + self.options + ) end - icon = modules.highlight.component_format_highlight(icon_highlight) .. icon .. - default_highlight + icon = modules.highlight.component_format_highlight(icon_highlight) .. icon .. default_highlight end else - ok = vim.fn.exists('*WebDevIconsGetFileTypeSymbol') - if ok ~= 0 then icon = vim.fn.WebDevIconsGetFileTypeSymbol() end + ok = vim.fn.exists '*WebDevIconsGetFileTypeSymbol' + if ok ~= 0 then + icon = vim.fn.WebDevIconsGetFileTypeSymbol() + end end - if not icon then return end + if not icon then + return + end if self.options.disable_text then self.status = icon diff --git a/lua/lualine/components/location.lua b/lua/lualine/components/location.lua index 9a8d0a5..39b2eae 100644 --- a/lua/lualine/components/location.lua +++ b/lua/lualine/components/location.lua @@ -2,6 +2,8 @@ -- MIT license, see LICENSE for more details. local Location = require('lualine.component'):new() -Location.update_status = function() return [[%3l:%-2c]] end +Location.update_status = function() + return [[%3l:%-2c]] +end return Location diff --git a/lua/lualine/components/mode.lua b/lua/lualine/components/mode.lua index a8904af..cec8222 100644 --- a/lua/lualine/components/mode.lua +++ b/lua/lualine/components/mode.lua @@ -1,6 +1,6 @@ -- Copyright (c) 2020-2021 hoob3rt -- MIT license, see LICENSE for more details. -local require = require'lualine_require'.require +local require = require('lualine_require').require local Mode = require('lualine.component'):new() local get_mode = require('lualine.utils.mode').get_mode diff --git a/lua/lualine/components/progress.lua b/lua/lualine/components/progress.lua index 2a046e7..ac7e52f 100644 --- a/lua/lualine/components/progress.lua +++ b/lua/lualine/components/progress.lua @@ -2,6 +2,8 @@ -- MIT license, see LICENSE for more details. local Progress = require('lualine.component'):new() -Progress.update_status = function() return [[%3P]] end +Progress.update_status = function() + return [[%3P]] +end return Progress diff --git a/lua/lualine/components/special/eval_func_component.lua b/lua/lualine/components/special/eval_func_component.lua index 39befda..e40b516 100644 --- a/lua/lualine/components/special/eval_func_component.lua +++ b/lua/lualine/components/special/eval_func_component.lua @@ -5,11 +5,15 @@ EvalFuncComponent.update_status = function(self) local ok, status if self.options.type == nil then ok, status = pcall(EvalFuncComponent.lua_eval, component) - if not ok then status = EvalFuncComponent.vim_function(component) end + if not ok then + status = EvalFuncComponent.vim_function(component) + end else if self.options.type == 'luae' then ok, status = pcall(EvalFuncComponent.lua_eval, component) - if not ok then status = nil end + if not ok then + status = nil + end elseif self.options.type == 'vimf' then status = EvalFuncComponent.vim_function(component) end @@ -26,7 +30,9 @@ end EvalFuncComponent.vim_function = function(name) -- vim function component local ok, return_val = pcall(vim.api.nvim_call_function, name, {}) - if not ok then return '' end -- function call failed + if not ok then + return '' + end -- function call failed ok, return_val = pcall(tostring, return_val) return ok and return_val or '' end diff --git a/lua/lualine/components/special/function_component.lua b/lua/lualine/components/special/function_component.lua index 23deea9..27685c4 100644 --- a/lua/lualine/components/special/function_component.lua +++ b/lua/lualine/components/special/function_component.lua @@ -4,10 +4,14 @@ FunctionComponent.update_status = function(self, is_focused) -- 1st element in options table is the function provided by config local ok, retval ok, retval = pcall(self.options[1], self, is_focused) - if not ok then return '' end + if not ok then + return '' + end if type(retval) ~= 'string' then ok, retval = pcall(tostring, retval) - if not ok then return '' end + if not ok then + return '' + end end return retval end diff --git a/lua/lualine/components/special/vim_var_component.lua b/lua/lualine/components/special/vim_var_component.lua index b318f17..53a99a8 100644 --- a/lua/lualine/components/special/vim_var_component.lua +++ b/lua/lualine/components/special/vim_var_component.lua @@ -4,20 +4,26 @@ VarComponent.update_status = function(self) -- vim veriable component -- accepts g:, v:, t:, w:, b:, o, go:, vo:, to:, wo:, bo: -- filters g portion from g:var - local scope = component:match('[gvtwb]?o?') + local scope = component:match '[gvtwb]?o?' -- filters var portion from g:var local var_name = component:sub(#scope + 2, #component) -- Displays nothing when veriable aren't present - if not (scope and var_name) then return '' end + if not (scope and var_name) then + return '' + end -- Support accessing keys within dictionary -- https://github.com/shadmansaleh/lualine.nvim/issues/25#issuecomment-907374548 local name_chunks = vim.split(var_name, '%.') local return_val = vim[scope][name_chunks[1]] - for i=2,#name_chunks do - if return_val == nil then break end + for i = 2, #name_chunks do + if return_val == nil then + break + end return_val = return_val[name_chunks[i]] end - if return_val == nil then return '' end + if return_val == nil then + return '' + end local ok ok, return_val = pcall(tostring, return_val) return ok and return_val or '' diff --git a/lua/lualine/config.lua b/lua/lualine/config.lua index 74af956..8829c1f 100644 --- a/lua/lualine/config.lua +++ b/lua/lualine/config.lua @@ -4,62 +4,63 @@ local config = { options = { icons_enabled = true, theme = 'auto', - component_separators = {'', ''}, - section_separators = {'', ''}, - disabled_filetypes = {} + component_separators = { '', '' }, + section_separators = { '', '' }, + disabled_filetypes = {}, }, sections = { - lualine_a = {'mode'}, - lualine_b = {'branch', 'diff', - {'diagnostics', sources={'nvim_lsp', 'coc'}}}, - lualine_c = {'filename'}, - lualine_x = {'encoding', 'fileformat', 'filetype'}, - lualine_y = {'progress'}, - lualine_z = {'location'} + lualine_a = { 'mode' }, + lualine_b = { 'branch', 'diff', { 'diagnostics', sources = { 'nvim_lsp', 'coc' } } }, + lualine_c = { 'filename' }, + lualine_x = { 'encoding', 'fileformat', 'filetype' }, + lualine_y = { 'progress' }, + lualine_z = { 'location' }, }, inactive_sections = { lualine_a = {}, lualine_b = {}, - lualine_c = {'filename'}, - lualine_x = {'location'}, + lualine_c = { 'filename' }, + lualine_x = { 'location' }, lualine_y = {}, - lualine_z = {} + lualine_z = {}, }, tabline = {}, - extensions = {} + extensions = {}, } -- change separator format 'x' or {'x'} to {'x', 'x'} local function fix_separators(separators) if separators ~= nil then if type(separators) == 'string' then - return {separators, separators} + return { separators, separators } elseif type(separators) == 'table' and #separators == 1 then - return {separators[1], separators[1]} + return { separators[1], separators[1] } end end return separators end local function apply_configuration(config_table) - if not config_table then return vim.deepcopy(config) end + if not config_table then + return vim.deepcopy(config) + end local function parse_sections(section_group_name) - if not config_table[section_group_name] then return end + if not config_table[section_group_name] then + return + end for section_name, section in pairs(config_table[section_group_name]) do config[section_group_name][section_name] = vim.deepcopy(section) end end - parse_sections('options') - parse_sections('sections') - parse_sections('inactive_sections') - parse_sections('tabline') + parse_sections 'options' + parse_sections 'sections' + parse_sections 'inactive_sections' + parse_sections 'tabline' if config_table.extensions then config.extensions = vim.deepcopy(config_table.extensions) end - config.options.section_separators = fix_separators( - config.options.section_separators) - config.options.component_separators = fix_separators( - config.options.component_separators) + config.options.section_separators = fix_separators(config.options.section_separators) + config.options.component_separators = fix_separators(config.options.component_separators) return vim.deepcopy(config) end @@ -69,5 +70,5 @@ end return { get_config = get_current_config, - apply_configuration = apply_configuration + apply_configuration = apply_configuration, } diff --git a/lua/lualine/extensions/chadtree.lua b/lua/lualine/extensions/chadtree.lua index 7033b11..ac2511f 100644 --- a/lua/lualine/extensions/chadtree.lua +++ b/lua/lualine/extensions/chadtree.lua @@ -1,11 +1,11 @@ -- Copyright (c) 2020-2021 hoob3rt -- MIT license, see LICENSE for more details. -local nerdtree = require('lualine.extensions.nerdtree') +local nerdtree = require 'lualine.extensions.nerdtree' local M = {} M.sections = vim.deepcopy(nerdtree.sections) -M.filetypes = {'CHADTree'} +M.filetypes = { 'CHADTree' } return M diff --git a/lua/lualine/extensions/fugitive.lua b/lua/lualine/extensions/fugitive.lua index 508bb17..8aa099d 100644 --- a/lua/lualine/extensions/fugitive.lua +++ b/lua/lualine/extensions/fugitive.lua @@ -6,15 +6,20 @@ local function fugitive_branch() local icon = '' -- e0a0 return icon .. ' ' .. vim.fn.FugitiveHead() end -local empty = {function() return ' ' end, left_padding=0, right_padding=0} - - -M.sections = { - lualine_a = {fugitive_branch}, - lualine_c = {empty}, - lualine_z = {'location'} +local empty = { + function() + return ' ' + end, + left_padding = 0, + right_padding = 0, } -M.filetypes = {'fugitive'} +M.sections = { + lualine_a = { fugitive_branch }, + lualine_c = { empty }, + lualine_z = { 'location' }, +} + +M.filetypes = { 'fugitive' } return M diff --git a/lua/lualine/extensions/fzf.lua b/lua/lualine/extensions/fzf.lua index bbb2aae..a774f1e 100644 --- a/lua/lualine/extensions/fzf.lua +++ b/lua/lualine/extensions/fzf.lua @@ -1,15 +1,23 @@ -- Copyright (c) 2020-2021 hoob3rt -- MIT license, see LICENSE for more details. -local function fzf_statusline() return 'FZF' end -local empty = {function() return ' ' end, left_padding=0, right_padding=0} +local function fzf_statusline() + return 'FZF' +end +local empty = { + function() + return ' ' + end, + left_padding = 0, + right_padding = 0, +} local M = {} M.sections = { - lualine_a = {fzf_statusline}, - lualine_c = {empty} + lualine_a = { fzf_statusline }, + lualine_c = { empty }, } -M.filetypes = {'fzf'} +M.filetypes = { 'fzf' } return M diff --git a/lua/lualine/extensions/nerdtree.lua b/lua/lualine/extensions/nerdtree.lua index f6efdd6..b2d348c 100644 --- a/lua/lualine/extensions/nerdtree.lua +++ b/lua/lualine/extensions/nerdtree.lua @@ -1,15 +1,23 @@ -- Copyright (c) 2020-2021 hoob3rt -- MIT license, see LICENSE for more details. -local function get_short_cwd() return vim.fn.fnamemodify(vim.fn.getcwd(), ':~') end -local empty = {function() return ' ' end, left_padding=0, right_padding=0} +local function get_short_cwd() + return vim.fn.fnamemodify(vim.fn.getcwd(), ':~') +end +local empty = { + function() + return ' ' + end, + left_padding = 0, + right_padding = 0, +} local M = {} M.sections = { - lualine_a = {get_short_cwd}, - lualine_c = {empty} + lualine_a = { get_short_cwd }, + lualine_c = { empty }, } -M.filetypes = {'nerdtree'} +M.filetypes = { 'nerdtree' } return M diff --git a/lua/lualine/extensions/nvim-tree.lua b/lua/lualine/extensions/nvim-tree.lua index 19731c4..9e5e9ec 100644 --- a/lua/lualine/extensions/nvim-tree.lua +++ b/lua/lualine/extensions/nvim-tree.lua @@ -1,11 +1,11 @@ -- Copyright (c) 2020-2021 hoob3rt -- MIT license, see LICENSE for more details. -local nerdtree = require('lualine.extensions.nerdtree') +local nerdtree = require 'lualine.extensions.nerdtree' local M = {} M.sections = vim.deepcopy(nerdtree.sections) -M.filetypes = {'NvimTree'} +M.filetypes = { 'NvimTree' } return M diff --git a/lua/lualine/extensions/quickfix.lua b/lua/lualine/extensions/quickfix.lua index e5f01ee..3e1c388 100644 --- a/lua/lualine/extensions/quickfix.lua +++ b/lua/lualine/extensions/quickfix.lua @@ -2,7 +2,7 @@ -- MIT license, see LICENSE for more details. -- local function is_loclist() - return vim.fn.getloclist(0, {filewinid = 1}).filewinid ~= 0 + return vim.fn.getloclist(0, { filewinid = 1 }).filewinid ~= 0 end local function label() @@ -11,11 +11,17 @@ end local function title() if is_loclist() then - return vim.fn.getloclist(0, {title = 0}).title + return vim.fn.getloclist(0, { title = 0 }).title end - return vim.fn.getqflist({title = 0}).title + return vim.fn.getqflist({ title = 0 }).title end -local empty = {function() return ' ' end, left_padding=0, right_padding=0} +local empty = { + function() + return ' ' + end, + left_padding = 0, + right_padding = 0, +} local M = {} @@ -25,12 +31,12 @@ function M.init() end M.sections = { - lualine_a = {label}, - lualine_b = {title}, - lualine_c = {empty}, - lualine_z = {'location'} + lualine_a = { label }, + lualine_b = { title }, + lualine_c = { empty }, + lualine_z = { 'location' }, } -M.filetypes = {'qf'} +M.filetypes = { 'qf' } return M diff --git a/lua/lualine/extensions/toggleterm.lua b/lua/lualine/extensions/toggleterm.lua index e936dfa..bb3ec2f 100644 --- a/lua/lualine/extensions/toggleterm.lua +++ b/lua/lualine/extensions/toggleterm.lua @@ -1,16 +1,24 @@ -- Copyright (c) 2020-2021 hoob3rt -- MIT license, see LICENSE for more details. -local function toggleterm_statusline() return 'ToggleTerm #' .. vim.b.toggle_number end -local empty = {function() return ' ' end, left_padding=0, right_padding=0} +local function toggleterm_statusline() + return 'ToggleTerm #' .. vim.b.toggle_number +end +local empty = { + function() + return ' ' + end, + left_padding = 0, + right_padding = 0, +} local M = {} M.sections = { - lualine_a = {toggleterm_statusline}, - lualine_c = {empty} + lualine_a = { toggleterm_statusline }, + lualine_c = { empty }, } -M.filetypes = {'toggleterm'} +M.filetypes = { 'toggleterm' } return M diff --git a/lua/lualine/highlight.lua b/lua/lualine/highlight.lua index 2e2befa..445e12e 100644 --- a/lua/lualine/highlight.lua +++ b/lua/lualine/highlight.lua @@ -1,14 +1,14 @@ -- Copyright (c) 2020-2021 hoob3rt -- MIT license, see LICENSE for more details. local M = {} -local lualine_require = require'lualine_require' +local lualine_require = require 'lualine_require' local require = lualine_require.require -local modules = lualine_require.lazy_require{ +local modules = lualine_require.lazy_require { utils = 'lualine.utils.utils', color_utils = 'lualine.utils.color_utils', } -local section_highlight_map = {x = 'c', y = 'b', z = 'a'} +local section_highlight_map = { x = 'c', y = 'b', z = 'a' } local active_theme = nil local create_cterm_colors = false @@ -30,20 +30,22 @@ end local function sanitize_color(color) if type(color) == 'string' then - if color:sub(1,1) == '#' then return color end -- RGB value + if color:sub(1, 1) == '#' then + return color + end -- RGB value return modules.color_utils.color_name2rgb(color) elseif type(color) == 'number' then if color > 255 then - error("What's this it can't be higher then 255 and you've given "..color) + error("What's this it can't be higher then 255 and you've given " .. color) end return modules.color_utils.cterm2rgb(color) end end function M.highlight(name, foreground, background, gui, link) - local command = {'highlight!'} + local command = { 'highlight!' } if link and #link > 0 then - vim.list_extend(command, {'link', name, link}) + vim.list_extend(command, { 'link', name, link }) else foreground = sanitize_color(foreground) background = sanitize_color(background) @@ -51,15 +53,13 @@ function M.highlight(name, foreground, background, gui, link) if foreground and foreground ~= 'none' then table.insert(command, 'guifg=' .. foreground) if create_cterm_colors then - table.insert(command, - 'ctermfg=' .. modules.color_utils.rgb2cterm(foreground)) + table.insert(command, 'ctermfg=' .. modules.color_utils.rgb2cterm(foreground)) end end if background and background ~= 'none' then table.insert(command, 'guibg=' .. background) if create_cterm_colors then - table.insert(command, - 'ctermbg=' .. modules.color_utils.rgb2cterm(background)) + table.insert(command, 'ctermbg=' .. modules.color_utils.rgb2cterm(background)) end end if gui then @@ -77,13 +77,11 @@ function M.create_highlight_groups(theme) create_cterm_colors = not vim.go.termguicolors for mode, sections in pairs(theme) do for section, color in pairs(sections) do - local highlight_group_name = {'lualine', section, mode} + local highlight_group_name = { 'lualine', section, mode } if type(color) == 'string' then -- link to a highlight group - M.highlight(table.concat(highlight_group_name, '_'), nil, - nil, nil, color) + M.highlight(table.concat(highlight_group_name, '_'), nil, nil, nil, color) else -- Define a new highlight - M.highlight(table.concat(highlight_group_name, '_'), color.fg, - color.bg, color.gui, nil) + M.highlight(table.concat(highlight_group_name, '_'), color.fg, color.bg, color.gui, nil) end end end @@ -94,15 +92,20 @@ end -- @return: (string) highlight group name with mode local function append_mode(highlight_group) local mode = require('lualine.utils.mode').get_mode() - if mode == 'VISUAL' or mode == 'V-BLOCK' or mode == 'V-LINE' or mode == - 'SELECT' or mode == 'S-LINE' or mode == 'S-BLOCK' then + if + mode == 'VISUAL' + or mode == 'V-BLOCK' + or mode == 'V-LINE' + or mode == 'SELECT' + or mode == 'S-LINE' + or mode == 'S-BLOCK' + then highlight_group = highlight_group .. '_visual' elseif mode == 'REPLACE' or mode == 'V-REPLACE' then highlight_group = highlight_group .. '_replace' elseif mode == 'INSERT' then highlight_group = highlight_group .. '_insert' - elseif mode == 'COMMAND' or mode == 'EX' or mode == 'MORE' or mode == - 'CONFIRM' then + elseif mode == 'COMMAND' or mode == 'EX' or mode == 'MORE' or mode == 'CONFIRM' then highlight_group = highlight_group .. '_command' elseif mode == 'TERMINAL' then highlight_group = highlight_group .. '_terminal' @@ -120,7 +123,9 @@ end -- @param default_color Colors et in theme this is 2nd fall back -- @param kind (fg/bg)) local function get_default_component_color(color, options_color, default_color, kind) - if color[kind] then return color[kind] end + if color[kind] then + return color[kind] + end if options_color then if type(options_color) == 'table' and options_color[kind] then return options_color[kind] @@ -146,54 +151,57 @@ end -- to retrive highlight group function M.create_component_highlight_group(color, highlight_tag, options) local tag_id = 0 - while (M.highlight_exists(table.concat( - {'lualine', highlight_tag, 'no_mode'}, '_')) - or (options.self.section and M.highlight_exists(table.concat( - {options.self.section, highlight_tag, 'normal'}, '_'))) -) do + while + M.highlight_exists(table.concat({ 'lualine', highlight_tag, 'no_mode' }, '_')) + or ( + options.self.section + and M.highlight_exists(table.concat({ options.self.section, highlight_tag, 'normal' }, '_')) + ) + do highlight_tag = highlight_tag .. '_' .. tostring(tag_id) tag_id = tag_id + 1 end if type(color) == 'string' then - local highlight_group_name = table.concat( - {'lualine', highlight_tag, 'no_mode'}, '_') + local highlight_group_name = table.concat({ 'lualine', highlight_tag, 'no_mode' }, '_') M.highlight(highlight_group_name, nil, nil, nil, color) -- l8nk to group return highlight_group_name end if color.bg and color.fg then -- When bg and fg are both present we donn't need to set highlighs for -- each mode as they will surely look the same. So we can work without options - local highlight_group_name = table.concat( - {'lualine', highlight_tag, 'no_mode'}, '_') + local highlight_group_name = table.concat({ 'lualine', highlight_tag, 'no_mode' }, '_') M.highlight(highlight_group_name, color.fg, color.bg, color.gui, nil) return highlight_group_name end local modes = { - 'normal', 'insert', 'visual', 'replace', 'command', 'terminal', 'inactive' + 'normal', + 'insert', + 'visual', + 'replace', + 'command', + 'terminal', + 'inactive', } local normal_hl -- convert lualine_a -> a before setting section - local section = options.self.section:match('lualine_(.*)') + local section = options.self.section:match 'lualine_(.*)' if section > 'c' and not active_theme.normal[section] then - section = section_highlight_map[section] end + section = section_highlight_map[section] + end for _, mode in ipairs(modes) do - local highlight_group_name = {options.self.section, highlight_tag, mode} - local default_color_table = active_theme[mode] and - active_theme[mode][section] or - active_theme.normal[section] + local highlight_group_name = { options.self.section, highlight_tag, mode } + local default_color_table = active_theme[mode] and active_theme[mode][section] or active_theme.normal[section] local bg = get_default_component_color(color, options.color, default_color_table, 'bg') local fg = get_default_component_color(color, options.color, default_color_table, 'fg') -- Check if it's same as normal mode if it is no need to create aditional highlight if mode ~= 'normal' then if bg ~= normal_hl.bg or fg ~= normal_hl.fg then - M.highlight(table.concat(highlight_group_name, '_'), fg, bg, color.gui, - nil) + M.highlight(table.concat(highlight_group_name, '_'), fg, bg, color.gui, nil) end else - normal_hl = {bg = bg, fg = fg} - M.highlight(table.concat(highlight_group_name, '_'), fg, bg, color.gui, - nil) + normal_hl = { bg = bg, fg = fg } + M.highlight(table.concat(highlight_group_name, '_'), fg, bg, color.gui, nil) end end return options.self.section .. '_' .. highlight_tag @@ -206,7 +214,7 @@ end -- @return: (string) formated highlight group name function M.component_format_highlight(highlight_name) local highlight_group = highlight_name - if highlight_name:find('no_mode') == #highlight_name - #'no_mode' + 1 then + if highlight_name:find 'no_mode' == #highlight_name - #'no_mode' + 1 then return '%#' .. highlight_group .. '#' end if modules.utils.is_focused() then @@ -222,11 +230,8 @@ function M.component_format_highlight(highlight_name) end function M.format_highlight(is_focused, highlight_group) - if highlight_group > 'lualine_c' - and not M.highlight_exists(highlight_group .. '_normal') then - highlight_group = 'lualine_' .. - section_highlight_map[highlight_group:match( - 'lualine_(.)')] + if highlight_group > 'lualine_c' and not M.highlight_exists(highlight_group .. '_normal') then + highlight_group = 'lualine_' .. section_highlight_map[highlight_group:match 'lualine_(.)'] end local highlight_name if not is_focused then @@ -248,17 +253,23 @@ end function M.get_transitional_highlights(left_hl, right_hl) -- When both left and right highlights are same or one is absent -- nothing to transition to. - if left_hl == nil or right_hl == nil or left_hl == right_hl then return nil end + if left_hl == nil or right_hl == nil or left_hl == right_hl then + return nil + end -- construct the name of hightlight group - local highlight_name = table.concat({'lualine_transitional',left_hl,'to',right_hl}, '_') + local highlight_name = table.concat({ 'lualine_transitional', left_hl, 'to', right_hl }, '_') if not M.highlight_exists(highlight_name) then -- Create the highlight_group if needed -- Get colors from highlights local fg = modules.utils.extract_highlight_colors(left_hl, 'bg') local bg = modules.utils.extract_highlight_colors(right_hl, 'bg') - if not fg or not bg then return nil end -- Color retrieval failed - if bg == fg then return nil end -- Separator won't be visible anyway + if not fg or not bg then + return nil + end -- Color retrieval failed + if bg == fg then + return nil + end -- Separator won't be visible anyway M.highlight(highlight_name, fg, bg, nil) end return '%#' .. highlight_name .. '#' diff --git a/lua/lualine/themes/16color.lua b/lua/lualine/themes/16color.lua index 8b0da23..fe093a3 100644 --- a/lua/lualine/themes/16color.lua +++ b/lua/lualine/themes/16color.lua @@ -23,16 +23,16 @@ local colors = { return { normal = { - a = {fg = colors.white, bg = colors.blue, gui = 'bold'}, - b = {fg = colors.white, bg = colors.gray}, - c = {fg = colors.silver, bg = colors.black} + a = { fg = colors.white, bg = colors.blue, gui = 'bold' }, + b = { fg = colors.white, bg = colors.gray }, + c = { fg = colors.silver, bg = colors.black }, }, - insert = {a = {fg = colors.white, bg = colors.green, gui = 'bold'}}, - visual = {a = {fg = colors.white, bg = colors.purple, gui = 'bold'}}, - replace = {a = {fg = colors.white, bg = colors.red, gui = 'bold'}}, + insert = { a = { fg = colors.white, bg = colors.green, gui = 'bold' } }, + visual = { a = { fg = colors.white, bg = colors.purple, gui = 'bold' } }, + replace = { a = { fg = colors.white, bg = colors.red, gui = 'bold' } }, inactive = { - a = {fg = colors.silver, bg = colors.gray, gui = 'bold'}, - b = {fg = colors.gray, bg = colors.black}, - c = {fg = colors.silver, bg = colors.black} - } + a = { fg = colors.silver, bg = colors.gray, gui = 'bold' }, + b = { fg = colors.gray, bg = colors.black }, + c = { fg = colors.silver, bg = colors.black }, + }, } diff --git a/lua/lualine/themes/OceanicNext.lua b/lua/lualine/themes/OceanicNext.lua index 4bcf6a0..72c74d2 100644 --- a/lua/lualine/themes/OceanicNext.lua +++ b/lua/lualine/themes/OceanicNext.lua @@ -16,28 +16,28 @@ local colors = { return { insert = { - a = {fg = colors.color0, bg = colors.color1, gui = 'bold'}, - b = {fg = colors.color0, bg = colors.color2}, - c = {fg = colors.color0, bg = colors.color3} + a = { fg = colors.color0, bg = colors.color1, gui = 'bold' }, + b = { fg = colors.color0, bg = colors.color2 }, + c = { fg = colors.color0, bg = colors.color3 }, }, normal = { - a = {fg = colors.color0, bg = colors.color4, gui = 'bold'}, - b = {fg = colors.color0, bg = colors.color2}, - c = {fg = colors.color0, bg = colors.color3} + a = { fg = colors.color0, bg = colors.color4, gui = 'bold' }, + b = { fg = colors.color0, bg = colors.color2 }, + c = { fg = colors.color0, bg = colors.color3 }, }, inactive = { - a = {fg = colors.color5, bg = colors.color2, gui = 'bold'}, - b = {fg = colors.color5, bg = colors.color3}, - c = {fg = colors.color2, bg = colors.color3} + a = { fg = colors.color5, bg = colors.color2, gui = 'bold' }, + b = { fg = colors.color5, bg = colors.color3 }, + c = { fg = colors.color2, bg = colors.color3 }, }, visual = { - a = {fg = colors.color0, bg = colors.color6, gui = 'bold'}, - b = {fg = colors.color0, bg = colors.color2}, - c = {fg = colors.color0, bg = colors.color3} + a = { fg = colors.color0, bg = colors.color6, gui = 'bold' }, + b = { fg = colors.color0, bg = colors.color2 }, + c = { fg = colors.color0, bg = colors.color3 }, }, replace = { - a = {fg = colors.color0, bg = colors.color7, gui = 'bold'}, - b = {fg = colors.color0, bg = colors.color2}, - c = {fg = colors.color0, bg = colors.color3} - } + a = { fg = colors.color0, bg = colors.color7, gui = 'bold' }, + b = { fg = colors.color0, bg = colors.color2 }, + c = { fg = colors.color0, bg = colors.color3 }, + }, } diff --git a/lua/lualine/themes/Tomorrow.lua b/lua/lualine/themes/Tomorrow.lua index bfa29a0..8e101a8 100644 --- a/lua/lualine/themes/Tomorrow.lua +++ b/lua/lualine/themes/Tomorrow.lua @@ -19,25 +19,25 @@ local colors = { return { inactive = { - a = {fg = colors.color0, bg = colors.color1, gui = 'bold'}, - b = {fg = colors.color2, bg = colors.color3}, - c = {fg = colors.color0, bg = colors.color1} + a = { fg = colors.color0, bg = colors.color1, gui = 'bold' }, + b = { fg = colors.color2, bg = colors.color3 }, + c = { fg = colors.color0, bg = colors.color1 }, }, normal = { - a = {fg = colors.color1, bg = colors.color4, gui = 'bold'}, - b = {fg = colors.color5, bg = colors.color6}, - c = {fg = colors.color7, bg = colors.color1} + a = { fg = colors.color1, bg = colors.color4, gui = 'bold' }, + b = { fg = colors.color5, bg = colors.color6 }, + c = { fg = colors.color7, bg = colors.color1 }, }, visual = { - a = {fg = colors.color1, bg = colors.color8, gui = 'bold'}, - b = {fg = colors.color5, bg = colors.color6} + a = { fg = colors.color1, bg = colors.color8, gui = 'bold' }, + b = { fg = colors.color5, bg = colors.color6 }, }, replace = { - a = {fg = colors.color1, bg = colors.color11, gui = 'bold'}, - b = {fg = colors.color5, bg = colors.color6} + a = { fg = colors.color1, bg = colors.color11, gui = 'bold' }, + b = { fg = colors.color5, bg = colors.color6 }, }, insert = { - a = {fg = colors.color1, bg = colors.color14, gui = 'bold'}, - b = {fg = colors.color5, bg = colors.color6} - } + a = { fg = colors.color1, bg = colors.color14, gui = 'bold' }, + b = { fg = colors.color5, bg = colors.color6 }, + }, } diff --git a/lua/lualine/themes/auto.lua b/lua/lualine/themes/auto.lua index 0b5cc8d..c942fee 100644 --- a/lua/lualine/themes/auto.lua +++ b/lua/lualine/themes/auto.lua @@ -1,12 +1,14 @@ local utils = require 'lualine.utils.utils' local loader = require 'lualine.utils.loader' -local color_name = vim.g.colors_name +local color_name = vim.g.colors_name if color_name then -- Check if there's a theme for current colorscheme -- If there is load that instead of genarating a new one local ok, theme = pcall(loader.load_theme, color_name) - if ok and theme then return theme end + if ok and theme then + return theme + end end --------------- @@ -30,7 +32,9 @@ local function getHi(scope, syntaxlist) scope = 'bg' end end - if color[scope] then return color[scope] end + if color[scope] then + return color[scope] + end end end return '#000000' @@ -38,19 +42,18 @@ end -- truns #rrggbb -> { red, green, blue } local function rgb_str2num(rgb_color_str) - if rgb_color_str:find('#') == 1 then + if rgb_color_str:find '#' == 1 then rgb_color_str = rgb_color_str:sub(2, #rgb_color_str) end local red = tonumber(rgb_color_str:sub(1, 2), 16) local green = tonumber(rgb_color_str:sub(3, 4), 16) local blue = tonumber(rgb_color_str:sub(5, 6), 16) - return {red = red, green = green, blue = blue} + return { red = red, green = green, blue = blue } end -- turns { red, green, blue } -> #rrggbb local function rgb_num2str(rgb_color_num) - local rgb_color_str = string.format('#%02x%02x%02x', rgb_color_num.red, - rgb_color_num.green, rgb_color_num.blue) + local rgb_color_str = string.format('#%02x%02x%02x', rgb_color_num.red, rgb_color_num.green, rgb_color_num.blue) return rgb_color_str end @@ -71,8 +74,12 @@ end -- clamps the val between left and right local function clamp(val, left, right) - if val > right then return right end - if val < left then return left end + if val > right then + return right + end + if val < left then + return left + end return val end @@ -100,27 +107,31 @@ local function apply_contrast(highlight) local hightlight_bg_avg = get_color_avg(highlight.bg) local contrast_threshold_config = clamp(contrast_threshold, 0, 0.5) local contranst_change_step = 5 - if hightlight_bg_avg > .5 then contranst_change_step = -contranst_change_step end + if hightlight_bg_avg > 0.5 then + contranst_change_step = -contranst_change_step + end -- donn't waste too much time here max 25 interation should be more than enough local iteration_count = 1 - while (math.abs(get_color_avg(highlight.fg) - hightlight_bg_avg) < - contrast_threshold_config and iteration_count < 25) do + while + math.abs(get_color_avg(highlight.fg) - hightlight_bg_avg) < contrast_threshold_config and iteration_count < 25 + do highlight.fg = contrast_modifier(highlight.fg, contranst_change_step) iteration_count = iteration_count + 1 end end -- Get the colors to create theme +-- stylua: ignore local colors = { - normal = getHi('bg', {'PmenuSel', 'PmenuThumb', 'TabLineSel'}), - insert = getHi('fg', {'String', 'MoreMsg'}), - replace = getHi('fg', {'Number', 'Type'}), - visual = getHi('fg', {'Special', 'Boolean', 'Constant'}), - command = getHi('fg', {'Identifier'}), - back1 = getHi('bg', {'Normal', 'StatusLineNC'}), - fore = getHi('fg', {'Normal', 'StatusLine'}), - back2 = getHi('bg', {'StatusLine'}) + normal = getHi('bg', { 'PmenuSel', 'PmenuThumb', 'TabLineSel' }), + insert = getHi('fg', { 'String', 'MoreMsg' }), + replace = getHi('fg', { 'Number', 'Type' }), + visual = getHi('fg', { 'Special', 'Boolean', 'Constant' }), + command = getHi('fg', { 'Identifier' }), + back1 = getHi('bg', { 'Normal', 'StatusLineNC' }), + fore = getHi('fg', { 'Normal', 'StatusLine' }), + back2 = getHi('bg', { 'StatusLine' }), } -- Change brightness of colors @@ -139,30 +150,30 @@ end -- basic theme defination local M = { normal = { - a = {bg = colors.normal, fg = colors.back1, gui = 'bold'}, - b = {bg = colors.back1, fg = colors.normal}, - c = {bg = colors.back2, fg = colors.fore} + a = { bg = colors.normal, fg = colors.back1, gui = 'bold' }, + b = { bg = colors.back1, fg = colors.normal }, + c = { bg = colors.back2, fg = colors.fore }, }, insert = { - a = {bg = colors.insert, fg = colors.back1, gui = 'bold'}, - b = {bg = colors.back1, fg = colors.insert}, - c = {bg = colors.back2, fg = colors.fore} + a = { bg = colors.insert, fg = colors.back1, gui = 'bold' }, + b = { bg = colors.back1, fg = colors.insert }, + c = { bg = colors.back2, fg = colors.fore }, }, replace = { - a = {bg = colors.replace, fg = colors.back1, gui = 'bold'}, - b = {bg = colors.back1, fg = colors.replace}, - c = {bg = colors.back2, fg = colors.fore} + a = { bg = colors.replace, fg = colors.back1, gui = 'bold' }, + b = { bg = colors.back1, fg = colors.replace }, + c = { bg = colors.back2, fg = colors.fore }, }, visual = { - a = {bg = colors.visual, fg = colors.back1, gui = 'bold'}, - b = {bg = colors.back1, fg = colors.visual}, - c = {bg = colors.back2, fg = colors.fore} + a = { bg = colors.visual, fg = colors.back1, gui = 'bold' }, + b = { bg = colors.back1, fg = colors.visual }, + c = { bg = colors.back2, fg = colors.fore }, }, command = { - a = {bg = colors.command, fg = colors.back1, gui = 'bold'}, - b = {bg = colors.back1, fg = colors.command}, - c = {bg = colors.back2, fg = colors.fore} - } + a = { bg = colors.command, fg = colors.back1, gui = 'bold' }, + b = { bg = colors.back1, fg = colors.command }, + c = { bg = colors.back2, fg = colors.fore }, + }, } M.terminal = M.command @@ -170,7 +181,9 @@ M.inactive = M.normal -- Apply prpper contrast so text is readable for _, section in pairs(M) do - for _, highlight in pairs(section) do apply_contrast(highlight) end + for _, highlight in pairs(section) do + apply_contrast(highlight) + end end return M diff --git a/lua/lualine/themes/ayu_dark.lua b/lua/lualine/themes/ayu_dark.lua index a90bf87..a116e97 100644 --- a/lua/lualine/themes/ayu_dark.lua +++ b/lua/lualine/themes/ayu_dark.lua @@ -16,25 +16,25 @@ local colors = { return { visual = { - a = {fg = colors.color2, bg = colors.color3, gui = 'bold'}, - b = {fg = colors.color4, bg = colors.color5} + a = { fg = colors.color2, bg = colors.color3, gui = 'bold' }, + b = { fg = colors.color4, bg = colors.color5 }, }, replace = { - a = {fg = colors.color2, bg = colors.color8, gui = 'bold'}, - b = {fg = colors.color4, bg = colors.color5} + a = { fg = colors.color2, bg = colors.color8, gui = 'bold' }, + b = { fg = colors.color4, bg = colors.color5 }, }, inactive = { - c = {fg = colors.color4, bg = colors.color2}, - a = {fg = colors.color4, bg = colors.color5, gui = 'bold'}, - b = {fg = colors.color4, bg = colors.color5} + c = { fg = colors.color4, bg = colors.color2 }, + a = { fg = colors.color4, bg = colors.color5, gui = 'bold' }, + b = { fg = colors.color4, bg = colors.color5 }, }, normal = { - c = {fg = colors.color9, bg = colors.color2}, - a = {fg = colors.color2, bg = colors.color10, gui = 'bold'}, - b = {fg = colors.color4, bg = colors.color5} + c = { fg = colors.color9, bg = colors.color2 }, + a = { fg = colors.color2, bg = colors.color10, gui = 'bold' }, + b = { fg = colors.color4, bg = colors.color5 }, }, insert = { - a = {fg = colors.color2, bg = colors.color13, gui = 'bold'}, - b = {fg = colors.color4, bg = colors.color5} - } + a = { fg = colors.color2, bg = colors.color13, gui = 'bold' }, + b = { fg = colors.color4, bg = colors.color5 }, + }, } diff --git a/lua/lualine/themes/ayu_light.lua b/lua/lualine/themes/ayu_light.lua index b1718f2..bcb3f0e 100644 --- a/lua/lualine/themes/ayu_light.lua +++ b/lua/lualine/themes/ayu_light.lua @@ -16,25 +16,25 @@ local colors = { return { visual = { - a = {fg = colors.color2, bg = colors.color3, gui = 'bold'}, - b = {fg = colors.color4, bg = colors.color5} + a = { fg = colors.color2, bg = colors.color3, gui = 'bold' }, + b = { fg = colors.color4, bg = colors.color5 }, }, replace = { - a = {fg = colors.color2, bg = colors.color8, gui = 'bold'}, - b = {fg = colors.color4, bg = colors.color5} + a = { fg = colors.color2, bg = colors.color8, gui = 'bold' }, + b = { fg = colors.color4, bg = colors.color5 }, }, inactive = { - c = {fg = colors.color4, bg = colors.color2}, - a = {fg = colors.color4, bg = colors.color5, gui = 'bold'}, - b = {fg = colors.color4, bg = colors.color5} + c = { fg = colors.color4, bg = colors.color2 }, + a = { fg = colors.color4, bg = colors.color5, gui = 'bold' }, + b = { fg = colors.color4, bg = colors.color5 }, }, normal = { - c = {fg = colors.color9, bg = colors.color2}, - a = {fg = colors.color2, bg = colors.color10, gui = 'bold'}, - b = {fg = colors.color4, bg = colors.color5} + c = { fg = colors.color9, bg = colors.color2 }, + a = { fg = colors.color2, bg = colors.color10, gui = 'bold' }, + b = { fg = colors.color4, bg = colors.color5 }, }, insert = { - a = {fg = colors.color2, bg = colors.color13, gui = 'bold'}, - b = {fg = colors.color4, bg = colors.color5} - } + a = { fg = colors.color2, bg = colors.color13, gui = 'bold' }, + b = { fg = colors.color4, bg = colors.color5 }, + }, } diff --git a/lua/lualine/themes/ayu_mirage.lua b/lua/lualine/themes/ayu_mirage.lua index 7264403..8a6b55e 100644 --- a/lua/lualine/themes/ayu_mirage.lua +++ b/lua/lualine/themes/ayu_mirage.lua @@ -16,25 +16,25 @@ local colors = { return { visual = { - a = {fg = colors.color2, bg = colors.color3, gui = 'bold'}, - b = {fg = colors.color4, bg = colors.color5} + a = { fg = colors.color2, bg = colors.color3, gui = 'bold' }, + b = { fg = colors.color4, bg = colors.color5 }, }, replace = { - a = {fg = colors.color2, bg = colors.color8, gui = 'bold'}, - b = {fg = colors.color4, bg = colors.color5} + a = { fg = colors.color2, bg = colors.color8, gui = 'bold' }, + b = { fg = colors.color4, bg = colors.color5 }, }, inactive = { - c = {fg = colors.color4, bg = colors.color2}, - a = {fg = colors.color4, bg = colors.color5, gui = 'bold'}, - b = {fg = colors.color4, bg = colors.color5} + c = { fg = colors.color4, bg = colors.color2 }, + a = { fg = colors.color4, bg = colors.color5, gui = 'bold' }, + b = { fg = colors.color4, bg = colors.color5 }, }, normal = { - c = {fg = colors.color9, bg = colors.color2}, - a = {fg = colors.color2, bg = colors.color10, gui = 'bold'}, - b = {fg = colors.color4, bg = colors.color5} + c = { fg = colors.color9, bg = colors.color2 }, + a = { fg = colors.color2, bg = colors.color10, gui = 'bold' }, + b = { fg = colors.color4, bg = colors.color5 }, }, insert = { - a = {fg = colors.color2, bg = colors.color13, gui = 'bold'}, - b = {fg = colors.color4, bg = colors.color5} - } + a = { fg = colors.color2, bg = colors.color13, gui = 'bold' }, + b = { fg = colors.color4, bg = colors.color5 }, + }, } diff --git a/lua/lualine/themes/codedark.lua b/lua/lualine/themes/codedark.lua index 775eb33..cc5ffda 100644 --- a/lua/lualine/themes/codedark.lua +++ b/lua/lualine/themes/codedark.lua @@ -13,26 +13,26 @@ local colors = { return { normal = { - b = {fg = colors.green, bg = colors.black}, - a = {fg = colors.black, bg = colors.green, gui = 'bold'}, - c = {fg = colors.white, bg = colors.black} + b = { fg = colors.green, bg = colors.black }, + a = { fg = colors.black, bg = colors.green, gui = 'bold' }, + c = { fg = colors.white, bg = colors.black }, }, visual = { - b = {fg = colors.pink, bg = colors.black}, - a = {fg = colors.black, bg = colors.pink, gui = 'bold'} + b = { fg = colors.pink, bg = colors.black }, + a = { fg = colors.black, bg = colors.pink, gui = 'bold' }, }, inactive = { - b = {fg = colors.black, bg = colors.blue}, - a = {fg = colors.white, bg = colors.gray, gui = 'bold'} + b = { fg = colors.black, bg = colors.blue }, + a = { fg = colors.white, bg = colors.gray, gui = 'bold' }, }, replace = { - b = {fg = colors.lightred, bg = colors.black}, - a = {fg = colors.black, bg = colors.lightred, gui = 'bold'}, - c = {fg = colors.white, bg = colors.black} + b = { fg = colors.lightred, bg = colors.black }, + a = { fg = colors.black, bg = colors.lightred, gui = 'bold' }, + c = { fg = colors.white, bg = colors.black }, }, insert = { - b = {fg = colors.blue, bg = colors.black}, - a = {fg = colors.black, bg = colors.blue, gui = 'bold'}, - c = {fg = colors.white, bg = colors.black} - } + b = { fg = colors.blue, bg = colors.black }, + a = { fg = colors.black, bg = colors.blue, gui = 'bold' }, + c = { fg = colors.white, bg = colors.black }, + }, } diff --git a/lua/lualine/themes/dracula.lua b/lua/lualine/themes/dracula.lua index e32b45c..6387201 100644 --- a/lua/lualine/themes/dracula.lua +++ b/lua/lualine/themes/dracula.lua @@ -16,33 +16,33 @@ local colors = { return { normal = { - a = {bg = colors.purple, fg = colors.black, gui = 'bold'}, - b = {bg = colors.lightgray, fg = colors.white}, - c = {bg = colors.gray, fg = colors.white} + a = { bg = colors.purple, fg = colors.black, gui = 'bold' }, + b = { bg = colors.lightgray, fg = colors.white }, + c = { bg = colors.gray, fg = colors.white }, }, insert = { - a = {bg = colors.green, fg = colors.black, gui = 'bold'}, - b = {bg = colors.lightgray, fg = colors.white}, - c = {bg = colors.gray, fg = colors.white} + a = { bg = colors.green, fg = colors.black, gui = 'bold' }, + b = { bg = colors.lightgray, fg = colors.white }, + c = { bg = colors.gray, fg = colors.white }, }, visual = { - a = {bg = colors.yellow, fg = colors.black, gui = 'bold'}, - b = {bg = colors.lightgray, fg = colors.white}, - c = {bg = colors.gray, fg = colors.white} + a = { bg = colors.yellow, fg = colors.black, gui = 'bold' }, + b = { bg = colors.lightgray, fg = colors.white }, + c = { bg = colors.gray, fg = colors.white }, }, replace = { - a = {bg = colors.red, fg = colors.black, gui = 'bold'}, - b = {bg = colors.lightgray, fg = colors.white}, - c = {bg = colors.gray, fg = colors.white} + a = { bg = colors.red, fg = colors.black, gui = 'bold' }, + b = { bg = colors.lightgray, fg = colors.white }, + c = { bg = colors.gray, fg = colors.white }, }, command = { - a = {bg = colors.orange, fg = colors.black, gui = 'bold'}, - b = {bg = colors.lightgray, fg = colors.white}, - c = {bg = colors.gray, fg = colors.white} + a = { bg = colors.orange, fg = colors.black, gui = 'bold' }, + b = { bg = colors.lightgray, fg = colors.white }, + c = { bg = colors.gray, fg = colors.white }, }, inactive = { - a = {bg = colors.gray, fg = colors.white, gui = 'bold'}, - b = {bg = colors.lightgray, fg = colors.white}, - c = {bg = colors.gray, fg = colors.white} - } + a = { bg = colors.gray, fg = colors.white, gui = 'bold' }, + b = { bg = colors.lightgray, fg = colors.white }, + c = { bg = colors.gray, fg = colors.white }, + }, } diff --git a/lua/lualine/themes/everforest.lua b/lua/lualine/themes/everforest.lua index 4397936..d71b8a9 100644 --- a/lua/lualine/themes/everforest.lua +++ b/lua/lualine/themes/everforest.lua @@ -16,38 +16,38 @@ local colors = { return { normal = { - a = {bg = colors.green, fg = colors.bg0, gui = 'bold'}, - b = {bg = colors.bg3, fg = colors.fg}, - c = {bg = colors.bg1, fg = colors.fg} + a = { bg = colors.green, fg = colors.bg0, gui = 'bold' }, + b = { bg = colors.bg3, fg = colors.fg }, + c = { bg = colors.bg1, fg = colors.fg }, }, insert = { - a = {bg = colors.fg, fg = colors.bg0, gui = 'bold'}, - b = {bg = colors.bg3, fg = colors.fg}, - c = {bg = colors.bg1, fg = colors.fg} + a = { bg = colors.fg, fg = colors.bg0, gui = 'bold' }, + b = { bg = colors.bg3, fg = colors.fg }, + c = { bg = colors.bg1, fg = colors.fg }, }, visual = { - a = {bg = colors.red, fg = colors.bg0, gui = 'bold'}, - b = {bg = colors.bg3, fg = colors.fg}, - c = {bg = colors.bg1, fg = colors.fg} + a = { bg = colors.red, fg = colors.bg0, gui = 'bold' }, + b = { bg = colors.bg3, fg = colors.fg }, + c = { bg = colors.bg1, fg = colors.fg }, }, replace = { - a = {bg = colors.orange, fg = colors.bg0, gui = 'bold'}, - b = {bg = colors.bg3, fg = colors.fg}, - c = {bg = colors.bg1, fg = colors.fg} + a = { bg = colors.orange, fg = colors.bg0, gui = 'bold' }, + b = { bg = colors.bg3, fg = colors.fg }, + c = { bg = colors.bg1, fg = colors.fg }, }, command = { - a = {bg = colors.aqua, fg = colors.bg0, gui = 'bold'}, - b = {bg = colors.bg3, fg = colors.fg}, - c = {bg = colors.bg1, fg = colors.fg} + a = { bg = colors.aqua, fg = colors.bg0, gui = 'bold' }, + b = { bg = colors.bg3, fg = colors.fg }, + c = { bg = colors.bg1, fg = colors.fg }, }, terminal = { - a = {bg = colors.purple, fg = colors.bg0, gui = 'bold'}, - b = {bg = colors.bg3, fg = colors.fg}, - c = {bg = colors.bg1, fg = colors.fg} + a = { bg = colors.purple, fg = colors.bg0, gui = 'bold' }, + b = { bg = colors.bg3, fg = colors.fg }, + c = { bg = colors.bg1, fg = colors.fg }, }, inactive = { - a = {bg = colors.bg1, fg = colors.grey1, gui = 'bold'}, - b = {bg = colors.bg1, fg = colors.grey1}, - c = {bg = colors.bg1, fg = colors.grey1} - } + a = { bg = colors.bg1, fg = colors.grey1, gui = 'bold' }, + b = { bg = colors.bg1, fg = colors.grey1 }, + c = { bg = colors.bg1, fg = colors.grey1 }, + }, } diff --git a/lua/lualine/themes/gruvbox-material.lua b/lua/lualine/themes/gruvbox-material.lua index fad89fc..5e2aeb7 100644 --- a/lua/lualine/themes/gruvbox-material.lua +++ b/lua/lualine/themes/gruvbox-material.lua @@ -16,14 +16,14 @@ local colors = { return { normal = { - a = {fg = colors.fg1, bg = colors.color4, gui = 'bold'}, - b = {fg = colors.fg2, bg = colors.color2}, - c = {fg = colors.fg2, bg = colors.color3} + a = { fg = colors.fg1, bg = colors.color4, gui = 'bold' }, + b = { fg = colors.fg2, bg = colors.color2 }, + c = { fg = colors.fg2, bg = colors.color3 }, }, - command = {a = {fg = colors.fg1, bg = colors.color5, gui = 'bold'}}, - inactive = {a = {fg = colors.fg2, bg = colors.color2}}, - insert = {a = {fg = colors.fg1, bg = colors.color6, gui = 'bold'}}, - replace = {a = {fg = colors.fg1, bg = colors.color7, gui = 'bold'}}, - terminal = {a = {fg = colors.fg1, bg = colors.color8, gui = 'bold'}}, - visual = {a = {fg = colors.fg1, bg = colors.color9, gui = 'bold'}} + command = { a = { fg = colors.fg1, bg = colors.color5, gui = 'bold' } }, + inactive = { a = { fg = colors.fg2, bg = colors.color2 } }, + insert = { a = { fg = colors.fg1, bg = colors.color6, gui = 'bold' } }, + replace = { a = { fg = colors.fg1, bg = colors.color7, gui = 'bold' } }, + terminal = { a = { fg = colors.fg1, bg = colors.color8, gui = 'bold' } }, + visual = { a = { fg = colors.fg1, bg = colors.color9, gui = 'bold' } }, } diff --git a/lua/lualine/themes/gruvbox_dark.lua b/lua/lualine/themes/gruvbox_dark.lua index 3646cad..00bd62d 100644 --- a/lua/lualine/themes/gruvbox_dark.lua +++ b/lua/lualine/themes/gruvbox_dark.lua @@ -16,33 +16,33 @@ local colors = { return { normal = { - a = {bg = colors.gray, fg = colors.black, gui = 'bold'}, - b = {bg = colors.lightgray, fg = colors.white}, - c = {bg = colors.darkgray, fg = colors.gray} + a = { bg = colors.gray, fg = colors.black, gui = 'bold' }, + b = { bg = colors.lightgray, fg = colors.white }, + c = { bg = colors.darkgray, fg = colors.gray }, }, insert = { - a = {bg = colors.blue, fg = colors.black, gui = 'bold'}, - b = {bg = colors.lightgray, fg = colors.white}, - c = {bg = colors.lightgray, fg = colors.white} + a = { bg = colors.blue, fg = colors.black, gui = 'bold' }, + b = { bg = colors.lightgray, fg = colors.white }, + c = { bg = colors.lightgray, fg = colors.white }, }, visual = { - a = {bg = colors.yellow, fg = colors.black, gui = 'bold'}, - b = {bg = colors.lightgray, fg = colors.white}, - c = {bg = colors.inactivegray, fg = colors.black} + a = { bg = colors.yellow, fg = colors.black, gui = 'bold' }, + b = { bg = colors.lightgray, fg = colors.white }, + c = { bg = colors.inactivegray, fg = colors.black }, }, replace = { - a = {bg = colors.red, fg = colors.black, gui = 'bold'}, - b = {bg = colors.lightgray, fg = colors.white}, - c = {bg = colors.black, fg = colors.white} + a = { bg = colors.red, fg = colors.black, gui = 'bold' }, + b = { bg = colors.lightgray, fg = colors.white }, + c = { bg = colors.black, fg = colors.white }, }, command = { - a = {bg = colors.green, fg = colors.black, gui = 'bold'}, - b = {bg = colors.lightgray, fg = colors.white}, - c = {bg = colors.inactivegray, fg = colors.black} + a = { bg = colors.green, fg = colors.black, gui = 'bold' }, + b = { bg = colors.lightgray, fg = colors.white }, + c = { bg = colors.inactivegray, fg = colors.black }, }, inactive = { - a = {bg = colors.darkgray, fg = colors.gray, gui = 'bold'}, - b = {bg = colors.darkgray, fg = colors.gray}, - c = {bg = colors.darkgray, fg = colors.gray} - } + a = { bg = colors.darkgray, fg = colors.gray, gui = 'bold' }, + b = { bg = colors.darkgray, fg = colors.gray }, + c = { bg = colors.darkgray, fg = colors.gray }, + }, } diff --git a/lua/lualine/themes/gruvbox_light.lua b/lua/lualine/themes/gruvbox_light.lua index 2b62052..99bbeff 100644 --- a/lua/lualine/themes/gruvbox_light.lua +++ b/lua/lualine/themes/gruvbox_light.lua @@ -13,33 +13,33 @@ local colors = { return { normal = { - a = {bg = colors.darkgray, fg = colors.white, gui = 'bold'}, - b = {bg = colors.gray, fg = colors.darkgray}, - c = {bg = colors.lightgray, fg = colors.darkgray}, + a = { bg = colors.darkgray, fg = colors.white, gui = 'bold' }, + b = { bg = colors.gray, fg = colors.darkgray }, + c = { bg = colors.lightgray, fg = colors.darkgray }, }, insert = { - a = {bg = colors.blue, fg = colors.white, gui = 'bold'}, - b = {bg = colors.gray, fg = colors.darkgray}, - c = {bg = colors.gray, fg = colors.black}, + a = { bg = colors.blue, fg = colors.white, gui = 'bold' }, + b = { bg = colors.gray, fg = colors.darkgray }, + c = { bg = colors.gray, fg = colors.black }, }, visual = { - a = {bg = colors.orange, fg = colors.white, gui = 'bold'}, - b = {bg = colors.gray, fg = colors.darkgray}, - c = {bg = colors.darkgray, fg = colors.white}, + a = { bg = colors.orange, fg = colors.white, gui = 'bold' }, + b = { bg = colors.gray, fg = colors.darkgray }, + c = { bg = colors.darkgray, fg = colors.white }, }, replace = { - a = {bg = colors.green, fg = colors.white, gui = 'bold'}, - b = {bg = colors.gray, fg = colors.darkgray}, - c = {bg = colors.gray, fg = colors.black}, + a = { bg = colors.green, fg = colors.white, gui = 'bold' }, + b = { bg = colors.gray, fg = colors.darkgray }, + c = { bg = colors.gray, fg = colors.black }, }, command = { - a = {bg = colors.darkgray, fg = colors.white, gui = 'bold'}, - b = {bg = colors.gray, fg = colors.darkgray}, - c = {bg = colors.lightgray, fg = colors.darkgray}, + a = { bg = colors.darkgray, fg = colors.white, gui = 'bold' }, + b = { bg = colors.gray, fg = colors.darkgray }, + c = { bg = colors.lightgray, fg = colors.darkgray }, }, inactive = { - a = {bg = colors.lightgray, fg = colors.inactivegray}, - b = {bg = colors.lightgray, fg = colors.inactivegray}, - c = {bg = colors.lightgray, fg = colors.inactivegray}, - } + a = { bg = colors.lightgray, fg = colors.inactivegray }, + b = { bg = colors.lightgray, fg = colors.inactivegray }, + c = { bg = colors.lightgray, fg = colors.inactivegray }, + }, } diff --git a/lua/lualine/themes/horizon.lua b/lua/lualine/themes/horizon.lua index 0f2a9c2..020d619 100644 --- a/lua/lualine/themes/horizon.lua +++ b/lua/lualine/themes/horizon.lua @@ -16,33 +16,33 @@ local colors = { return { normal = { - a = {bg = colors.gray, fg = colors.black, gui = 'bold'}, - b = {bg = colors.lightgray, fg = colors.white}, - c = {bg = colors.darkgray, fg = colors.white}, + a = { bg = colors.gray, fg = colors.black, gui = 'bold' }, + b = { bg = colors.lightgray, fg = colors.white }, + c = { bg = colors.darkgray, fg = colors.white }, }, insert = { - a = {bg = colors.blue, fg = colors.black, gui = 'bold'}, - b = {bg = colors.lightgray, fg = colors.white}, - c = {bg = colors.darkgray, fg = colors.white} + a = { bg = colors.blue, fg = colors.black, gui = 'bold' }, + b = { bg = colors.lightgray, fg = colors.white }, + c = { bg = colors.darkgray, fg = colors.white }, }, visual = { - a = {bg = colors.yellow, fg = colors.black, gui = 'bold'}, - b = {bg = colors.lightgray, fg = colors.white}, - c = {bg = colors.darkgray, fg = colors.white} + a = { bg = colors.yellow, fg = colors.black, gui = 'bold' }, + b = { bg = colors.lightgray, fg = colors.white }, + c = { bg = colors.darkgray, fg = colors.white }, }, replace = { - a = {bg = colors.red, fg = colors.black, gui = 'bold'}, - b = {bg = colors.lightgray, fg = colors.white}, - c = {bg = colors.darkgray, fg = colors.white} + a = { bg = colors.red, fg = colors.black, gui = 'bold' }, + b = { bg = colors.lightgray, fg = colors.white }, + c = { bg = colors.darkgray, fg = colors.white }, }, command = { - a = {bg = colors.green, fg = colors.black, gui = 'bold'}, - b = {bg = colors.lightgray, fg = colors.white}, - c = {bg = colors.darkgray, fg = colors.white} + a = { bg = colors.green, fg = colors.black, gui = 'bold' }, + b = { bg = colors.lightgray, fg = colors.white }, + c = { bg = colors.darkgray, fg = colors.white }, }, inactive = { - a = {bg = colors.inactivegray, fg = colors.lightgray, gui = 'bold'}, - b = {bg = colors.inactivegray, fg = colors.lightgray}, - c = {bg = colors.inactivegray, fg = colors.lightgray} - } + a = { bg = colors.inactivegray, fg = colors.lightgray, gui = 'bold' }, + b = { bg = colors.inactivegray, fg = colors.lightgray }, + c = { bg = colors.inactivegray, fg = colors.lightgray }, + }, } diff --git a/lua/lualine/themes/iceberg_dark.lua b/lua/lualine/themes/iceberg_dark.lua index c4a3d9f..e6f3f20 100644 --- a/lua/lualine/themes/iceberg_dark.lua +++ b/lua/lualine/themes/iceberg_dark.lua @@ -18,25 +18,25 @@ local colors = { return { visual = { - a = {fg = colors.color2, bg = colors.color3, gui = 'bold'}, - b = {fg = colors.color4, bg = colors.color5} + a = { fg = colors.color2, bg = colors.color3, gui = 'bold' }, + b = { fg = colors.color4, bg = colors.color5 }, }, replace = { - a = {fg = colors.color2, bg = colors.color8, gui = 'bold'}, - b = {fg = colors.color4, bg = colors.color5} + a = { fg = colors.color2, bg = colors.color8, gui = 'bold' }, + b = { fg = colors.color4, bg = colors.color5 }, }, inactive = { - c = {fg = colors.color9, bg = colors.color10}, - a = {fg = colors.color9, bg = colors.color10, gui = 'bold'}, - b = {fg = colors.color9, bg = colors.color10} + c = { fg = colors.color9, bg = colors.color10 }, + a = { fg = colors.color9, bg = colors.color10, gui = 'bold' }, + b = { fg = colors.color9, bg = colors.color10 }, }, normal = { - c = {fg = colors.color9, bg = colors.color10}, - a = {fg = colors.color11, bg = colors.color12, gui = 'bold'}, - b = {fg = colors.color4, bg = colors.color5} + c = { fg = colors.color9, bg = colors.color10 }, + a = { fg = colors.color11, bg = colors.color12, gui = 'bold' }, + b = { fg = colors.color4, bg = colors.color5 }, }, insert = { - a = {fg = colors.color2, bg = colors.color15, gui = 'bold'}, - b = {fg = colors.color4, bg = colors.color5} - } + a = { fg = colors.color2, bg = colors.color15, gui = 'bold' }, + b = { fg = colors.color4, bg = colors.color5 }, + }, } diff --git a/lua/lualine/themes/iceberg_light.lua b/lua/lualine/themes/iceberg_light.lua index 0e50eec..c936b57 100644 --- a/lua/lualine/themes/iceberg_light.lua +++ b/lua/lualine/themes/iceberg_light.lua @@ -16,25 +16,25 @@ local colors = { return { replace = { - b = {fg = colors.color0, bg = colors.color1}, - a = {fg = colors.color0, bg = colors.color2, gui = 'bold'} + b = { fg = colors.color0, bg = colors.color1 }, + a = { fg = colors.color0, bg = colors.color2, gui = 'bold' }, }, visual = { - b = {fg = colors.color0, bg = colors.color1}, - a = {fg = colors.color0, bg = colors.color5, gui = 'bold'} + b = { fg = colors.color0, bg = colors.color1 }, + a = { fg = colors.color0, bg = colors.color5, gui = 'bold' }, }, normal = { - b = {fg = colors.color0, bg = colors.color1}, - a = {fg = colors.color0, bg = colors.color8, gui = 'bold'}, - c = {fg = colors.color9, bg = colors.color10} + b = { fg = colors.color0, bg = colors.color1 }, + a = { fg = colors.color0, bg = colors.color8, gui = 'bold' }, + c = { fg = colors.color9, bg = colors.color10 }, }, inactive = { - b = {fg = colors.color9, bg = colors.color10}, - a = {fg = colors.color9, bg = colors.color10, gui = 'bold'}, - c = {fg = colors.color9, bg = colors.color10} + b = { fg = colors.color9, bg = colors.color10 }, + a = { fg = colors.color9, bg = colors.color10, gui = 'bold' }, + c = { fg = colors.color9, bg = colors.color10 }, }, insert = { - b = {fg = colors.color0, bg = colors.color1}, - a = {fg = colors.color0, bg = colors.color11, gui = 'bold'} - } + b = { fg = colors.color0, bg = colors.color1 }, + a = { fg = colors.color0, bg = colors.color11, gui = 'bold' }, + }, } diff --git a/lua/lualine/themes/jellybeans.lua b/lua/lualine/themes/jellybeans.lua index 571456a..c6f44ad 100644 --- a/lua/lualine/themes/jellybeans.lua +++ b/lua/lualine/themes/jellybeans.lua @@ -17,25 +17,25 @@ local colors = { return { visual = { - a = {fg = colors.color2, bg = colors.color3, gui = 'bold'}, - b = {fg = colors.color4, bg = colors.color5} + a = { fg = colors.color2, bg = colors.color3, gui = 'bold' }, + b = { fg = colors.color4, bg = colors.color5 }, }, replace = { - a = {fg = colors.color2, bg = colors.color8, gui = 'bold'}, - b = {fg = colors.color4, bg = colors.color5} + a = { fg = colors.color2, bg = colors.color8, gui = 'bold' }, + b = { fg = colors.color4, bg = colors.color5 }, }, inactive = { - c = {fg = colors.color9, bg = colors.color2}, - a = {fg = colors.color10, bg = colors.color2, gui = 'bold'}, - b = {fg = colors.color9, bg = colors.color2} + c = { fg = colors.color9, bg = colors.color2 }, + a = { fg = colors.color10, bg = colors.color2, gui = 'bold' }, + b = { fg = colors.color9, bg = colors.color2 }, }, normal = { - c = {fg = colors.color10, bg = colors.color2}, - a = {fg = colors.color2, bg = colors.color11, gui = 'bold'}, - b = {fg = colors.color4, bg = colors.color5} + c = { fg = colors.color10, bg = colors.color2 }, + a = { fg = colors.color2, bg = colors.color11, gui = 'bold' }, + b = { fg = colors.color4, bg = colors.color5 }, }, insert = { - a = {fg = colors.color2, bg = colors.color14, gui = 'bold'}, - b = {fg = colors.color4, bg = colors.color5} - } + a = { fg = colors.color2, bg = colors.color14, gui = 'bold' }, + b = { fg = colors.color4, bg = colors.color5 }, + }, } diff --git a/lua/lualine/themes/material.lua b/lua/lualine/themes/material.lua index 1495aa3..2d2bcb1 100644 --- a/lua/lualine/themes/material.lua +++ b/lua/lualine/themes/material.lua @@ -18,25 +18,25 @@ local colors = { return { normal = { - a = {fg = colors.bg, bg = colors.blue, gui = 'bold'}, - b = {fg = colors.fg, bg = colors.gray3}, - c = {fg = colors.fg, bg = colors.gray2} + a = { fg = colors.bg, bg = colors.blue, gui = 'bold' }, + b = { fg = colors.fg, bg = colors.gray3 }, + c = { fg = colors.fg, bg = colors.gray2 }, }, insert = { - a = {fg = colors.bg, bg = colors.green, gui = 'bold'}, - b = {fg = colors.fg, bg = colors.gray3} + a = { fg = colors.bg, bg = colors.green, gui = 'bold' }, + b = { fg = colors.fg, bg = colors.gray3 }, }, visual = { - a = {fg = colors.bg, bg = colors.purple, gui = 'bold'}, - b = {fg = colors.fg, bg = colors.gray3} + a = { fg = colors.bg, bg = colors.purple, gui = 'bold' }, + b = { fg = colors.fg, bg = colors.gray3 }, }, replace = { - a = {fg = colors.bg, bg = colors.red1, gui = 'bold'}, - b = {fg = colors.fg, bg = colors.gray3} + a = { fg = colors.bg, bg = colors.red1, gui = 'bold' }, + b = { fg = colors.fg, bg = colors.gray3 }, }, inactive = { - a = {fg = colors.fg, bg = colors.bg, gui = 'bold'}, - b = {fg = colors.fg, bg = colors.bg}, - c = {fg = colors.fg, bg = colors.gray2} - } + a = { fg = colors.fg, bg = colors.bg, gui = 'bold' }, + b = { fg = colors.fg, bg = colors.bg }, + c = { fg = colors.fg, bg = colors.gray2 }, + }, } diff --git a/lua/lualine/themes/modus-vivendi.lua b/lua/lualine/themes/modus-vivendi.lua index fc923a7..7170fd3 100644 --- a/lua/lualine/themes/modus-vivendi.lua +++ b/lua/lualine/themes/modus-vivendi.lua @@ -16,33 +16,33 @@ local colors = { return { normal = { - a = {bg = colors.blue, fg = colors.lightgray, gui = 'bold'}, - b = {bg = colors.lightgray, fg = colors.blue}, - c = {bg = colors.gray, fg = colors.white} + a = { bg = colors.blue, fg = colors.lightgray, gui = 'bold' }, + b = { bg = colors.lightgray, fg = colors.blue }, + c = { bg = colors.gray, fg = colors.white }, }, insert = { - a = {bg = colors.cyan, fg = colors.lightgray, gui = 'bold'}, - b = {bg = colors.lightgray, fg = colors.cyan}, - c = {bg = colors.gray, fg = colors.white} + a = { bg = colors.cyan, fg = colors.lightgray, gui = 'bold' }, + b = { bg = colors.lightgray, fg = colors.cyan }, + c = { bg = colors.gray, fg = colors.white }, }, visual = { - a = {bg = colors.magenta, fg = colors.lightgray, gui = 'bold'}, - b = {bg = colors.lightgray, fg = colors.magenta}, - c = {bg = colors.gray, fg = colors.white} + a = { bg = colors.magenta, fg = colors.lightgray, gui = 'bold' }, + b = { bg = colors.lightgray, fg = colors.magenta }, + c = { bg = colors.gray, fg = colors.white }, }, replace = { - a = {bg = colors.red, fg = colors.lightgray, gui = 'bold'}, - b = {bg = colors.lightgray, fg = colors.red}, - c = {bg = colors.gray, fg = colors.white} + a = { bg = colors.red, fg = colors.lightgray, gui = 'bold' }, + b = { bg = colors.lightgray, fg = colors.red }, + c = { bg = colors.gray, fg = colors.white }, }, command = { - a = {bg = colors.green, fg = colors.lightgray, gui = 'bold'}, - b = {bg = colors.lightgray, fg = colors.green}, - c = {bg = colors.gray, fg = colors.white} + a = { bg = colors.green, fg = colors.lightgray, gui = 'bold' }, + b = { bg = colors.lightgray, fg = colors.green }, + c = { bg = colors.gray, fg = colors.white }, }, inactive = { - a = {bg = colors.darkgray, fg = colors.lightgray, gui = 'bold'}, - b = {bg = colors.darkgray, fg = colors.lightgray}, - c = {bg = colors.darkgray, fg = colors.lightgray} - } + a = { bg = colors.darkgray, fg = colors.lightgray, gui = 'bold' }, + b = { bg = colors.darkgray, fg = colors.lightgray }, + c = { bg = colors.darkgray, fg = colors.lightgray }, + }, } diff --git a/lua/lualine/themes/molokai.lua b/lua/lualine/themes/molokai.lua index 31328e8..c7909de 100644 --- a/lua/lualine/themes/molokai.lua +++ b/lua/lualine/themes/molokai.lua @@ -16,16 +16,16 @@ local colors = { return { normal = { - a = {fg = colors.black, bg = colors.cyan, gui = 'bold'}, - b = {fg = colors.black, bg = colors.pink}, - c = {fg = colors.orange, bg = colors.black} + a = { fg = colors.black, bg = colors.cyan, gui = 'bold' }, + b = { fg = colors.black, bg = colors.pink }, + c = { fg = colors.orange, bg = colors.black }, }, - insert = {a = {fg = colors.black, bg = colors.green, gui = 'bold'}}, - visual = {a = {fg = colors.black, bg = colors.yellow, gui = 'bold'}}, - replace = {a = {fg = colors.black, bg = colors.red, gui = 'bold'}}, + insert = { a = { fg = colors.black, bg = colors.green, gui = 'bold' } }, + visual = { a = { fg = colors.black, bg = colors.yellow, gui = 'bold' } }, + replace = { a = { fg = colors.black, bg = colors.red, gui = 'bold' } }, inactive = { - a = {fg = colors.pink, bg = colors.black, gui = 'bold'}, - b = {fg = colors.white, bg = colors.pink}, - c = {fg = colors.gray, bg = colors.black} - } + a = { fg = colors.pink, bg = colors.black, gui = 'bold' }, + b = { fg = colors.white, bg = colors.pink }, + c = { fg = colors.gray, bg = colors.black }, + }, } diff --git a/lua/lualine/themes/moonfly.lua b/lua/lualine/themes/moonfly.lua index d8a2891..cc83277 100644 --- a/lua/lualine/themes/moonfly.lua +++ b/lua/lualine/themes/moonfly.lua @@ -16,25 +16,25 @@ local colors = { return { replace = { - a = {fg = colors.color0, bg = colors.color1, gui = 'bold'}, - b = {fg = colors.color2, bg = colors.color3} + a = { fg = colors.color0, bg = colors.color1, gui = 'bold' }, + b = { fg = colors.color2, bg = colors.color3 }, }, inactive = { - a = {fg = colors.color6, bg = colors.color3, gui = 'bold'}, - b = {fg = colors.color6, bg = colors.color3}, - c = {fg = colors.color6, bg = colors.color3} + a = { fg = colors.color6, bg = colors.color3, gui = 'bold' }, + b = { fg = colors.color6, bg = colors.color3 }, + c = { fg = colors.color6, bg = colors.color3 }, }, normal = { - a = {fg = colors.color0, bg = colors.color7, gui = 'bold'}, - b = {fg = colors.color2, bg = colors.color3}, - c = {fg = colors.color2, bg = colors.color3} + a = { fg = colors.color0, bg = colors.color7, gui = 'bold' }, + b = { fg = colors.color2, bg = colors.color3 }, + c = { fg = colors.color2, bg = colors.color3 }, }, visual = { - a = {fg = colors.color0, bg = colors.color8, gui = 'bold'}, - b = {fg = colors.color2, bg = colors.color3} + a = { fg = colors.color0, bg = colors.color8, gui = 'bold' }, + b = { fg = colors.color2, bg = colors.color3 }, }, insert = { - a = {fg = colors.color0, bg = colors.color2, gui = 'bold'}, - b = {fg = colors.color2, bg = colors.color3} - } + a = { fg = colors.color0, bg = colors.color2, gui = 'bold' }, + b = { fg = colors.color2, bg = colors.color3 }, + }, } diff --git a/lua/lualine/themes/nightfly.lua b/lua/lualine/themes/nightfly.lua index 7516841..3df5b18 100644 --- a/lua/lualine/themes/nightfly.lua +++ b/lua/lualine/themes/nightfly.lua @@ -13,25 +13,25 @@ local colors = { return { replace = { - a = {fg = colors.color0, bg = colors.color1, gui = 'bold'}, - b = {fg = colors.color2, bg = colors.color3} + a = { fg = colors.color0, bg = colors.color1, gui = 'bold' }, + b = { fg = colors.color2, bg = colors.color3 }, }, inactive = { - a = {fg = colors.color6, bg = colors.color3, gui = 'bold'}, - b = {fg = colors.color6, bg = colors.color3}, - c = {fg = colors.color6, bg = colors.color3} + a = { fg = colors.color6, bg = colors.color3, gui = 'bold' }, + b = { fg = colors.color6, bg = colors.color3 }, + c = { fg = colors.color6, bg = colors.color3 }, }, normal = { - a = {fg = colors.color0, bg = colors.color7, gui = 'bold'}, - b = {fg = colors.color2, bg = colors.color3}, - c = {fg = colors.color2, bg = colors.color3} + a = { fg = colors.color0, bg = colors.color7, gui = 'bold' }, + b = { fg = colors.color2, bg = colors.color3 }, + c = { fg = colors.color2, bg = colors.color3 }, }, visual = { - a = {fg = colors.color0, bg = colors.color8, gui = 'bold'}, - b = {fg = colors.color2, bg = colors.color3} + a = { fg = colors.color0, bg = colors.color8, gui = 'bold' }, + b = { fg = colors.color2, bg = colors.color3 }, }, insert = { - a = {fg = colors.color0, bg = colors.color2, gui = 'bold'}, - b = {fg = colors.color2, bg = colors.color3} - } + a = { fg = colors.color0, bg = colors.color2, gui = 'bold' }, + b = { fg = colors.color2, bg = colors.color3 }, + }, } diff --git a/lua/lualine/themes/nord.lua b/lua/lualine/themes/nord.lua index 7eea741..2b3b4c2 100644 --- a/lua/lualine/themes/nord.lua +++ b/lua/lualine/themes/nord.lua @@ -13,17 +13,16 @@ local colors = { return { normal = { - a = {fg = colors.nord1, bg = colors.nord8, gui = 'bold'}, - b = {fg = colors.nord5, bg = colors.nord1}, - c = {fg = colors.nord5, bg = colors.nord3} + a = { fg = colors.nord1, bg = colors.nord8, gui = 'bold' }, + b = { fg = colors.nord5, bg = colors.nord1 }, + c = { fg = colors.nord5, bg = colors.nord3 }, }, - insert = {a = {fg = colors.nord1, bg = colors.nord6, gui = 'bold'}}, - visual = {a = {fg = colors.nord1, bg = colors.nord7, gui = 'bold'}}, - replace = {a = {fg = colors.nord1, bg = colors.nord13, gui = 'bold'}}, + insert = { a = { fg = colors.nord1, bg = colors.nord6, gui = 'bold' } }, + visual = { a = { fg = colors.nord1, bg = colors.nord7, gui = 'bold' } }, + replace = { a = { fg = colors.nord1, bg = colors.nord13, gui = 'bold' } }, inactive = { - a = {fg = colors.nord1, bg = colors.nord8, gui = 'bold'}, - b = {fg = colors.nord5, bg = colors.nord1}, - c = {fg = colors.nord5, bg = colors.nord1} - } + a = { fg = colors.nord1, bg = colors.nord8, gui = 'bold' }, + b = { fg = colors.nord5, bg = colors.nord1 }, + c = { fg = colors.nord5, bg = colors.nord1 }, + }, } - diff --git a/lua/lualine/themes/onedark.lua b/lua/lualine/themes/onedark.lua index 421ed17..f020e36 100644 --- a/lua/lualine/themes/onedark.lua +++ b/lua/lualine/themes/onedark.lua @@ -18,16 +18,16 @@ local colors = { return { normal = { - a = {fg = colors.bg, bg = colors.green, gui = 'bold'}, - b = {fg = colors.fg, bg = colors.gray3}, - c = {fg = colors.fg, bg = colors.gray2} + a = { fg = colors.bg, bg = colors.green, gui = 'bold' }, + b = { fg = colors.fg, bg = colors.gray3 }, + c = { fg = colors.fg, bg = colors.gray2 }, }, - insert = {a = {fg = colors.bg, bg = colors.blue, gui = 'bold'}}, - visual = {a = {fg = colors.bg, bg = colors.purple, gui = 'bold'}}, - replace = {a = {fg = colors.bg, bg = colors.red1, gui = 'bold'}}, + insert = { a = { fg = colors.bg, bg = colors.blue, gui = 'bold' } }, + visual = { a = { fg = colors.bg, bg = colors.purple, gui = 'bold' } }, + replace = { a = { fg = colors.bg, bg = colors.red1, gui = 'bold' } }, inactive = { - a = {fg = colors.gray1, bg = colors.bg, gui = 'bold'}, - b = {fg = colors.gray1, bg = colors.bg}, - c = {fg = colors.gray1, bg = colors.gray2} - } + a = { fg = colors.gray1, bg = colors.bg, gui = 'bold' }, + b = { fg = colors.gray1, bg = colors.bg }, + c = { fg = colors.gray1, bg = colors.gray2 }, + }, } diff --git a/lua/lualine/themes/onelight.lua b/lua/lualine/themes/onelight.lua index e8a3c35..bc5c5f3 100644 --- a/lua/lualine/themes/onelight.lua +++ b/lua/lualine/themes/onelight.lua @@ -18,17 +18,16 @@ local colors = { return { normal = { - a = {fg = colors.bg, bg = colors.green, gui = 'bold'}, - b = {fg = colors.fg, bg = colors.gray3}, - c = {fg = colors.fg, bg = colors.gray2} + a = { fg = colors.bg, bg = colors.green, gui = 'bold' }, + b = { fg = colors.fg, bg = colors.gray3 }, + c = { fg = colors.fg, bg = colors.gray2 }, }, - insert = {a = {fg = colors.bg, bg = colors.blue, gui = 'bold'}}, - visual = {a = {fg = colors.bg, bg = colors.purple, gui = 'bold'}}, - replace = {a = {fg = colors.bg, bg = colors.red1, gui = 'bold'}}, + insert = { a = { fg = colors.bg, bg = colors.blue, gui = 'bold' } }, + visual = { a = { fg = colors.bg, bg = colors.purple, gui = 'bold' } }, + replace = { a = { fg = colors.bg, bg = colors.red1, gui = 'bold' } }, inactive = { - a = {fg = colors.bg, bg = colors.gray3, gui = 'bold'}, - b = {fg = colors.bg, bg = colors.gray3}, - c = {fg = colors.gray3, bg = colors.gray2} - } - + a = { fg = colors.bg, bg = colors.gray3, gui = 'bold' }, + b = { fg = colors.bg, bg = colors.gray3 }, + c = { fg = colors.gray3, bg = colors.gray2 }, + }, } diff --git a/lua/lualine/themes/palenight.lua b/lua/lualine/themes/palenight.lua index 570c71b..5e66dab 100644 --- a/lua/lualine/themes/palenight.lua +++ b/lua/lualine/themes/palenight.lua @@ -23,25 +23,25 @@ local colors = { return { normal = { - a = {fg = colors.black, bg = colors.purple, gui = 'bold'}, - b = {fg = colors.purple, bg = colors.menu_grey}, - c = {fg = colors.comment_grey, bg = colors.black} + a = { fg = colors.black, bg = colors.purple, gui = 'bold' }, + b = { fg = colors.purple, bg = colors.menu_grey }, + c = { fg = colors.comment_grey, bg = colors.black }, }, insert = { - a = {fg = colors.black, bg = colors.blue, gui = 'bold'}, - b = {fg = colors.blue, bg = colors.menu_grey} + a = { fg = colors.black, bg = colors.blue, gui = 'bold' }, + b = { fg = colors.blue, bg = colors.menu_grey }, }, visual = { - a = {fg = colors.black, bg = colors.cyan, gui = 'bold'}, - b = {fg = colors.cyan, bg = colors.menu_grey} + a = { fg = colors.black, bg = colors.cyan, gui = 'bold' }, + b = { fg = colors.cyan, bg = colors.menu_grey }, }, replace = { - a = {fg = colors.black, bg = colors.green, gui = 'bold'}, - b = {fg = colors.green, bg = colors.menu_grey} + a = { fg = colors.black, bg = colors.green, gui = 'bold' }, + b = { fg = colors.green, bg = colors.menu_grey }, }, inactive = { - a = {fg = colors.black, bg = colors.menu_grey, gui = 'bold'}, - b = {fg = colors.black, bg = colors.menu_grey}, - c = {fg = colors.black, bg = colors.menu_grey} - } + a = { fg = colors.black, bg = colors.menu_grey, gui = 'bold' }, + b = { fg = colors.black, bg = colors.menu_grey }, + c = { fg = colors.black, bg = colors.menu_grey }, + }, } diff --git a/lua/lualine/themes/papercolor_dark.lua b/lua/lualine/themes/papercolor_dark.lua index 5c940e8..6fba11b 100644 --- a/lua/lualine/themes/papercolor_dark.lua +++ b/lua/lualine/themes/papercolor_dark.lua @@ -27,17 +27,16 @@ local colors = { return { normal = { - a = {fg = colors.foreground, bg = colors.background, gui = 'bold'}, - b = {fg = colors.statusline_active_fg, bg = colors.status}, - c = {fg = colors.statusline_active_fg, bg = colors.statusline_active_bg} + a = { fg = colors.foreground, bg = colors.background, gui = 'bold' }, + b = { fg = colors.statusline_active_fg, bg = colors.status }, + c = { fg = colors.statusline_active_fg, bg = colors.statusline_active_bg }, }, - insert = {a = {fg = colors.background, bg = colors.blue, gui = 'bold'}}, - visual = {a = {fg = colors.visual_fg, bg = colors.visual_bg, gui = 'bold'}}, - replace = {a = {fg = colors.background, bg = colors.pink, gui = 'bold'}}, + insert = { a = { fg = colors.background, bg = colors.blue, gui = 'bold' } }, + visual = { a = { fg = colors.visual_fg, bg = colors.visual_bg, gui = 'bold' } }, + replace = { a = { fg = colors.background, bg = colors.pink, gui = 'bold' } }, inactive = { - a = {fg = colors.foreground, bg = colors.background, gui = 'bold'}, - b = {fg = colors.foreground, bg = colors.background}, - c = {fg = colors.foreground, bg = colors.background} - } - + a = { fg = colors.foreground, bg = colors.background, gui = 'bold' }, + b = { fg = colors.foreground, bg = colors.background }, + c = { fg = colors.foreground, bg = colors.background }, + }, } diff --git a/lua/lualine/themes/papercolor_light.lua b/lua/lualine/themes/papercolor_light.lua index c395a7b..336bb88 100644 --- a/lua/lualine/themes/papercolor_light.lua +++ b/lua/lualine/themes/papercolor_light.lua @@ -25,17 +25,16 @@ local colors = { return { normal = { - a = {fg = colors.foreground, bg = colors.background, gui = 'bold'}, - b = {fg = colors.statusline_active_fg, bg = colors.status}, - c = {fg = colors.statusline_active_fg, bg = colors.statusline_active_bg} + a = { fg = colors.foreground, bg = colors.background, gui = 'bold' }, + b = { fg = colors.statusline_active_fg, bg = colors.status }, + c = { fg = colors.statusline_active_fg, bg = colors.statusline_active_bg }, }, - insert = {a = {fg = colors.blue, bg = colors.background, gui = 'bold'}}, - visual = {a = {fg = colors.background, bg = colors.orange, gui = 'bold'}}, - replace = {a = {fg = colors.background, bg = colors.pink, gui = 'bold'}}, + insert = { a = { fg = colors.blue, bg = colors.background, gui = 'bold' } }, + visual = { a = { fg = colors.background, bg = colors.orange, gui = 'bold' } }, + replace = { a = { fg = colors.background, bg = colors.pink, gui = 'bold' } }, inactive = { - a = {fg = colors.foreground, bg = colors.background, gui = 'bold'}, - b = {fg = colors.foreground, bg = colors.background}, - c = {fg = colors.foreground, bg = colors.background} - } - + a = { fg = colors.foreground, bg = colors.background, gui = 'bold' }, + b = { fg = colors.foreground, bg = colors.background }, + c = { fg = colors.foreground, bg = colors.background }, + }, } diff --git a/lua/lualine/themes/powerline.lua b/lua/lualine/themes/powerline.lua index 93870f8..145a321 100644 --- a/lua/lualine/themes/powerline.lua +++ b/lua/lualine/themes/powerline.lua @@ -21,20 +21,20 @@ local Colors = { return { normal = { - a = {fg = Colors.darkestgreen, bg = Colors.brightgreen, gui = 'bold'}, - b = {fg = Colors.gray10, bg = Colors.gray5}, - c = {fg = Colors.gray7, bg = Colors.gray2} + a = { fg = Colors.darkestgreen, bg = Colors.brightgreen, gui = 'bold' }, + b = { fg = Colors.gray10, bg = Colors.gray5 }, + c = { fg = Colors.gray7, bg = Colors.gray2 }, }, insert = { - a = {fg = Colors.darkestcyan, bg = Colors.white, gui = 'bold'}, - b = {fg = Colors.darkestcyan, bg = Colors.mediumcyan}, - c = {fg = Colors.mediumcyan, bg = Colors.darkestblue} + a = { fg = Colors.darkestcyan, bg = Colors.white, gui = 'bold' }, + b = { fg = Colors.darkestcyan, bg = Colors.mediumcyan }, + c = { fg = Colors.mediumcyan, bg = Colors.darkestblue }, }, - visual = {a = {fg = Colors.darkred, bg = Colors.brightorange, gui = 'bold'}}, - replace = {a = {fg = Colors.white, bg = Colors.brightred, gui = 'bold'}}, + visual = { a = { fg = Colors.darkred, bg = Colors.brightorange, gui = 'bold' } }, + replace = { a = { fg = Colors.white, bg = Colors.brightred, gui = 'bold' } }, inactive = { - a = {fg = Colors.gray1, bg = Colors.gray5, gui = 'bold'}, - b = {fg = Colors.gray1, bg = Colors.gray5}, - c = {bg = Colors.gray1, fg = Colors.gray5} - } + a = { fg = Colors.gray1, bg = Colors.gray5, gui = 'bold' }, + b = { fg = Colors.gray1, bg = Colors.gray5 }, + c = { bg = Colors.gray1, fg = Colors.gray5 }, + }, } diff --git a/lua/lualine/themes/powerline_dark.lua b/lua/lualine/themes/powerline_dark.lua index 38f18c5..1a8225a 100644 --- a/lua/lualine/themes/powerline_dark.lua +++ b/lua/lualine/themes/powerline_dark.lua @@ -24,33 +24,33 @@ local colors = { return { normal = { - a = {bg = colors.neon, fg = colors.black, gui = 'bold'}, - b = {bg = colors.gray, fg = colors.white}, - c = {bg = colors.black, fg = colors.brightgreen} + a = { bg = colors.neon, fg = colors.black, gui = 'bold' }, + b = { bg = colors.gray, fg = colors.white }, + c = { bg = colors.black, fg = colors.brightgreen }, }, insert = { - a = {bg = colors.blue, fg = colors.darkblue, gui = 'bold'}, - b = {bg = colors.navyblue, fg = colors.white}, - c = {bg = colors.purple, fg = colors.white} + a = { bg = colors.blue, fg = colors.darkblue, gui = 'bold' }, + b = { bg = colors.navyblue, fg = colors.white }, + c = { bg = colors.purple, fg = colors.white }, }, visual = { - a = {bg = colors.orange, fg = colors.black, gui = 'bold'}, - b = {bg = colors.darkgray, fg = colors.white}, - c = {bg = colors.red, fg = colors.white} + a = { bg = colors.orange, fg = colors.black, gui = 'bold' }, + b = { bg = colors.darkgray, fg = colors.white }, + c = { bg = colors.red, fg = colors.white }, }, replace = { - a = {bg = colors.brightred, fg = colors.white, gui = 'bold'}, - b = {bg = colors.cyan, fg = colors.darkblue}, - c = {bg = colors.navyblue, fg = colors.white} + a = { bg = colors.brightred, fg = colors.white, gui = 'bold' }, + b = { bg = colors.cyan, fg = colors.darkblue }, + c = { bg = colors.navyblue, fg = colors.white }, }, command = { - a = {bg = colors.green, fg = colors.black, gui = 'bold'}, - b = {bg = colors.darkgray, fg = colors.white}, - c = {bg = colors.black, fg = colors.brightgreen} + a = { bg = colors.green, fg = colors.black, gui = 'bold' }, + b = { bg = colors.darkgray, fg = colors.white }, + c = { bg = colors.black, fg = colors.brightgreen }, }, inactive = { - a = {bg = colors.darkgray, fg = colors.gray, gui = 'bold'}, - b = {bg = colors.darkgray, fg = colors.gray}, - c = {bg = colors.darkgray, fg = colors.gray} - } + a = { bg = colors.darkgray, fg = colors.gray, gui = 'bold' }, + b = { bg = colors.darkgray, fg = colors.gray }, + c = { bg = colors.darkgray, fg = colors.gray }, + }, } diff --git a/lua/lualine/themes/seoul256.lua b/lua/lualine/themes/seoul256.lua index 8f8a6b1..49463ee 100644 --- a/lua/lualine/themes/seoul256.lua +++ b/lua/lualine/themes/seoul256.lua @@ -17,25 +17,25 @@ local colors = { return { visual = { - b = {fg = colors.color0, bg = colors.color1}, - a = {fg = colors.color4, bg = colors.color5, gui = 'bold'} + b = { fg = colors.color0, bg = colors.color1 }, + a = { fg = colors.color4, bg = colors.color5, gui = 'bold' }, }, inactive = { - b = {fg = colors.color6, bg = colors.color4}, - c = {fg = colors.color6, bg = colors.color4}, - a = {fg = colors.color7, bg = colors.color4, gui = 'bold'} + b = { fg = colors.color6, bg = colors.color4 }, + c = { fg = colors.color6, bg = colors.color4 }, + a = { fg = colors.color7, bg = colors.color4, gui = 'bold' }, }, insert = { - b = {fg = colors.color0, bg = colors.color1}, - a = {fg = colors.color4, bg = colors.color10, gui = 'bold'} + b = { fg = colors.color0, bg = colors.color1 }, + a = { fg = colors.color4, bg = colors.color10, gui = 'bold' }, }, replace = { - b = {fg = colors.color0, bg = colors.color1}, - a = {fg = colors.color4, bg = colors.color13, gui = 'bold'} + b = { fg = colors.color0, bg = colors.color1 }, + a = { fg = colors.color4, bg = colors.color13, gui = 'bold' }, }, normal = { - b = {fg = colors.color0, bg = colors.color1}, - c = {fg = colors.color7, bg = colors.color4}, - a = {fg = colors.color4, bg = colors.color14, gui = 'bold'} - } + b = { fg = colors.color0, bg = colors.color1 }, + c = { fg = colors.color7, bg = colors.color4 }, + a = { fg = colors.color4, bg = colors.color14, gui = 'bold' }, + }, } diff --git a/lua/lualine/themes/solarized_dark.lua b/lua/lualine/themes/solarized_dark.lua index 8cbf7e4..888790a 100644 --- a/lua/lualine/themes/solarized_dark.lua +++ b/lua/lualine/themes/solarized_dark.lua @@ -23,16 +23,16 @@ local colors = { return { normal = { - a = {fg = colors.base03, bg = colors.blue, gui = 'bold'}, - b = {fg = colors.base03, bg = colors.base1}, - c = {fg = colors.base1, bg = colors.base02} + a = { fg = colors.base03, bg = colors.blue, gui = 'bold' }, + b = { fg = colors.base03, bg = colors.base1 }, + c = { fg = colors.base1, bg = colors.base02 }, }, - insert = {a = {fg = colors.base03, bg = colors.green, gui = 'bold'}}, - visual = {a = {fg = colors.base03, bg = colors.magenta, gui = 'bold'}}, - replace = {a = {fg = colors.base03, bg = colors.red, gui = 'bold'}}, + insert = { a = { fg = colors.base03, bg = colors.green, gui = 'bold' } }, + visual = { a = { fg = colors.base03, bg = colors.magenta, gui = 'bold' } }, + replace = { a = { fg = colors.base03, bg = colors.red, gui = 'bold' } }, inactive = { - a = {fg = colors.base0, bg = colors.base02, gui = 'bold'}, - b = {fg = colors.base03, bg = colors.base00}, - c = {fg = colors.base01, bg = colors.base02} - } + a = { fg = colors.base0, bg = colors.base02, gui = 'bold' }, + b = { fg = colors.base03, bg = colors.base00 }, + c = { fg = colors.base01, bg = colors.base02 }, + }, } diff --git a/lua/lualine/themes/solarized_light.lua b/lua/lualine/themes/solarized_light.lua index 978316a..e686891 100644 --- a/lua/lualine/themes/solarized_light.lua +++ b/lua/lualine/themes/solarized_light.lua @@ -23,16 +23,16 @@ local colors = { return { normal = { - a = {fg = colors.base03, bg = colors.blue, gui = 'bold'}, - b = {fg = colors.base03, bg = colors.base1}, - c = {fg = colors.base1, bg = colors.base02} + a = { fg = colors.base03, bg = colors.blue, gui = 'bold' }, + b = { fg = colors.base03, bg = colors.base1 }, + c = { fg = colors.base1, bg = colors.base02 }, }, - insert = {a = {fg = colors.base03, bg = colors.green, gui = 'bold'}}, - visual = {a = {fg = colors.base03, bg = colors.magenta, gui = 'bold'}}, - replace = {a = {fg = colors.base03, bg = colors.red, gui = 'bold'}}, + insert = { a = { fg = colors.base03, bg = colors.green, gui = 'bold' } }, + visual = { a = { fg = colors.base03, bg = colors.magenta, gui = 'bold' } }, + replace = { a = { fg = colors.base03, bg = colors.red, gui = 'bold' } }, inactive = { - a = {fg = colors.base0, bg = colors.base02, gui = 'bold'}, - b = {fg = colors.base03, bg = colors.base00}, - c = {fg = colors.base01, bg = colors.base02} - } + a = { fg = colors.base0, bg = colors.base02, gui = 'bold' }, + b = { fg = colors.base03, bg = colors.base00 }, + c = { fg = colors.base01, bg = colors.base02 }, + }, } diff --git a/lua/lualine/themes/wombat.lua b/lua/lualine/themes/wombat.lua index 391aa3e..36451b8 100644 --- a/lua/lualine/themes/wombat.lua +++ b/lua/lualine/themes/wombat.lua @@ -23,16 +23,16 @@ local colors = { return { normal = { - a = {fg = colors.base02, bg = colors.blue, gui = 'bold'}, - b = {fg = colors.base02, bg = colors.base0}, - c = {fg = colors.base2, bg = colors.base02} + a = { fg = colors.base02, bg = colors.blue, gui = 'bold' }, + b = { fg = colors.base02, bg = colors.base0 }, + c = { fg = colors.base2, bg = colors.base02 }, }, - insert = {a = {fg = colors.base02, bg = colors.green, gui = 'bold'}}, - visual = {a = {fg = colors.base02, bg = colors.magenta, gui = 'bold'}}, - replace = {a = {fg = colors.base023, bg = colors.red, gui = 'bold'}}, + insert = { a = { fg = colors.base02, bg = colors.green, gui = 'bold' } }, + visual = { a = { fg = colors.base02, bg = colors.magenta, gui = 'bold' } }, + replace = { a = { fg = colors.base023, bg = colors.red, gui = 'bold' } }, inactive = { - a = {fg = colors.base1, bg = colors.base02, gui = 'bold'}, - b = {fg = colors.base023, bg = colors.base01}, - c = {fg = colors.base1, bg = colors.base023} - } + a = { fg = colors.base1, bg = colors.base02, gui = 'bold' }, + b = { fg = colors.base023, bg = colors.base01 }, + c = { fg = colors.base1, bg = colors.base023 }, + }, } diff --git a/lua/lualine/utils/color_utils.lua b/lua/lualine/utils/color_utils.lua index f4147a7..dc7fc28 100644 --- a/lua/lualine/utils/color_utils.lua +++ b/lua/lualine/utils/color_utils.lua @@ -291,7 +291,7 @@ function M.rgb2cterm(hex_color) local closest_cterm_color = 0 local min_distance = 10000 for _, color in ipairs(color_table) do - local current_distance = get_color_distance(color[2], {r, g, b}) + local current_distance = get_color_distance(color[2], { r, g, b }) if current_distance < min_distance then min_distance = current_distance closest_cterm_color = color[1] @@ -303,7 +303,7 @@ end function M.color_name2rgb(name) local color_val = vim.api.nvim_get_color_by_name(name) if color_val == -1 then - return '#'..name -- Assuming it's 'rrggbb' without # not rad instead of red + return '#' .. name -- Assuming it's 'rrggbb' without # not rad instead of red end return string.format('#%06x', color_val) end @@ -312,7 +312,7 @@ function M.cterm2rgb(color) local color_data = color_table[color + 1] if color_data ~= nil then color_data = color_data[2] - return string.format("#%02x%02x%02x", color_data[1], color_data[2], color_data[3]) + return string.format('#%02x%02x%02x', color_data[1], color_data[2], color_data[3]) end end diff --git a/lua/lualine/utils/job.lua b/lua/lualine/utils/job.lua index 675184e..8178f1b 100644 --- a/lua/lualine/utils/job.lua +++ b/lua/lualine/utils/job.lua @@ -5,8 +5,12 @@ local Job = setmetatable({ return self.job_id > 0 end, stop = function(self) - if self.killed then return end - if self.job_id and self.job_id > 0 then vim.fn.jobstop(self.job_id) end + if self.killed then + return + end + if self.job_id and self.job_id > 0 then + vim.fn.jobstop(self.job_id) + end self.job_id = 0 self.killed = true end, @@ -16,19 +20,23 @@ local Job = setmetatable({ local original_cb = self.args[name] if original_cb then self.args[name] = function(...) - if not self.killed then return original_cb(...) end + if not self.killed then + return original_cb(...) + end end end - end - }, { + end, +}, { __call = function(self, args) args = vim.deepcopy(args or {}) - if type(args.cmd) == 'string' then args.cmd = vim.split(args.cmd, ' ') end + if type(args.cmd) == 'string' then + args.cmd = vim.split(args.cmd, ' ') + end self.__index = self - local job = setmetatable({args = args}, self) - job:wrap_cb_alive('on_stdout') - job:wrap_cb_alive('on_stderr') - job:wrap_cb_alive('on_stdin') + local job = setmetatable({ args = args }, self) + job:wrap_cb_alive 'on_stdout' + job:wrap_cb_alive 'on_stderr' + job:wrap_cb_alive 'on_stdin' return job end, }) diff --git a/lua/lualine/utils/loader.lua b/lua/lualine/utils/loader.lua index 77ecf09..41bb3b4 100644 --- a/lua/lualine/utils/loader.lua +++ b/lua/lualine/utils/loader.lua @@ -1,9 +1,9 @@ -- Copyright (c) 2020-2021 hoob3rt -- MIT license, see LICENSE for more details. -local lualine_require = require'lualine_require' +local lualine_require = require 'lualine_require' local require = lualine_require.require -local modules = lualine_require.lazy_require{ +local modules = lualine_require.lazy_require { notice = 'lualine.utils.notices', } local is_valid_filename = lualine_require.is_valid_filename @@ -12,11 +12,10 @@ local sep = lualine_require.sep local component_types = { luaf = function(component) - return - require('lualine.components.special.function_component'):new(component) + return require('lualine.components.special.function_component'):new(component) end, mod = function(component) - local ok, loaded_component = pcall(require,'lualine.components.'..component[1]) + local ok, loaded_component = pcall(require, 'lualine.components.' .. component[1]) if ok then component.component_name = component[1] loaded_component = loaded_component:new(component) @@ -25,18 +24,17 @@ local component_types = { end, stl = function(component) local stl_expr = component[1] -- Vim's %p %l statusline elements - component[1] = function() return stl_expr end - return - require('lualine.components.special.function_component'):new(component) + component[1] = function() + return stl_expr + end + return require('lualine.components.special.function_component'):new(component) end, var = function(component) - return - require('lualine.components.special.vim_var_component'):new(component) + return require('lualine.components.special.vim_var_component'):new(component) end, ['_'] = function(component) - return - require('lualine.components.special.eval_func_component'):new(component) - end + return require('lualine.components.special.eval_func_component'):new(component) + end, } local function component_loader(component) @@ -51,10 +49,13 @@ local function component_loader(component) elseif component.type == 'vimf' or component.type == 'luae' then return component_types['_'](component) else - modules.notice.add_notice(string.format([[ + modules.notice.add_notice(string.format( + [[ ### component.type -component type '%s' isn't recognised. Check if spelling is correct.]], component.type)) +component type '%s' isn't recognised. Check if spelling is correct.]], + component.type + )) end end local loaded_component = component_types.mod(component) @@ -62,7 +63,7 @@ component type '%s' isn't recognised. Check if spelling is correct.]], component return loaded_component elseif string.char(component[1]:byte(1)) == '%' then return component_types.stl(component) - elseif component[1]:find('[gvtwb]?o?:') == 1 then + elseif component[1]:find '[gvtwb]?o?:' == 1 then return component_types.var(component) else return component_types['_'](component) @@ -74,7 +75,7 @@ local function load_sections(sections, options) for section_name, section in pairs(sections) do for index, component in pairs(section) do if type(component) == 'string' or type(component) == 'function' then - component = {component} + component = { component } end component.self = {} component.self.section = section_name @@ -95,7 +96,7 @@ local function load_extensions(config) local loaded_extensions = {} for _, extension in pairs(config.extensions) do if type(extension) == 'string' then - local ok, local_extension = pcall(require, 'lualine.extensions.' ..extension) + local ok, local_extension = pcall(require, 'lualine.extensions.' .. extension) if ok then local_extension = vim.deepcopy(local_extension) load_sections(local_extension.sections, config.options) @@ -107,10 +108,13 @@ local function load_extensions(config) end table.insert(loaded_extensions, local_extension) else - modules.notice.add_notice(string.format([[ + modules.notice.add_notice(string.format( + [[ ### Extensions Extension named `%s` was not found . Check if spelling is correct. -]], extension)) +]], + extension + )) end elseif type(extension) == 'table' then local local_extension = vim.deepcopy(extension) @@ -133,20 +137,20 @@ local function load_all(config) end local function load_theme(theme_name) - assert(is_valid_filename(theme_name), "Invalid filename") + assert(is_valid_filename(theme_name), 'Invalid filename') local retval - local path = table.concat({'lua', 'lualine', 'themes', theme_name}, sep)..'.lua' + local path = table.concat({ 'lua', 'lualine', 'themes', theme_name }, sep) .. '.lua' local files = lualine_require.rtp_searcher(path) local n_files = #files if n_files == 0 then -- No match found - error(path .. " Not found") + error(path .. ' Not found') elseif n_files == 1 then -- when only one is found run that and return it's return value - retval = dofile(files[1]) + retval = dofile(files[1]) else -- More then 1 found . Use the first one that isn't in lualines repo - local lualine_repo_pattern = table.concat({'lualine.nvim', 'lua', 'lualine'}, sep) + local lualine_repo_pattern = table.concat({ 'lualine.nvim', 'lua', 'lualine' }, sep) local file_found = false for _, file in ipairs(files) do if not file:find(lualine_repo_pattern) then @@ -158,7 +162,7 @@ local function load_theme(theme_name) if not file_found then -- This shouldn't happen but somehow we have multiple files but they -- apear to be in lualines repo . Just run the first one - retval = dofile(files[1]) + retval = dofile(files[1]) end end return retval @@ -166,5 +170,5 @@ end return { load_all = load_all, - load_theme = load_theme + load_theme = load_theme, } diff --git a/lua/lualine/utils/mode.lua b/lua/lualine/utils/mode.lua index 27e19b3..94a1f49 100644 --- a/lua/lualine/utils/mode.lua +++ b/lua/lualine/utils/mode.lua @@ -36,7 +36,9 @@ Mode.map = { function Mode.get_mode() local mode_code = vim.api.nvim_get_mode().mode - if Mode.map[mode_code] == nil then return mode_code end + if Mode.map[mode_code] == nil then + return mode_code + end return Mode.map[mode_code] end diff --git a/lua/lualine/utils/notices.lua b/lua/lualine/utils/notices.lua index 98df9af..dcf2815 100644 --- a/lua/lualine/utils/notices.lua +++ b/lua/lualine/utils/notices.lua @@ -3,17 +3,21 @@ local M = {} local notices = {} function M.add_notice(notice) - if type(notice) == 'string' then notice = vim.split(notice, "\n") end + if type(notice) == 'string' then + notice = vim.split(notice, '\n') + end table.insert(notices, notice) end function M.notice_message_startup() if #notices > 0 then - vim.cmd('command! -nargs=0 LualineNotices lua require"lualine.utils.notices".show_notices()') + vim.cmd 'command! -nargs=0 LualineNotices lua require"lualine.utils.notices".show_notices()' vim.schedule(function() vim.notify( - "lualine: There are some issues with your config. Run :LualineNotices for details", - vim.log.levels.WARN, {}) + 'lualine: There are some issues with your config. Run :LualineNotices for details', + vim.log.levels.WARN, + {} + ) end) end end @@ -25,16 +29,15 @@ function M.show_notices() :silent! nnoremap q bd :silent! normal ggdG ]] - local ok, _ = pcall(vim.api.nvim_buf_set_name, 0, "Lualine Notices") + local ok, _ = pcall(vim.api.nvim_buf_set_name, 0, 'Lualine Notices') if not ok then - vim.notify("Lualine Notices is already open in another window", - vim.log.levels.ERROR, {}) - vim.cmd('normal q') - return + vim.notify('Lualine Notices is already open in another window', vim.log.levels.ERROR, {}) + vim.cmd 'normal q' + return end local notice = vim.tbl_flatten(notices) vim.fn.append(0, notice) - vim.api.nvim_win_set_cursor(0, {1, 0}) + vim.api.nvim_win_set_cursor(0, { 1, 0 }) end function M.clear_notices() diff --git a/lua/lualine/utils/section.lua b/lua/lualine/utils/section.lua index ca71544..44360f6 100644 --- a/lua/lualine/utils/section.lua +++ b/lua/lualine/utils/section.lua @@ -1,19 +1,17 @@ -- Copyright (c) 2020-2021 hoob3rt -- MIT license, see LICENSE for more details. local M = {} -local require = require'lualine_require'.require -local utils = require('lualine.utils.utils') -local highlight = require('lualine.highlight') +local require = require('lualine_require').require +local utils = require 'lualine.utils.utils' +local highlight = require 'lualine.highlight' -- Returns formated string for a section function M.draw_section(section, section_name, is_focused) - local highlight_name = highlight.format_highlight(is_focused, - 'lualine_' .. section_name) + local highlight_name = highlight.format_highlight(is_focused, 'lualine_' .. section_name) local status = {} for _, component in pairs(section) do -- load components into status table - if type(component) ~= 'table' or - (type(component) == 'table' and not component.component_no) then + if type(component) ~= 'table' or (type(component) == 'table' and not component.component_no) then return '' -- unknown element in section. section posibly not yet loaded end table.insert(status, component:draw(highlight_name, is_focused)) @@ -26,17 +24,23 @@ function M.draw_section(section, section_name, is_focused) -- Check through components to see when component separator need to be removed for component_no = #section, 1, -1 do - if #status[component_no] > 0 then first_component_no = component_no end + if #status[component_no] > 0 then + first_component_no = component_no + end -- Remove component separator with highlight for last component if not last_component_found and #status[component_no] > 0 then last_component_found = true status[component_no] = section[component_no]:strip_separator() if section_name < 'c' then - if type(section[first_component_no].options.separator) ~= 'table' and - section[1].options.section_separators[1] ~= '' then - status[component_no] = string.format('%s%%S{%s}', - status[component_no], section[1] - .options.section_separators[1]) + if + type(section[first_component_no].options.separator) ~= 'table' + and section[1].options.section_separators[1] ~= '' + then + status[component_no] = string.format( + '%s%%S{%s}', + status[component_no], + section[1].options.section_separators[1] + ) end end end @@ -46,41 +50,50 @@ function M.draw_section(section, section_name, is_focused) status[component_no] = section[component_no]:strip_separator() end -- Remove component separator when color option is used to color background - if (type(section[component_no].options.color) == 'table' and - section[component_no].options.color.bg) or - type(section[component_no].options.color) == 'string' then + if + (type(section[component_no].options.color) == 'table' and section[component_no].options.color.bg) + or type(section[component_no].options.color) == 'string' + then strip_next_component = true status[component_no] = section[component_no]:strip_separator() end - if (section[component_no].strip_previous_separator == true) then + if section[component_no].strip_previous_separator == true then strip_next_component = true end end local left_sparator_string = '' - if section_name > 'x' and section[first_component_no] and - type(section[first_component_no].options.separator) ~= 'table' and - section[1].options.section_separators[2] ~= '' then - left_sparator_string = string.format('%%s{%s}', - section[first_component_no].options.ls_separator or - section[1].options.section_separators[2]) + if + section_name > 'x' + and section[first_component_no] + and type(section[first_component_no].options.separator) ~= 'table' + and section[1].options.section_separators[2] ~= '' + then + left_sparator_string = string.format( + '%%s{%s}', + section[first_component_no].options.ls_separator or section[1].options.section_separators[2] + ) end -- Remove empty strings from status status = utils.list_shrink(status) local status_str = table.concat(status) - if #status_str == 0 then return '' end + if #status_str == 0 then + return '' + end local needs_hl - local find_start_trans_sep_start, find_start_trans_sep_end = status_str:find('^%%s{.-}') + local find_start_trans_sep_start, find_start_trans_sep_end = status_str:find '^%%s{.-}' if find_start_trans_sep_start then -- the section doesn't need to be prepended with default hl when sections -- first component has trasitionals sep needs_hl = status_str:find('^%%#', find_start_trans_sep_end + 1) - else needs_hl = status_str:find('^%%#') end + else + needs_hl = status_str:find '^%%#' + end if needs_hl then -- Don't prepend with old highlight when the component changes it imidiately diff --git a/lua/lualine/utils/utils.lua b/lua/lualine/utils/utils.lua index 77d10c3..1a242e4 100644 --- a/lua/lualine/utils/utils.lua +++ b/lua/lualine/utils/utils.lua @@ -5,7 +5,9 @@ local M = {} -- Note for now only works for termguicolors scope can be bg or fg or any other -- attr parameter like bold/italic/reverse function M.extract_highlight_colors(color_group, scope) - if vim.fn.hlexists(color_group) == 0 then return nil end + if vim.fn.hlexists(color_group) == 0 then + return nil + end local color = vim.api.nvim_get_hl_by_name(color_group, true) if color.background ~= nil then color.bg = string.format('#%06x', color.background) @@ -15,7 +17,9 @@ function M.extract_highlight_colors(color_group, scope) color.fg = string.format('#%06x', color.foreground) color.foreground = nil end - if scope then return color[scope] end + if scope then + return color[scope] + end return color end @@ -23,22 +27,26 @@ end function M.list_shrink(list) local new_list = {} for i = 1, #list do - if list[i] and #list[i] > 0 then table.insert(new_list, list[i]) end + if list[i] and #list[i] > 0 then + table.insert(new_list, list[i]) + end end return new_list end -- Check if a auto command is already defined local function autocmd_is_defined(event, patern, command_str) - return vim.api.nvim_exec(string.format("au lualine %s %s", - event, patern), true):find(command_str) ~= nil + return vim.api.nvim_exec(string.format('au lualine %s %s', event, patern), true):find(command_str) ~= nil end -- Define a auto command if it's not already defined function M.define_autocmd(event, patern, cmd) - if not cmd then cmd = patern; patern = '*' end + if not cmd then + cmd = patern + patern = '*' + end if not autocmd_is_defined(event, patern, cmd) then - vim.cmd(string.format("autocmd lualine %s %s %s", event, patern, cmd)) + vim.cmd(string.format('autocmd lualine %s %s %s', event, patern, cmd)) end end diff --git a/lua/lualine_require.lua b/lua/lualine_require.lua index a3159c9..27a9afd 100644 --- a/lua/lualine_require.lua +++ b/lua/lualine_require.lua @@ -1,27 +1,31 @@ local M = {} -M.sep = package.config:sub(1,1) +M.sep = package.config:sub(1, 1) -local source = debug.getinfo(1, "S").source -if source:sub(1,1) == '@' then - local base_start = source:find(table.concat({'lualine.nvim', 'lua', 'lualine_require.lua'}, M.sep)) +local source = debug.getinfo(1, 'S').source +if source:sub(1, 1) == '@' then + local base_start = source:find(table.concat({ 'lualine.nvim', 'lua', 'lualine_require.lua' }, M.sep)) if base_start then source = source:sub(2, base_start + 12 + 1 + 3) -- #lualine.nvim = 12 , #lua = 3. - if source then M.plugin_dir = source end + if source then + M.plugin_dir = source + end end end function M.is_valid_filename(name) - local invalid_chars="[^a-zA-Z0-9_. -]" + local invalid_chars = '[^a-zA-Z0-9_. -]' return name:find(invalid_chars) == nil end function M.require(module) - if package.loaded[module] then return package.loaded[module] end + if package.loaded[module] then + return package.loaded[module] + end local pattern = module:gsub('%.', M.sep) .. '.lua' if M.plugin_dir then local path = M.plugin_dir .. pattern - assert(M.is_valid_filename(module), "Invalid filename") + assert(M.is_valid_filename(module), 'Invalid filename') if vim.loop.fs_stat(path) then local mod_result = dofile(path) package.loaded[module] = mod_result @@ -29,7 +33,7 @@ function M.require(module) end end - local paths = M.rtp_searcher('lua'..M.sep..pattern, true) + local paths = M.rtp_searcher('lua' .. M.sep .. pattern, true) if #paths > 0 then local mod_result = dofile(paths[1]) package.loaded[module] = mod_result @@ -41,11 +45,13 @@ end function M.rtp_searcher(file, once) local ret = {} - for dir in vim.gsplit(vim.api.nvim_get_option('rtp'), ',') do + for dir in vim.gsplit(vim.api.nvim_get_option 'rtp', ',') do local path = dir .. M.sep .. file if vim.loop.fs_stat(path) then - ret[#ret+1] = path - if once then break end + ret[#ret + 1] = path + if once then + break + end end end return ret @@ -55,13 +61,17 @@ function M.lazy_require(modules) return setmetatable({}, { __index = function(self, key) local loaded = rawget(self, key) - if loaded ~= nil then return loaded end + if loaded ~= nil then + return loaded + end local module_location = modules[key] - if module_location == nil then return nil end + if module_location == nil then + return nil + end local module = M.require(module_location) rawset(self, key, module) return module - end + end, }) end diff --git a/lua/tests/helpers.lua b/lua/tests/helpers.lua index 78d0b33..3fdfabb 100644 --- a/lua/tests/helpers.lua +++ b/lua/tests/helpers.lua @@ -3,32 +3,54 @@ local eq = assert.are.same local M = {} M.meths = setmetatable({}, { - __index = function(_, key) return vim.api['nvim_' .. key] end + __index = function(_, key) + return vim.api['nvim_' .. key] + end, }) -- Checks ouput of a component M.assert_component = function(component, opts, result) -- for testing global options - if component == nil then component = 'special.function_component' end + if component == nil then + component = 'special.function_component' + end local comp = require('lualine.components.' .. component):new(opts) eq(result, comp:draw(opts.hl)) end -- sets defaults for component options M.build_component_opts = function(opts) - if not opts then opts = {} end - if opts[1] == nil then opts[1] = function() return 'test' end end - if not opts.self then opts.self = {section = 'lualine_c'} end - if not opts.theme then opts.theme = 'gruvbox' end - if not opts.hl then opts.hl = '' end - if opts.icons_enabled == nil then opts.icons_enabled = true end - if not opts.component_separators then - opts.component_separators = {'', ''} + if not opts then + opts = {} + end + if opts[1] == nil then + opts[1] = function() + return 'test' + end + end + if not opts.self then + opts.self = { section = 'lualine_c' } + end + if not opts.theme then + opts.theme = 'gruvbox' + end + if not opts.hl then + opts.hl = '' + end + if opts.icons_enabled == nil then + opts.icons_enabled = true + end + if not opts.component_separators then + opts.component_separators = { '', '' } + end + if not opts.section_separators then + opts.section_separators = { '', '' } end - if not opts.section_separators then opts.section_separators = {'', ''} end return opts end -M.P = function(t) print(vim.inspect(t)) end +M.P = function(t) + print(vim.inspect(t)) +end return M diff --git a/lua/tests/minimal_init.lua b/lua/tests/minimal_init.lua index 3a27414..e82a8e7 100644 --- a/lua/tests/minimal_init.lua +++ b/lua/tests/minimal_init.lua @@ -1,5 +1,8 @@ -- load lualine and plenary -vim.api.nvim_exec([[ +vim.api.nvim_exec( + [[ set rtp+=. set rtp+=../plenary.nvim -]], false) +]], + false +) diff --git a/lua/tests/spec/component_spec.lua b/lua/tests/spec/component_spec.lua index 4c93939..992abef 100644 --- a/lua/tests/spec/component_spec.lua +++ b/lua/tests/spec/component_spec.lua @@ -9,217 +9,216 @@ local stub = require 'luassert.stub' describe('Component:', function() it('can select separators', function() local opts = build_component_opts() - local comp = require('lualine.components.special.function_component'):new( - opts) + local comp = require('lualine.components.special.function_component'):new(opts) -- correct for lualine_c eq('', comp.options.separator) - local opts2 = build_component_opts({self = {section = 'lualine_y'}}) - local comp2 = require('lualine.components.special.function_component'):new( - opts2) + local opts2 = build_component_opts { self = { section = 'lualine_y' } } + local comp2 = require('lualine.components.special.function_component'):new(opts2) -- correct for lualine_u eq('', comp2.options.separator) end) it('can provide unique identifier', function() local opts1 = build_component_opts() - local comp1 = require('lualine.components.special.function_component'):new( - opts1) + local comp1 = require('lualine.components.special.function_component'):new(opts1) local opts2 = build_component_opts() - local comp2 = require('lualine.components.special.function_component'):new( - opts2) + local comp2 = require('lualine.components.special.function_component'):new(opts2) neq(comp1.component_no, comp2.component_no) end) it('create option highlights', function() - local color = {fg = '#224532', bg = '#892345'} - local opts1 = build_component_opts({color = color}) + local color = { fg = '#224532', bg = '#892345' } + local opts1 = build_component_opts { color = color } local hl = require 'lualine.highlight' stub(hl, 'create_component_highlight_group') - hl.create_component_highlight_group.returns('MyCompHl') - local comp1 = require('lualine.components.special.function_component'):new( - opts1) + hl.create_component_highlight_group.returns 'MyCompHl' + local comp1 = require('lualine.components.special.function_component'):new(opts1) eq('MyCompHl', comp1.options.color_highlight) -- color highlight wan't in options when create_comp_hl was -- called so remove it before assert comp1.options.color_highlight = nil - assert.stub(hl.create_component_highlight_group).was_called_with(color, - comp1.options - .component_name, - comp1.options) + assert.stub(hl.create_component_highlight_group).was_called_with(color, comp1.options.component_name, comp1.options) hl.create_component_highlight_group:revert() color = 'MyHl' - local opts2 = build_component_opts({color = color}) + local opts2 = build_component_opts { color = color } stub(hl, 'create_component_highlight_group') - hl.create_component_highlight_group.returns('MyCompLinkedHl') - local comp2 = require('lualine.components.special.function_component'):new( - opts2) + hl.create_component_highlight_group.returns 'MyCompLinkedHl' + local comp2 = require('lualine.components.special.function_component'):new(opts2) eq('MyCompLinkedHl', comp2.options.color_highlight) -- color highlight wan't in options when create_comp_hl was -- called so remove it before assert comp2.options.color_highlight = nil - assert.stub(hl.create_component_highlight_group).was_called_with(color, - comp2.options - .component_name, - comp2.options) + assert.stub(hl.create_component_highlight_group).was_called_with(color, comp2.options.component_name, comp2.options) hl.create_component_highlight_group:revert() end) it('can draw', function() - local opts = build_component_opts({ - component_separators = {'', ''}, - padding = 0 - }) + local opts = build_component_opts { + component_separators = { '', '' }, + padding = 0, + } assert_component(nil, opts, 'test') end) it('can apply separators', function() - local opts = build_component_opts({padding = 0}) + local opts = build_component_opts { padding = 0 } assert_component(nil, opts, 'test') end) it('can apply default highlight', function() - local opts = build_component_opts({padding = 0, hl = '%#My_highlight#'}) + local opts = build_component_opts { padding = 0, hl = '%#My_highlight#' } assert_component(nil, opts, '%#My_highlight#test') - opts = build_component_opts({function() return "%#Custom_hl#test" end, - padding = 0, hl = '%#My_highlight#'}) + opts = build_component_opts { + function() + return '%#Custom_hl#test' + end, + padding = 0, + hl = '%#My_highlight#', + } assert_component(nil, opts, '%#Custom_hl#test%#My_highlight#') - opts = build_component_opts({function() return "in middle%#Custom_hl#test" end, - padding = 0, hl = '%#My_highlight#'}) + opts = build_component_opts { + function() + return 'in middle%#Custom_hl#test' + end, + padding = 0, + hl = '%#My_highlight#', + } assert_component(nil, opts, '%#My_highlight#in middle%#Custom_hl#test%#My_highlight#') end) describe('Global options:', function() it('upper', function() - local opts = build_component_opts({ - component_separators = {'', ''}, + local opts = build_component_opts { + component_separators = { '', '' }, padding = 0, - upper = true - }) + upper = true, + } assert_component(nil, opts, 'TEST') end) it('lower', function() - local opts = build_component_opts({ - function() return 'TeSt' end, - component_separators = {'', ''}, + local opts = build_component_opts { + function() + return 'TeSt' + end, + component_separators = { '', '' }, padding = 0, - lower = true - }) + lower = true, + } assert_component(nil, opts, 'test') end) it('left_padding', function() - local opts = build_component_opts({ - component_separators = {'', ''}, + local opts = build_component_opts { + component_separators = { '', '' }, padding = 0, - left_padding = 5 - }) + left_padding = 5, + } assert_component(nil, opts, ' test') end) it('right_padding', function() - local opts = build_component_opts({ - component_separators = {'', ''}, + local opts = build_component_opts { + component_separators = { '', '' }, padding = 0, - right_padding = 5 - }) + right_padding = 5, + } assert_component(nil, opts, 'test ') end) it('padding', function() - local opts = build_component_opts({ - component_separators = {'', ''}, - padding = 5 - }) + local opts = build_component_opts { + component_separators = { '', '' }, + padding = 5, + } assert_component(nil, opts, ' test ') end) it('icon', function() - local opts = build_component_opts({ - component_separators = {'', ''}, + local opts = build_component_opts { + component_separators = { '', '' }, padding = 0, - icon = '0' - }) + icon = '0', + } assert_component(nil, opts, '0 test') end) it('icons_enabled', function() - local opts = build_component_opts({ - component_separators = {'', ''}, + local opts = build_component_opts { + component_separators = { '', '' }, padding = 0, icons_enabled = true, - icon = '0' - }) + icon = '0', + } assert_component(nil, opts, '0 test') - local opts2 = build_component_opts( - { - component_separators = {'', ''}, - padding = 0, - icons_enabled = false, - icon = '0' - }) + local opts2 = build_component_opts { + component_separators = { '', '' }, + padding = 0, + icons_enabled = false, + icon = '0', + } assert_component(nil, opts2, 'test') end) it('separator', function() - local opts = build_component_opts({ - component_separators = {'', ''}, + local opts = build_component_opts { + component_separators = { '', '' }, padding = 0, - separator = '|' - }) + separator = '|', + } assert_component(nil, opts, 'test|') end) it('format', function() - local opts = build_component_opts({ - component_separators = {'', ''}, + local opts = build_component_opts { + component_separators = { '', '' }, padding = 0, format = function(data) return data:sub(1, 1):upper() .. data:sub(2, #data) - end - }) + end, + } assert_component(nil, opts, 'Test') end) it('condition', function() - local opts = build_component_opts({ - component_separators = {'', ''}, + local opts = build_component_opts { + component_separators = { '', '' }, padding = 0, - condition = function() return true end - }) + condition = function() + return true + end, + } assert_component(nil, opts, 'test') - local opts2 = build_component_opts( - { - component_separators = {'', ''}, - padding = 0, - condition = function() return false end - }) + local opts2 = build_component_opts { + component_separators = { '', '' }, + padding = 0, + condition = function() + return false + end, + } assert_component(nil, opts2, '') end) it('color', function() - local opts = build_component_opts({ - component_separators = {'', ''}, + local opts = build_component_opts { + component_separators = { '', '' }, padding = 0, - color = 'MyHl' - }) + color = 'MyHl', + } local comp = require('lualine.components.special.function_component'):new(opts) - local custom_link_hl_name = 'lualine_'..comp.options.component_name..'_no_mode' - eq('%#'..custom_link_hl_name..'#test', comp:draw(opts.hl)) - local opts2 = build_component_opts( - { - component_separators = {'', ''}, - padding = 0, - color = {bg = '#230055', fg = '#223344'} - }) + local custom_link_hl_name = 'lualine_' .. comp.options.component_name .. '_no_mode' + eq('%#' .. custom_link_hl_name .. '#test', comp:draw(opts.hl)) + local opts2 = build_component_opts { + component_separators = { '', '' }, + padding = 0, + color = { bg = '#230055', fg = '#223344' }, + } local hl = require 'lualine.highlight' stub(hl, 'component_format_highlight') - hl.component_format_highlight.returns('%#MyCompHl#') - local comp2 = - require('lualine.components.special.function_component'):new(opts2) + hl.component_format_highlight.returns '%#MyCompHl#' + local comp2 = require('lualine.components.special.function_component'):new(opts2) assert_component(nil, opts2, '%#MyCompHl#test') - assert.stub(hl.component_format_highlight).was_called_with( - comp2.options.color_highlight) + assert.stub(hl.component_format_highlight).was_called_with(comp2.options.color_highlight) hl.component_format_highlight:revert() end) end) @@ -227,20 +226,20 @@ end) describe('Encoding component', function() it('works', function() - local opts = build_component_opts({ - component_separators = {'', ''}, - padding = 0 - }) + local opts = build_component_opts { + component_separators = { '', '' }, + padding = 0, + } assert_component('encoding', opts, '%{strlen(&fenc)?&fenc:&enc}') end) end) describe('Fileformat component', function() it('works with icons', function() - local opts = build_component_opts({ - component_separators = {'', ''}, - padding = 0 - }) + local opts = build_component_opts { + component_separators = { '', '' }, + padding = 0, + } local fmt = vim.bo.fileformat vim.bo.fileformat = 'unix' assert_component('fileformat', opts, '') @@ -251,11 +250,11 @@ describe('Fileformat component', function() vim.bo.fileformat = fmt end) it('works without icons', function() - local opts = build_component_opts({ - component_separators = {'', ''}, + local opts = build_component_opts { + component_separators = { '', '' }, padding = 0, - icons_enabled = false - }) + icons_enabled = false, + } assert_component('fileformat', opts, vim.bo.fileformat) end) end) @@ -273,10 +272,10 @@ describe('Filetype component', function() end) it('does not add icon when library unavailable', function() - local opts = build_component_opts({ - component_separators = {'', ''}, - padding = 0 - }) + local opts = build_component_opts { + component_separators = { '', '' }, + padding = 0, + } assert_component('filetype', opts, 'lua') end) @@ -284,49 +283,47 @@ describe('Filetype component', function() package.loaded['nvim-web-devicons'] = { get_icon = function() return '*', 'test_highlight_group' - end + end, } local hl = require 'lualine.highlight' local utils = require 'lualine.utils.utils' stub(hl, 'create_component_highlight_group') stub(utils, 'extract_highlight_colors') - hl.create_component_highlight_group.returns('MyCompHl') - utils.extract_highlight_colors.returns('#000') + hl.create_component_highlight_group.returns 'MyCompHl' + utils.extract_highlight_colors.returns '#000' - local opts = build_component_opts({ - component_separators = {'', ''}, + local opts = build_component_opts { + component_separators = { '', '' }, padding = 0, - colored=true, + colored = true, disable_text = false, - }) + } assert_component('filetype', opts, '%#MyCompHl_normal#*%#lualine_c_normal# lua') assert.stub(utils.extract_highlight_colors).was_called_with('test_highlight_group', 'fg') - assert.stub(hl.create_component_highlight_group).was_called_with( - {fg = '#000'}, 'test_highlight_group', opts - ) + assert.stub(hl.create_component_highlight_group).was_called_with({ fg = '#000' }, 'test_highlight_group', opts) hl.create_component_highlight_group:revert() utils.extract_highlight_colors:revert() package.loaded['nvim-web-devicons'] = nil end) - it('Doesn\'t color when colored is false', function() + it("Doesn't color when colored is false", function() package.loaded['nvim-web-devicons'] = { get_icon = function() return '*', 'test_highlight_group' - end + end, } local hl = require 'lualine.highlight' local utils = require 'lualine.utils.utils' stub(hl, 'create_component_highlight_group') stub(utils, 'extract_highlight_colors') - hl.create_component_highlight_group.returns('MyCompHl') - utils.extract_highlight_colors.returns('#000') - local opts = build_component_opts({ - component_separators = {'', ''}, + hl.create_component_highlight_group.returns 'MyCompHl' + utils.extract_highlight_colors.returns '#000' + local opts = build_component_opts { + component_separators = { '', '' }, padding = 0, colored = false, - }) + } assert_component('filetype', opts, '* lua') hl.create_component_highlight_group:revert() utils.extract_highlight_colors:revert() @@ -337,15 +334,15 @@ describe('Filetype component', function() package.loaded['nvim-web-devicons'] = { get_icon = function() return '*', 'test_highlight_group' - end + end, } - local opts = build_component_opts({ - component_separators = {'', ''}, + local opts = build_component_opts { + component_separators = { '', '' }, padding = 0, colored = false, disable_text = true, - }) + } assert_component('filetype', opts, '*') package.loaded['nvim-web-devicons'] = nil end) @@ -354,11 +351,11 @@ end) describe('Hostname component', function() it('works', function() stub(vim.loop, 'os_gethostname') - vim.loop.os_gethostname.returns('localhost') - local opts = build_component_opts({ - component_separators = {'', ''}, - padding = 0 - }) + vim.loop.os_gethostname.returns 'localhost' + local opts = build_component_opts { + component_separators = { '', '' }, + padding = 0, + } assert_component('hostname', opts, 'localhost') vim.loop.os_gethostname:revert() end) @@ -366,20 +363,20 @@ end) describe('Location component', function() it('works', function() - local opts = build_component_opts({ - component_separators = {'', ''}, - padding = 0 - }) + local opts = build_component_opts { + component_separators = { '', '' }, + padding = 0, + } assert_component('location', opts, '%3l:%-2c') end) end) describe('Progress component', function() it('works', function() - local opts = build_component_opts({ - component_separators = {'', ''}, - padding = 0 - }) + local opts = build_component_opts { + component_separators = { '', '' }, + padding = 0, + } assert_component('progress', opts, '%3P') end) end) @@ -387,11 +384,11 @@ end) describe('Mode component', function() it('works', function() stub(vim.api, 'nvim_get_mode') - vim.api.nvim_get_mode.returns({mode = 'n', blocking = false}) - local opts = build_component_opts({ - component_separators = {'', ''}, - padding = 0 - }) + vim.api.nvim_get_mode.returns { mode = 'n', blocking = false } + local opts = build_component_opts { + component_separators = { '', '' }, + padding = 0, + } assert_component('mode', opts, 'NORMAL') vim.api.nvim_get_mode:revert() end) diff --git a/lua/tests/spec/config_spec.lua b/lua/tests/spec/config_spec.lua index a9a9e76..c2e0a5a 100644 --- a/lua/tests/spec/config_spec.lua +++ b/lua/tests/spec/config_spec.lua @@ -6,11 +6,11 @@ describe('config parsing', function() describe('options', function() describe('icons_enabled', function() it('default', function() - local config = config_module.apply_configuration({}) + local config = config_module.apply_configuration {} eq(config.options.icons_enabled, true) end) it('custom', function() - local config = {options = {icons_enabled = false}} + local config = { options = { icons_enabled = false } } config = config_module.apply_configuration(config) eq(config.options.icons_enabled, false) end) @@ -18,14 +18,14 @@ describe('config parsing', function() describe('theme', function() it('default', function() - local config = config_module.apply_configuration({}) + local config = config_module.apply_configuration {} eq(config.options.theme, 'auto') end) it('custom', function() - local config = {options = {theme = 'nord'}} + local config = { options = { theme = 'nord' } } config = config_module.apply_configuration(config) eq(config.options.theme, 'nord') - config = {options = {theme = {}}} + config = { options = { theme = {} } } config = config_module.apply_configuration(config) eq(config.options.theme, {}) end) @@ -33,43 +33,43 @@ describe('config parsing', function() describe('separators', function() it('default', function() - local config = config_module.apply_configuration({}) - eq(config.options.component_separators, {'', ''}) - eq(config.options.section_separators, {'', ''}) + local config = config_module.apply_configuration {} + eq(config.options.component_separators, { '', '' }) + eq(config.options.section_separators, { '', '' }) end) it('double separators', function() local config = { options = { - component_separators = {'a', 'b'}, - section_separators = {'c', 'd'} - } + component_separators = { 'a', 'b' }, + section_separators = { 'c', 'd' }, + }, } config = config_module.apply_configuration(config) - eq(config.options.component_separators, {'a', 'b'}) - eq(config.options.section_separators, {'c', 'd'}) + eq(config.options.component_separators, { 'a', 'b' }) + eq(config.options.section_separators, { 'c', 'd' }) end) describe('single separator', function() it('string', function() local config = { - options = {component_separators = 'a', section_separators = 'b'} + options = { component_separators = 'a', section_separators = 'b' }, } config = config_module.apply_configuration(config) - eq(config.options.component_separators, {'a', 'a'}) - eq(config.options.section_separators, {'b', 'b'}) + eq(config.options.component_separators, { 'a', 'a' }) + eq(config.options.section_separators, { 'b', 'b' }) end) it('table', function() local config = { - options = {component_separators = {'a'}, section_separators = {'b'}} + options = { component_separators = { 'a' }, section_separators = { 'b' } }, } config = config_module.apply_configuration(config) - eq(config.options.component_separators, {'a', 'a'}) - eq(config.options.section_separators, {'b', 'b'}) + eq(config.options.component_separators, { 'a', 'a' }) + eq(config.options.section_separators, { 'b', 'b' }) end) end) it('no seprarators', function() local config = { - options = {component_separators = {}, section_separators = {}} + options = { component_separators = {}, section_separators = {} }, } config = config_module.apply_configuration(config) eq(config.options.component_separators, {}) @@ -79,24 +79,24 @@ describe('config parsing', function() describe('disabled filetypes', function() it('default', function() - local config = config_module.apply_configuration({}) + local config = config_module.apply_configuration {} eq(config.options.disabled_filetypes, {}) end) it('custom', function() - local config = {options = {disabled_filetypes = {'lua'}}} + local config = { options = { disabled_filetypes = { 'lua' } } } config = config_module.apply_configuration(config) - eq(config.options.disabled_filetypes, {'lua'}) + eq(config.options.disabled_filetypes, { 'lua' }) end) end) describe('non default global option', function() it('default', function() - local config = {options = {}} + local config = { options = {} } config = config_module.apply_configuration(config) eq(config.options.non_default_global_option, nil) end) it('custom', function() - local config = {options = {non_default_global_option = 1}} + local config = { options = { non_default_global_option = 1 } } config = config_module.apply_configuration(config) eq(config.options.non_default_global_option, 1) end) @@ -108,32 +108,31 @@ describe('config parsing', function() local config = {} config = config_module.apply_configuration(config) local lualine_default_sections = { - lualine_a = {'mode'}, - lualine_b = {'branch', 'diff', - {'diagnostics', sources={'nvim_lsp', 'coc'}}}, - lualine_c = {'filename'}, - lualine_x = {'encoding', 'fileformat', 'filetype'}, - lualine_y = {'progress'}, - lualine_z = {'location'} + lualine_a = { 'mode' }, + lualine_b = { 'branch', 'diff', { 'diagnostics', sources = { 'nvim_lsp', 'coc' } } }, + lualine_c = { 'filename' }, + lualine_x = { 'encoding', 'fileformat', 'filetype' }, + lualine_y = { 'progress' }, + lualine_z = { 'location' }, } eq(config.sections, lualine_default_sections) end) it('custom', function() local custom_sections = { - lualine_a = {{'mode', lower = true}}, - lualine_b = {'branch', {'branch', lower = true}}, + lualine_a = { { 'mode', lower = true } }, + lualine_b = { 'branch', { 'branch', lower = true } }, lualine_c = nil, - lualine_x = {} + lualine_x = {}, } local expected_sections = { - lualine_a = {{'mode', lower = true}}, - lualine_b = {'branch', {'branch', lower = true}}, - lualine_c = {'filename'}, + lualine_a = { { 'mode', lower = true } }, + lualine_b = { 'branch', { 'branch', lower = true } }, + lualine_c = { 'filename' }, lualine_x = {}, - lualine_y = {'progress'}, - lualine_z = {'location'} + lualine_y = { 'progress' }, + lualine_z = { 'location' }, } - local config = {sections = custom_sections} + local config = { sections = custom_sections } config = config_module.apply_configuration(config) eq(config.sections, expected_sections) end) @@ -149,17 +148,17 @@ describe('config parsing', function() end) it('custom', function() local custom_sections = { - lualine_a = {{'mode', lower = true}}, - lualine_b = {'branch', {'branch', lower = true}}, + lualine_a = { { 'mode', lower = true } }, + lualine_b = { 'branch', { 'branch', lower = true } }, lualine_c = nil, - lualine_x = {} + lualine_x = {}, } local expected_sections = { - lualine_a = {{'mode', lower = true}}, - lualine_b = {'branch', {'branch', lower = true}}, - lualine_x = {} + lualine_a = { { 'mode', lower = true } }, + lualine_b = { 'branch', { 'branch', lower = true } }, + lualine_x = {}, } - local config = {tabline = custom_sections} + local config = { tabline = custom_sections } config = config_module.apply_configuration(config) eq(config.tabline, expected_sections) end) @@ -167,14 +166,14 @@ describe('config parsing', function() describe('extensions', function() it('default', function() - local config = {options = {}} + local config = { options = {} } config = config_module.apply_configuration(config) eq(config.extensions, {}) end) it('custom', function() - local config = {extensions = {'fugitive'}} + local config = { extensions = { 'fugitive' } } config = config_module.apply_configuration(config) - eq(config.extensions, {'fugitive'}) + eq(config.extensions, { 'fugitive' }) end) end) end) diff --git a/lua/tests/spec/utils_spec.lua b/lua/tests/spec/utils_spec.lua index 263904e..ac48d94 100644 --- a/lua/tests/spec/utils_spec.lua +++ b/lua/tests/spec/utils_spec.lua @@ -4,17 +4,16 @@ local eq = assert.are.same local build_component_opts = helpers.build_component_opts describe('Utils', function() - local utils = require('lualine.utils.utils') + local utils = require 'lualine.utils.utils' it('can retrive highlight groups', function() - local hl2 = {fg = '#aabbcc', bg = '#889977', reverse = true} + local hl2 = { fg = '#aabbcc', bg = '#889977', reverse = true } -- handles non existing hl groups - eq(utils.extract_highlight_colors('hl2'), nil) + eq(utils.extract_highlight_colors 'hl2', nil) -- create highlight - vim.cmd( - string.format('hi hl2 guifg=%s guibg=%s gui=reverse', hl2.fg, hl2.bg)) + vim.cmd(string.format('hi hl2 guifg=%s guibg=%s gui=reverse', hl2.fg, hl2.bg)) -- Can retrive entire highlight table - eq(utils.extract_highlight_colors('hl2'), hl2) + eq(utils.extract_highlight_colors 'hl2', hl2) -- Can retrive specific parts of highlight eq(utils.extract_highlight_colors('hl2', 'fg'), hl2.fg) -- clear hl2 @@ -23,9 +22,20 @@ describe('Utils', function() it('can shrink list with holes', function() local list_with_holes = { - '2', '4', '6', nil, '43', nil, '2', '', 'a', '', 'b', ' ' + '2', + '4', + '6', + nil, + '43', + nil, + '2', + '', + 'a', + '', + 'b', + ' ', } - local list_without_holes = {'2', '4', '6', '43', '2', 'a', 'b', ' '} + local list_without_holes = { '2', '4', '6', '43', '2', 'a', 'b', ' ' } eq(utils.list_shrink(list_with_holes), list_without_holes) end) end) @@ -34,7 +44,7 @@ describe('Cterm genarator', function() local cterm = require 'lualine.utils.color_utils' it('can convert rgb to cterm', function() - local colors = {['#112233'] = 235, ['#7928ae'] = 97, ['#017bdc'] = 68} + local colors = { ['#112233'] = 235, ['#7928ae'] = 97, ['#017bdc'] = 68 } for rgb, ct in pairs(colors) do eq(cterm.rgb2cterm(rgb), tostring(ct)) end @@ -44,57 +54,52 @@ end) describe('Section genarator', function() local sec = require 'lualine.utils.section' it('can draw', function() - local opts = build_component_opts({section_separators = {'', ''}}) + local opts = build_component_opts { section_separators = { '', '' } } local section = { require('lualine.components.special.function_component'):new(opts), - require('lualine.components.special.function_component'):new(opts) + require('lualine.components.special.function_component'):new(opts), } - eq( '%#lualine_MySection_normal# test %#lualine_MySection_normal# test ', - sec.draw_section(section, 'MySection')) + eq('%#lualine_MySection_normal# test %#lualine_MySection_normal# test ', sec.draw_section(section, 'MySection')) end) it('can remove separators from component with custom colors', function() - local opts = build_component_opts({section_separators = {'', ''}}) - local opts_colored = build_component_opts({color = 'MyColor'}) - local opts_colored2 = build_component_opts( - { - color = {bg = '#223344'}, - section_separators = {'', ''} - }) - local opts_colored3 = build_component_opts( - { - color = {fg = '#223344'}, - section_separators = {'', ''} - }) - require'lualine.highlight'.create_highlight_groups( - require 'lualine.themes.gruvbox') + local opts = build_component_opts { section_separators = { '', '' } } + local opts_colored = build_component_opts { color = 'MyColor' } + local opts_colored2 = build_component_opts { + color = { bg = '#223344' }, + section_separators = { '', '' }, + } + local opts_colored3 = build_component_opts { + color = { fg = '#223344' }, + section_separators = { '', '' }, + } + require('lualine.highlight').create_highlight_groups(require 'lualine.themes.gruvbox') local section = { require('lualine.components.special.function_component'):new(opts), require('lualine.components.special.function_component'):new(opts_colored), - require('lualine.components.special.function_component'):new(opts) + require('lualine.components.special.function_component'):new(opts), } - local highlight_name2 = 'lualine_'..section[2].options.component_name..'_no_mode' + local highlight_name2 = 'lualine_' .. section[2].options.component_name .. '_no_mode' -- Removes separator on string color - eq( '%#lualine_MySection_normal# test %#' ..highlight_name2..'#' - .. ' test %#lualine_MySection_normal# test ', - sec.draw_section(section, 'MySection')) - section[2] = - require('lua.lualine.components.special.function_component'):new( - opts_colored2) - local highlight_name = - '%#lualine_c_' .. section[2].options.component_name .. '_normal#' + eq( + '%#lualine_MySection_normal# test %#' .. highlight_name2 .. '#' .. ' test %#lualine_MySection_normal# test ', + sec.draw_section(section, 'MySection') + ) + section[2] = require('lua.lualine.components.special.function_component'):new(opts_colored2) + local highlight_name = '%#lualine_c_' .. section[2].options.component_name .. '_normal#' -- Removes separator on color with bg - eq('%#lualine_MySection_normal# test ' .. highlight_name .. - ' test %#lualine_MySection_normal# test ', - sec.draw_section(section, 'MySection')) - section[2] = - require('lua.lualine.components.special.function_component'):new( - opts_colored3) - highlight_name2 = - '%#lualine_c_' .. section[2].options.component_name .. '_normal#' + eq( + '%#lualine_MySection_normal# test ' .. highlight_name .. ' test %#lualine_MySection_normal# test ', + sec.draw_section(section, 'MySection') + ) + section[2] = require('lua.lualine.components.special.function_component'):new(opts_colored3) + highlight_name2 = '%#lualine_c_' .. section[2].options.component_name .. '_normal#' -- Doesn't remove separator on color without bg - eq('%#lualine_MySection_normal# test ' .. highlight_name2 .. - ' test %#lualine_MySection_normal#%#lualine_MySection_normal# test ', - sec.draw_section(section, 'MySection')) + eq( + '%#lualine_MySection_normal# test ' + .. highlight_name2 + .. ' test %#lualine_MySection_normal#%#lualine_MySection_normal# test ', + sec.draw_section(section, 'MySection') + ) end) end)