fix: typo (#997)

This commit is contained in:
Zhizhen He 2023-03-30 12:12:37 +08:00 committed by GitHub
parent f7b3daf1ae
commit 6bb1f80a98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 45 additions and 47 deletions

View File

@ -29,7 +29,7 @@ Good luck!
*Let's introduce you to the tools we use.* *Let's introduce you to the tools we use.*
- Your PR needs to pass tests & linter. We lint our codebase with [luacheck](https://github.com/mpeterv/luacheck) - Your PR needs to pass tests & linter. We lint our codebase with [luacheck](https://github.com/mpeterv/luacheck)
and run tests with [plenary-test][plenary.nvim] these will be ran on CI. If you want you can run tests & linter and run tests with [plenary-test][plenary.nvim] these will be run on CI. If you want you can run tests & linter
locally with `make test` & `make lint` respectively. Or `make check` to run both linter & tests. For running locally with `make test` & `make lint` respectively. Or `make check` to run both linter & tests. For running
tests you'll have to make sure lualine.nvim, [plenary.nvim][plenary.nvim] and tests you'll have to make sure lualine.nvim, [plenary.nvim][plenary.nvim] and
[nvim-web-devicons](https://github.com/kyazdani42/nvim-web-devicons) are in same directory. [nvim-web-devicons](https://github.com/kyazdani42/nvim-web-devicons) are in same directory.

View File

@ -470,7 +470,7 @@ sections = {
#### Component specific options #### Component specific options
These are options that are available on specific components. These are options that are available on specific components.
For example you have option on `diagnostics` component to For example, you have option on `diagnostics` component to
specify what your diagnostic sources will be. specify what your diagnostic sources will be.
#### buffers component options #### buffers component options
@ -867,7 +867,7 @@ require('lualine').setup { extensions = { my_extension } }
### Refreshing lualine ### Refreshing lualine
By default lualine refreshes itself based on timer and some events. You can set By default lualine refreshes itself based on timer and some events. You can set
the interval of the timer with refresh option. However you can also force the interval of the timer with refresh option. However you can also force
lualine to refresh at any time by calling lualine.refresh function. lualine to refresh at any time by calling `lualine.refresh` function.
```lua ```lua
require('lualine').refresh({ require('lualine').refresh({
scope = 'tabpage', -- scope of refresh all/tabpage/window scope = 'tabpage', -- scope of refresh all/tabpage/window
@ -882,7 +882,7 @@ So you can simply do
require('lualine').refresh() require('lualine').refresh()
``` ```
Avoid calling lualine.refresh inside components. Since components are evaluated Avoid calling `lualine.refresh` inside components. Since components are evaluated
during refresh, calling refresh while refreshing can have undesirable effects. during refresh, calling refresh while refreshing can have undesirable effects.
### Disabling lualine ### Disabling lualine

View File

@ -54,7 +54,7 @@ But if `g:ayuprefermirage` exists, it will load ayu_mirage instead when
### base16 ### base16
This theme will automatically uses colors defined by your colorscheme using [RRethy/nvim-base16](https://github.com/RRethy/nvim-base16)] plugin. This theme will automatically use colors defined by your colorscheme using [RRethy/nvim-base16](https://github.com/RRethy/nvim-base16)] plugin.
The following example is using the `tomorrow-night` colorscheme: The following example is using the `tomorrow-night` colorscheme:
<p> <p>

View File

@ -73,7 +73,7 @@ local function ins_left(component)
table.insert(config.sections.lualine_c, component) table.insert(config.sections.lualine_c, component)
end end
-- Inserts a component in lualine_x ot right section -- Inserts a component in lualine_x at right section
local function ins_right(component) local function ins_right(component)
table.insert(config.sections.lualine_x, component) table.insert(config.sections.lualine_x, component)
end end

View File

@ -358,7 +358,7 @@ local function refresh(opts)
local wins = {} local wins = {}
local old_actual_curwin = vim.g.actual_curwin local old_actual_curwin = vim.g.actual_curwin
-- ignore focus on filetypes listes in options.ignore_focus -- ignore focus on filetypes listed in options.ignore_focus
local curwin = vim.api.nvim_get_current_win() local curwin = vim.api.nvim_get_current_win()
local curtab = vim.api.nvim_get_current_tabpage() local curtab = vim.api.nvim_get_current_tabpage()
if last_focus[curtab] == nil or not vim.api.nvim_win_is_valid(last_focus[curtab]) then if last_focus[curtab] == nil or not vim.api.nvim_win_is_valid(last_focus[curtab]) then

View File

@ -201,7 +201,7 @@ function M:apply_section_separators()
end end
end end
---Add on click funtion description to already drawn item ---Add on click function description to already drawn item
function M:apply_on_click() function M:apply_on_click()
if self.on_click_id then if self.on_click_id then
self.status = self:format_fn(self.on_click_id, self.status) self.status = self:format_fn(self.on_click_id, self.status)

View File

@ -84,7 +84,7 @@ end
---updates the job args ---updates the job args
function M.update_diff_args() function M.update_diff_args()
-- Donn't show git diff when current buffer doesn't have a filename -- Don't show git diff when current buffer doesn't have a filename
active_bufnr = tostring(vim.api.nvim_get_current_buf()) active_bufnr = tostring(vim.api.nvim_get_current_buf())
if #vim.fn.expand('%') == 0 then if #vim.fn.expand('%') == 0 then
M.diff_args = nil M.diff_args = nil
@ -121,7 +121,7 @@ function M.update_diff_args()
M.update_git_diff() M.update_git_diff()
end end
---update git_diff veriable ---update git_diff variable
function M.update_git_diff() function M.update_git_diff()
if M.diff_args then if M.diff_args then
diff_output_cache = {} diff_output_cache = {}

View File

@ -183,7 +183,7 @@ function M.highlight(name, foreground, background, gui, link)
} }
end end
---Attach a hl to another, so the attachee auto updates on change to hl that it's attached too. ---Attach a hl to another, so the attached auto updates on change to hl that it's attached too.
---@param provider string the hl receiver is getting attached to ---@param provider string the hl receiver is getting attached to
---@param receiver string the hl that will be auto updated upon change to provider ---@param receiver string the hl that will be auto updated upon change to provider
---@param provider_el_type string (fg/bg) what element receiver relates to of provider ---@param provider_el_type string (fg/bg) what element receiver relates to of provider
@ -328,7 +328,7 @@ function M.create_component_highlight_group(color, highlight_tag, options, apply
end end
if type(color) ~= 'function' and (apply_no_default or (color.bg and color.fg)) then if type(color) ~= 'function' and (apply_no_default or (color.bg and color.fg)) then
-- When bg and fg are both present we donn't need to set highlighs for -- When bg and fg are both present we don't need to set highlights for
-- each mode as they will surely look the same. So we can work without options -- each mode as they will surely look the same. So we can work without options
local highlight_group_name = table.concat({ 'lualine', section, highlight_tag }, '_') local highlight_group_name = table.concat({ 'lualine', section, highlight_tag }, '_')
M.highlight(highlight_group_name, color.fg, color.bg, color.gui, nil) M.highlight(highlight_group_name, color.fg, color.bg, color.gui, nil)

View File

@ -70,11 +70,11 @@ local function clamp(val, left, right)
end end
-- Changes brightness of rgb_color by percentage -- Changes brightness of rgb_color by percentage
local function brightness_modifier(rgb_color, parcentage) local function brightness_modifier(rgb_color, percentage)
local color = rgb_str2num(rgb_color) local color = rgb_str2num(rgb_color)
color.red = clamp(color.red + (color.red * parcentage / 100), 0, 255) color.red = clamp(color.red + (color.red * percentage / 100), 0, 255)
color.green = clamp(color.green + (color.green * parcentage / 100), 0, 255) color.green = clamp(color.green + (color.green * percentage / 100), 0, 255)
color.blue = clamp(color.blue + (color.blue * parcentage / 100), 0, 255) color.blue = clamp(color.blue + (color.blue * percentage / 100), 0, 255)
return rgb_num2str(color) return rgb_num2str(color)
end end
@ -90,19 +90,17 @@ end
-- Changes brightness of foreground color to achieve contrast -- Changes brightness of foreground color to achieve contrast
-- without changing the color -- without changing the color
local function apply_contrast(highlight) local function apply_contrast(highlight)
local hightlight_bg_avg = get_color_avg(highlight.bg) local highlight_bg_avg = get_color_avg(highlight.bg)
local contrast_threshold_config = clamp(contrast_threshold, 0, 0.5) local contrast_threshold_config = clamp(contrast_threshold, 0, 0.5)
local contranst_change_step = 5 local contrast_change_step = 5
if hightlight_bg_avg > 0.5 then if highlight_bg_avg > 0.5 then
contranst_change_step = -contranst_change_step contrast_change_step = -contrast_change_step
end end
-- Don't waste too much time here max 25 iteration should be more than enough -- Don't waste too much time here max 25 iteration should be more than enough
local iteration_count = 1 local iteration_count = 1
while while math.abs(get_color_avg(highlight.fg) - highlight_bg_avg) < contrast_threshold_config and iteration_count < 25 do
math.abs(get_color_avg(highlight.fg) - hightlight_bg_avg) < contrast_threshold_config and iteration_count < 25 highlight.fg = contrast_modifier(highlight.fg, contrast_change_step)
do
highlight.fg = contrast_modifier(highlight.fg, contranst_change_step)
iteration_count = iteration_count + 1 iteration_count = iteration_count + 1
end end
end end

View File

@ -15,7 +15,7 @@ function M.register_fn(id, fn)
end end
---Get the function with id ---Get the function with id
---@param id number id of the fn to retrive ---@param id number id of the fn to retrieve
---@return function ---@return function
function M.get_fn(id) function M.get_fn(id)
vim.validate { id = { id, 'n' } } vim.validate { id = { id, 'n' } }

View File

@ -243,7 +243,7 @@ local function load_theme(theme_name)
end end
if not file_found then if not file_found then
-- This shouldn't happen but somehow we have multiple files but they -- This shouldn't happen but somehow we have multiple files but they
-- apear to be in lualines repo . Just run the first one -- appear to be in lualines repo . Just run the first one
retval = dofile(files[1]) retval = dofile(files[1])
end end
end end

View File

@ -12,7 +12,7 @@ local highlight = require('lualine.highlight')
---@param section table list of components ---@param section table list of components
---@param section_name string used for getting proper hl ---@param section_name string used for getting proper hl
---@param is_focused boolean ---@param is_focused boolean
---@return string formated string for a section ---@return string formatted string for a section
--TODO Clean this up this does lots of messy stuff. --TODO Clean this up this does lots of messy stuff.
function M.draw_section(section, section_name, is_focused) function M.draw_section(section, section_name, is_focused)
local highlight_name = highlight.format_highlight(section_name, is_focused) local highlight_name = highlight.format_highlight(section_name, is_focused)
@ -21,7 +21,7 @@ function M.draw_section(section, section_name, is_focused)
for _, component in pairs(section) do for _, component in pairs(section) do
-- load components into status table -- 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 return '' -- unknown element in section. section possibly not yet loaded
end end
table.insert(status, component:draw(highlight_name, is_focused)) table.insert(status, component:draw(highlight_name, is_focused))
end end
@ -81,14 +81,14 @@ function M.draw_section(section, section_name, is_focused)
end end
end end
local left_sparator_string = '' local left_separator_string = ''
if if
section_name > 'x' section_name > 'x'
and section[first_component_no] and section[first_component_no]
and type(section[first_component_no].options.separator) ~= 'table' and type(section[first_component_no].options.separator) ~= 'table'
and (section[1].options.section_separators.right ~= nil and section[1].options.section_separators.right ~= '') and (section[1].options.section_separators.right ~= nil and section[1].options.section_separators.right ~= '')
then then
left_sparator_string = string.format( left_separator_string = string.format(
'%%s{%s}', '%%s{%s}',
section[first_component_no].options.ls_separator or section[1].options.section_separators.right section[first_component_no].options.ls_separator or section[1].options.section_separators.right
) )
@ -107,17 +107,17 @@ function M.draw_section(section, section_name, is_focused)
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 if find_start_trans_sep_start then
-- the section doesn't need to be prepended with default hl when sections -- the section doesn't need to be prepended with default hl when sections
-- first component has trasitionals sep -- first component has transitional sep
needs_hl = status_str:find('^%%#', find_start_trans_sep_end + 1) needs_hl = status_str:find('^%%#', find_start_trans_sep_end + 1)
else else
needs_hl = status_str:find('^%%#') needs_hl = status_str:find('^%%#')
end end
if needs_hl then if needs_hl then
-- Don't prepend with old highlight when the component changes it imidiately -- Don't prepend with old highlight when the component changes it immediately
return left_sparator_string .. status_str return left_separator_string .. status_str
else else
return left_sparator_string .. highlight_name .. status_str return left_separator_string .. highlight_name .. status_str
end end
end end

View File

@ -191,13 +191,13 @@ function M.stl_escape(str)
return str:gsub('%%', '%%%%') return str:gsub('%%', '%%%%')
end end
---A safe call inside a timmer ---A safe call inside a timer
---@param timer userdata ---@param timer userdata
---@param augroup string|nil autocmd group to reset too on error. ---@param augroup string|nil autocmd group to reset too on error.
---@param fn function ---@param fn function
---@param max_err integer ---@param max_err integer
---@param err_msg string ---@param err_msg string
---@return function a wraped fn that can be called inside a timer and that ---@return function a wrapped fn that can be called inside a timer and that
---stops the timer after max_err errors in calling fn ---stops the timer after max_err errors in calling fn
function M.timer_call(timer, augroup, fn, max_err, err_msg) function M.timer_call(timer, augroup, fn, max_err, err_msg)
local err_cnt, ret = 0, nil local err_cnt, ret = 0, nil

View File

@ -16,7 +16,7 @@ if source:sub(1, 1) == '@' then
end end
end end
--- checks if name is valied --- checks if name is valid
---@param name string ---@param name string
---@return boolean ---@return boolean
function M.is_valid_filename(name) function M.is_valid_filename(name)

View File

@ -35,7 +35,7 @@ M.assert_component = function(component, opts, result, is_active)
eq(result, comp:draw(opts.hl, is_active or true)) eq(result, comp:draw(opts.hl, is_active or true))
end end
function M.assert_component_instence(comp, result) function M.assert_component_instance(comp, result)
eq(result, comp:draw(comp.options.hl)) eq(result, comp:draw(comp.options.hl))
end end
-- sets defaults for component options -- sets defaults for component options

View File

@ -757,7 +757,7 @@ describe('Branch component', function()
"git -c user.name='asdf' -c user.email='asdf@jlk.org' -C " .. tmpdir .. ' ' .. string.format(...) "git -c user.name='asdf' -c user.email='asdf@jlk.org' -C " .. tmpdir .. ' ' .. string.format(...)
) )
end end
local assert_comp_ins = helpers.assert_component_instence local assert_comp_ins = helpers.assert_component_instance
before_each(function() before_each(function()
tmpdir = os.tmpname() tmpdir = os.tmpname()

View File

@ -73,7 +73,7 @@ describe('config parsing', function()
eq(config.options.section_separators, { left = 'b', right = 'a' }) eq(config.options.section_separators, { left = 'b', right = 'a' })
end) end)
end) end)
it('no seprarators', function() it('no separators', function()
local config = { local config = {
options = { component_separators = {}, section_separators = {} }, options = { component_separators = {}, section_separators = {} },
} }

View File

@ -26,7 +26,7 @@ describe('Lualine', function()
statusline = 1000, statusline = 1000,
tabline = 1000, tabline = 1000,
winbar = 1000, winbar = 1000,
} },
}, },
sections = { sections = {
lualine_a = { 'mode' }, lualine_a = { 'mode' },
@ -102,7 +102,7 @@ describe('Lualine', function()
]===]) ]===])
end) end)
it('get_config can retrive config', function() it('get_config can retrieve config', function()
eq(config, require('lualine').get_config()) eq(config, require('lualine').get_config())
end) end)
@ -207,7 +207,7 @@ describe('Lualine', function()
]===]) ]===])
end) end)
it('mid divider can be disbled on special case', function() it('mid divider can be disabled on special case', function()
config.options.always_divide_middle = false config.options.always_divide_middle = false
config.sections.lualine_x = {} config.sections.lualine_x = {}
config.sections.lualine_y = {} config.sections.lualine_y = {}

View File

@ -10,7 +10,7 @@ local stub = require('luassert.stub')
describe('Utils', function() describe('Utils', function()
local utils = require('lualine.utils.utils') local utils = require('lualine.utils.utils')
it('can retrive highlight groups', function() it('can retrieve highlight groups', function()
local hl2 = { fg = '#aabbcc', bg = '#889977', sp = '#997788', reverse = true, undercurl = true } local hl2 = { fg = '#aabbcc', bg = '#889977', sp = '#997788', reverse = true, undercurl = true }
-- handles non existing hl groups -- handles non existing hl groups
eq(utils.extract_highlight_colors('hl2'), nil) eq(utils.extract_highlight_colors('hl2'), nil)
@ -79,7 +79,7 @@ describe('Utils', function()
end) end)
end) end)
describe('Cterm genarator', function() describe('Cterm generator', function()
local cterm = require('lualine.utils.color_utils') local cterm = require('lualine.utils.color_utils')
it('can convert rgb to cterm', function() it('can convert rgb to cterm', function()
@ -90,7 +90,7 @@ describe('Cterm genarator', function()
end) end)
end) end)
describe('Section genarator', function() describe('Section generator', function()
local hl = require('lualine.highlight') local hl = require('lualine.highlight')
stub(hl, 'format_highlight') stub(hl, 'format_highlight')
hl.format_highlight.returns('%#lualine_c_normal#') hl.format_highlight.returns('%#lualine_c_normal#')

View File

@ -42,7 +42,7 @@
---]===]) ---]===])
--- ``` --- ```
--- ---
--- For more flexibility you can match a patten in expect block. --- For more flexibility you can match a pattern in expect block.
--- ``lua --- ``lua
--- statusline:expect([===[ --- statusline:expect([===[
--- highlights = { --- highlights = {