diff --git a/lua/one-nvim.lua b/lua/one-nvim.lua index eb93cce..7f16890 100644 --- a/lua/one-nvim.lua +++ b/lua/one-nvim.lua @@ -1,4 +1,4 @@ -local vim, api, fn, exe = vim, vim.api, vim.fn, vim.api.nvim_command +local vim, api, fn, exe, go = vim, vim.api, vim.fn, vim.api.nvim_command, vim.go --[[ VARIABLES ]] -- These are constants for the indexes in the colors that were defined before. @@ -10,8 +10,8 @@ local _TYPE_STRING = 'string' local _TYPE_TABLE = 'table' -- Determine which set of colors to use. -local _USE_HEX = vim.o.termguicolors -local _USE_256 = tonumber(vim.go.t_Co) > 255 +local _USE_HEX = go.termguicolors +local _USE_256 = tonumber(go.t_Co) > 255 or string.find(vim.env.TERM, '256') --[[ HELPER FUNCTIONS ]] @@ -68,7 +68,7 @@ local function tohex(rgb) return string.format('#%06x', rgb) end -- Load specific &bg instructions local function use_background_with(attributes) return setmetatable( - attributes[vim.o.background], + attributes[go.background], {['__index'] = attributes} ) end @@ -78,7 +78,7 @@ end local highlite = {} function highlite.group(group_name) - local no_errors, group_definition = pcall(api.nvim_get_hl_by_name, group_name, vim.o.termguicolors) + local no_errors, group_definition = pcall(api.nvim_get_hl_by_name, group_name, go.termguicolors) if not no_errors then group_definition = {} end @@ -108,7 +108,7 @@ function highlite.highlight(highlight_group, attributes) -- {{{ † highlight_cmd[5] = attributes else -- The `highlight_group` is uniquely defined. -- Take care of special instructions for certain background colors. - if attributes[vim.o.background] then + if attributes[go.background] then attributes = use_background_with(attributes) end @@ -130,7 +130,7 @@ end function highlite:highlight_terminal(terminal_ansi_colors) for index, color in ipairs(terminal_ansi_colors) do - vim.g['terminal_color_'..index] = vim.o.termguicolors and color[_PALETTE_HEX] or color[_PALETTE_256] or get(color, _PALETTE_ANSI) + vim.g['terminal_color_'..index] = go.termguicolors and color[_PALETTE_HEX] or color[_PALETTE_256] or get(color, _PALETTE_ANSI) end end @@ -167,7 +167,7 @@ return setmetatable(highlite, { color_name = nil -- If we aren't using hex nor 256 colorsets. - if not (_USE_HEX or _USE_256) then vim.go.t_Co = '16' end + if not (_USE_HEX or _USE_256) then go.t_Co = '16' end -- Highlight the baseline. self.highlight('Normal', normal)