diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 89e3167..7963874 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -3,36 +3,39 @@ Thanks for considering to contribute. ### Getting started -You're not sure where to help. You can try these -- You can look at the currently open [issues](https://github.com/nvim-lualine/lualine.nvim/issues) to see if some bug needs fixing or for - cool feature idea. You should also look at currently open prs to see - if some abandoned pr interests you
+ +If you're not sure where to help? You can try these: + +- You can look at the currently open [issues](https://github.com/nvim-lualine/lualine.nvim/issues) + to see if some bug needs fixing or for cool feature ideas.
+ You should also look at currently open PRs ([Pull requests](https://github.com/nvim-lualine/lualine.nvim/pulls)) to see if some abandoned PR interests you.
*We could really use some help with tests & docs they are currently lacking :)* -- You can add exciting new component, extension or theme. +- You can add an exciting new component, extension or theme. Note: Currently we aren't adding regular colorscheme based themes. - We think they make more sense with colorschemes as they tend not to get - updated once added here. But if you have some unique themes idea like [auto](https://github.com/nvim-lualine/lualine.nvim/blob/master/THEMES.md#auto) or [pywal](https://github.com/nvim-lualine/lualine.nvim/blob/master/THEMES.md#pywal) feel free to open an pr or issue. -- Feel free to open issues or unfinished pr for help. - I'd actually recommend you to open an issue first for bigging prs to discuss - the feature with maintainer beforehand. That way you'll can know if the - feature is likely to be accepted or not before you get started also you'll - get recommendation and help with implementation specially if you show + We think they make more sense with colorschemes as they tend not to get + updated once added here. But if you have some unique themes idea like [auto](https://github.com/nvim-lualine/lualine.nvim/blob/master/THEMES.md#auto) or [pywal](https://github.com/nvim-lualine/lualine.nvim/blob/master/THEMES.md#pywal) feel free to open an PR or issue. +- Feel free to open issues or unfinished PRs for help. + I'd actually recommend you to open an issue first for bigger PRs to discuss + the feature with a maintainer beforehand. That way you can know if the + feature is likely to be accepted or not before you get started. + You'll get recommendation and help with implementation specially if you show willingness to implement it yourself. - Do add tests and docs for your changes. -Good luck. +Good luck! + +### Developer tools -### Devloper tools *Let's introduce you to the tools we use.* -- Your pr need 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](https://github.com/nvim-lua/plenary.nvim) these will be ran 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 tests you'll have to make sure both lualine.nvim and plenery.nvim are in same directory. -- lua codebase gets formatted with [stylua](https://github.com/JohnnyMorganz/StyLua) in CI. +- Lua codebase gets formatted with [stylua](https://github.com/JohnnyMorganz/StyLua) in CI. So you can ignore formatting. But if you want to submit formatted - pr you can run formatter locally with `make format`. + PR you can run formatter locally with `make format`. - VimDocs are auto generated with [panvimdoc](https://github.com/kdheepak/panvimdoc) from README.md. So don't make changes to doc/lualine.txt . Instead add your docs to README or Wiki. The docgen in ran by CI too. If you want to run it locally you can do so @@ -41,5 +44,5 @@ Good luck. - You can check our test coverage with `make testcov`. You'll need to have [luacov](https://github.com/keplerproject/luacov) & [luacov-console](https://github.com/spacewander/luacov-console) installed for that. - If you want the luacovs detailed report files run the command with NOCLEAN env set. + If you want luacov's detailed report files, run the command with the `NOCLEAN` env set. For example `NOCLEAN=1 make testcov` diff --git a/README.md b/README.md index 3c46220..6529e92 100644 --- a/README.md +++ b/README.md @@ -465,7 +465,7 @@ sections = { symbols = { modified = ' ●', -- Text to show when the buffer is modified - alternate_file = '#', -- Text to show to indify the alternate file + alternate_file = '#', -- Text to show to identify the alternate file directory = '', -- Text to show when the buffer is a directory }, } @@ -685,29 +685,35 @@ tabline = { ``` #### Buffers + Shows currently open buffers. Like bufferline . See [buffers options](#buffers-component-options) for all builtin behaviors of buffers component. You can use `:LualineBuffersJump` to jump to buffer based on index of buffer in buffers component. + ```vim :LualineBuffersJump 2 " Jumps to 2nd buffer in buffers component. :LualineBuffersJump $ " Jumps to last buffer in buffers component. ``` #### Tabs + Shows currently open tab. Like usual tabline. See [tabs options](#tabs-component-options) for all builtin behaviors of tabs component. You can also use `:LualineRenameTab` to set a name for a tabpage. For example: + ```vim :LualineRenameTab Project_K -```` +``` + It's useful when you're using rendering mode 2/3 in tabs. -To unname a tablage run `:LualineRenameTab` without argument. +To unname a tabpage run `:LualineRenameTab` without argument. #### Tabline as statusline + You can also completely move your statusline to a tabline by configuring `lualine.tabline` and disabling `lualine.sections` and `lualine.inactive_sections`: @@ -797,6 +803,7 @@ If you want to extend lualine with plugins or want to know which ones already do, [wiki/plugins](https://github.com/nvim-lualine/lualine.nvim/wiki/Plugins) is for you. ### Support + If you appreciate my work you can buy me a coffee. Buy Me A Coffee diff --git a/THEMES.md b/THEMES.md index 6b4b0ea..6aba355 100644 --- a/THEMES.md +++ b/THEMES.md @@ -3,11 +3,13 @@ All available themes are only best effort ports by myself/ other users. If you find a theme to be weird/ wrong please open an issue/ pr. ### auto + auto is a special theme. It will automatically load theme for your colorscheme. If there's no theme available for your colorscheme then it'll try it's best to generate one. ### 16color +

@@ -16,6 +18,7 @@ it'll try it's best to generate one.

### ayu_dark +

@@ -24,6 +27,7 @@ it'll try it's best to generate one.

### ayu_light +

@@ -32,6 +36,7 @@ it'll try it's best to generate one.

### ayu_mirage +

@@ -40,6 +45,7 @@ it'll try it's best to generate one.

### ayu + It's a combination of ayu_light, ayu_dark & ayu_mirage. If `g:ayucolor` exists, it loads one of these based on your `g:ayucolor` option. Otherwise, it will load ayu_light when background=light and ayu_dark when background=dark @@ -59,6 +65,7 @@ The following example is using the `tomorrow-night` colorscheme:

### codedark +

@@ -67,6 +74,7 @@ The following example is using the `tomorrow-night` colorscheme:

### dracula +

@@ -75,6 +83,7 @@ The following example is using the `tomorrow-night` colorscheme:

### everforest +

@@ -83,6 +92,7 @@ The following example is using the `tomorrow-night` colorscheme:

### gruvbox_dark +

@@ -91,6 +101,7 @@ The following example is using the `tomorrow-night` colorscheme:

### gruvbox_light +

@@ -99,10 +110,12 @@ The following example is using the `tomorrow-night` colorscheme:

### gruvbox + It's a combination of gruvbox_light and gruvbox_dark. It loads either of them based you your `background` option. ### gruvbox-material +

@@ -111,6 +124,7 @@ them based you your `background` option.

### horizon +

@@ -119,6 +133,7 @@ them based you your `background` option.

### iceberg_dark +

@@ -127,6 +142,7 @@ them based you your `background` option.

### iceberg_light +

@@ -135,10 +151,12 @@ them based you your `background` option.

### iceberg + It's a combination of iceberg_light and iceberg_dark. It loads either of them based you your `background` option. ### jellybeans +

@@ -147,6 +165,7 @@ them based you your `background` option.

### material +

@@ -155,6 +174,7 @@ them based you your `background` option.

### modus-vivendi +

@@ -163,6 +183,7 @@ them based you your `background` option.

### molokai +

@@ -171,6 +192,7 @@ them based you your `background` option.

### moonfly +

@@ -179,6 +201,7 @@ them based you your `background` option.

### nightfly +

@@ -187,6 +210,7 @@ them based you your `background` option.

### nord +

@@ -195,6 +219,7 @@ them based you your `background` option.

### OceanicNext +

@@ -203,6 +228,7 @@ them based you your `background` option.

### onedark +

@@ -211,6 +237,7 @@ them based you your `background` option.

### onelight +

@@ -219,6 +246,7 @@ them based you your `background` option.

### palenight +

@@ -227,6 +255,7 @@ them based you your `background` option.

### papercolor_dark +

@@ -235,6 +264,7 @@ them based you your `background` option.

### papercolor_light +

@@ -243,10 +273,12 @@ them based you your `background` option.

### PaperColor + It's a combination of papercolor_light and papercolor_dark. It loads either of them based you your `background` option. ### powerline +

@@ -255,6 +287,7 @@ them based you your `background` option.

### powerline_dark +

@@ -263,6 +296,7 @@ them based you your `background` option.

### pywal + pywal is another special theme. It will load the colors from your current [pywal](https://github.com/dylanaraps/pywal) cache, specifically `~/.cache/wal/colors.sh` and generate a theme. #### `wal --theme ashes` @@ -282,6 +316,7 @@ pywal is another special theme. It will load the colors from your current [pywal ### seoul256 +

@@ -290,6 +325,7 @@ pywal is another special theme. It will load the colors from your current [pywal

### solarized_dark +

@@ -298,6 +334,7 @@ pywal is another special theme. It will load the colors from your current [pywal

### solarized_light +

@@ -306,6 +343,7 @@ pywal is another special theme. It will load the colors from your current [pywal

### Tomorrow +

@@ -314,6 +352,7 @@ pywal is another special theme. It will load the colors from your current [pywal

### wombat +

diff --git a/lua/lualine.lua b/lua/lualine.lua index 717d14c..c2356bd 100644 --- a/lua/lualine.lua +++ b/lua/lualine.lua @@ -12,8 +12,8 @@ local modules = lualine_require.lazy_require { local config -- Stores currently applied config -- Helper for apply_transitional_separators() ---- finds first applied highlight group fter str_checked in status ----@param status string : unprossed statusline string +--- finds first applied highlight group after str_checked in status +---@param status string : unprocessed statusline string ---@param str_checked number : position of how far status has been checked ---@return string|nil the hl group name or nil local function find_next_hl(status, str_checked) @@ -36,11 +36,11 @@ end -- Helper for apply_transitional_separators() --- applies transitional separator highlight + transitional separator ----@param status string : unprossed statusline string +---@param status string : unprocessed statusline string ---@param str_checked number : position of how far status has been checked ---@param last_hl string : last applied hl group name before str_checked ---@param reverse boolean : reverse the hl group ( true for right separators ) ----@return string|nil concated separator highlight and transitional separator +---@return string|nil concatenate separator highlight and transitional separator local function fill_section_separator(status, is_focused, str_checked, last_hl, sep, reverse) -- Inserts transitional separator along with transitional highlight local next_hl = find_next_hl(status, str_checked) @@ -63,12 +63,12 @@ end --- processes statusline string --- replaces %s/S{sep} with proper left/right separator highlight + sep ----@param status string : unprossed statusline string +---@param status string : unprocessed statusline string ---@return string : processed statusline string local function apply_transitional_separators(status, is_focused) - local status_applied = {} -- Collects all the pieces for concatation - local last_hl -- Stores lash highligjt group that we found - local last_hl_reseted = false -- Whether last_hl is nil because we reseted + local status_applied = {} -- Collects all the pieces for concatenation + local last_hl -- Stores last highlight group that we found + local last_hl_reseted = false -- Whether last_hl is nil after reset -- it after %= 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 @@ -120,10 +120,10 @@ local function apply_transitional_separators(status, is_focused) 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 -- 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 + -- This check for lualine_a and lualine_b is dumb. It doesn't guarantee + -- c or x section isn't present. Worst case scenario after this patch -- we have another visual bug that occurs less frequently. - -- Annoying Edge Cases............................................ + -- Annoying Edge Cases last_hl = nil last_hl_reseted = true str_checked = str_checked + 1 -- Skip the following % too @@ -138,7 +138,7 @@ end --- creates the statusline string ---@param sections table : section config where components are replaced with --- component objects ----@param is_focused boolean : whether being evsluated for focused window or not +---@param is_focused boolean : whether being evaluated for focused window or not ---@return string statusline string local statusline = modules.utils.retry_call_wrap(function(sections, is_focused) -- The sequence sections should maintain [SECTION_SEQUENCE] @@ -176,10 +176,10 @@ end) --- check if any extension matches the filetype and return proper sections ---@param current_ft string : filetype name of current file ----@param is_focused boolean : whether being evsluated for focused window or not +---@param is_focused boolean : whether being evaluated for focused window or not ---@return table : (section_table) section config where components are replaced with --- component objects --- TODO: change this so it uses a hash table instead of iteration over lisr +-- TODO: change this so it uses a hash table instead of iteration over list -- to improve redraws. Add buftype / bufname for extensions -- or some kind of cond ? local function get_extension_sections(current_ft, is_focused) @@ -217,13 +217,13 @@ Also provide what colorscheme you're using. modules.utils_notices.add_notice(string.format(message_template, theme_name)) end ---- sets up theme by defining hl groups and setting theme cache in highlight.lua ---- uses options.theme option for theme if it's a string loads theme of that name ---- if it's a table directlybuses it . ---- when theme load fails this fallsback to 'auto' theme if even that fails ---- this falls back to 'gruvbox' theme ---- also sets up auto command to reload lualine on ColorScheme or background ---- change on +--- Sets up theme by defining hl groups and setting theme cache in 'highlight.lua'. +--- Uses 'options.theme' variable to apply the theme: +--- - If the value is a string, it'll load a theme of that name. +--- - If it's a table, it's directly used as the theme. +--- If loading the theme fails, this falls back to 'auto' theme. +--- If the 'auto' theme also fails, this falls back to 'gruvbox' theme. +--- Also sets up auto command to reload lualine on ColorScheme or background changes. local function setup_theme() local function get_theme_from_config() local theme_name = config.options.theme @@ -263,7 +263,7 @@ local function set_tabline() end end ---- Sets &ststusline option to lualine +--- Sets &statusline option to lualine --- adds auto command to redraw lualine on VimResized event local function set_statusline() if next(config.sections) ~= nil or next(config.inactive_sections) ~= nil then @@ -282,7 +282,7 @@ end -- lualine.statusline function --- Draw correct statusline for current window ----@param focused boolean : force the value of is_focused . useful for debugging +---@param focused boolean : force the value of is_focused . Useful for debugging ---@return string statusline string local function status_dispatch(focused) local retval @@ -313,12 +313,12 @@ end -- lualine.setup function --- sets new user config ---- This function doesn't load components/theme etc.. they are done before ---- first statusline redraw after new config. This is more efficient when ---- lualine config is done in several setup calls in chunks. This way ---- we don't intialize components just to throgh them away .Instead they are +--- This function doesn't load components/theme etc... They are done before +--- first statusline redraw and after new config. This is more efficient when +--- lualine config is done in several setup calls as chunks. This way +--- we don't initialize components just to throw them away. Instead they are --- initialized when we know we will use them. ---- sets &last_status tl 2 +--- sets &last_status to 2 ---@param user_config table table local function setup(user_config) if package.loaded['lualine.utils.notices'] then diff --git a/lua/lualine/component.lua b/lua/lualine/component.lua index ded321f..0432832 100644 --- a/lua/lualine/component.lua +++ b/lua/lualine/component.lua @@ -34,7 +34,7 @@ function M:init(options) end ---sets the default separator for component based on whether the component ----is in left sections or right sections when separator option is omited. +---is in left sections or right sections when separator option is omitted. function M:set_separator() if self.options.separator == nil then if self.options.component_separators then @@ -73,7 +73,7 @@ function M:apply_padding() end if l_padding then if self.status:find('%%#.*#') == 1 then - -- When component has changed the highlight at begining + -- When component has changed the highlight at beginning -- 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) @@ -95,10 +95,10 @@ function M:apply_highlights(default_highlight) end 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 + -- 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 necessary self.status = self.status .. default_highlight - -- Also put it in applied sep so when sep get struped so does the hl + -- Also put it in applied sep so when sep get striped so does the hl self.applied_separator = default_highlight end -- Prepend default hl when the component doesn't start with hl otherwise @@ -108,7 +108,7 @@ function M:apply_highlights(default_highlight) end end ----apply icon to component (appends/prepemds component with icon) +---apply icon to component (appends/prepends component with icon) function M:apply_icon() local icon = self.options.icon if self.options.icons_enabled and icon then @@ -202,15 +202,15 @@ end ---create a lualine highlight for color ---@param color table|string|function defined color for hl ---@param hint string|nil hint for hl name ----@return table an identifier to later retrive the hl for application +---@return table an identifier to later retrieve the hl for application function M:create_hl(color, hint) hint = hint and self.options.component_name .. '_' .. hint or self.options.component_name return highlight.create_component_highlight_group(color, hint, self.options, false) end ----Get stl formated hl group for hl_token ----@param hl_token table indentifier received from create_hl or create_component_highlight_group ----@return string stl formated hl group for hl_token +---Get stl formatted hl group for hl_token +---@param hl_token table identifier received from create_hl or create_component_highlight_group +---@return string stl formatted hl group for hl_token function M:format_hl(hl_token) return highlight.component_format_highlight(hl_token) end @@ -223,7 +223,7 @@ function M:update_status(is_focused) end ---driver code of the class ---@param default_highlight string default hl group of section where component resides ---@param is_focused boolean|number whether drawing for active or inactive statusline. ----@return string stl formated rendering string for component +---@return string stl formatted rendering string for component function M:draw(default_highlight, is_focused) self.status = '' self.applied_separator = '' diff --git a/lua/lualine/components/branch/init.lua b/lua/lualine/components/branch/init.lua index 8d3970d..7e75544 100644 --- a/lua/lualine/components/branch/init.lua +++ b/lua/lualine/components/branch/init.lua @@ -7,7 +7,7 @@ local modules = require('lualine_require').lazy_require { utils = 'lualine.utils.utils', } --- Initilizer +-- Initializer M.init = function(self, options) M.super.init(self, options) if not self.options.icon then diff --git a/lua/lualine/components/buffers/buffer.lua b/lua/lualine/components/buffers/buffer.lua index bda0b8e..618aaca 100644 --- a/lua/lualine/components/buffers/buffer.lua +++ b/lua/lualine/components/buffers/buffer.lua @@ -5,7 +5,7 @@ local modules = require('lualine_require').lazy_require { utils = 'lualine.utils.utils', } ----intialize a new buffer from opts +---initialize a new buffer from opts ---@param opts table function Buffer:init(opts) assert(opts.bufnr, 'Cannot create Buffer without bufnr') @@ -72,7 +72,7 @@ function Buffer:render() name = self.options.fmt(name or '') end - if self.ellipse then -- show elipsis + if self.ellipse then -- show ellipsis name = '...' else name = self:apply_mode(name) diff --git a/lua/lualine/components/buffers/init.lua b/lua/lualine/components/buffers/init.lua index 955d1d6..3c1ab7b 100644 --- a/lua/lualine/components/buffers/init.lua +++ b/lua/lualine/components/buffers/init.lua @@ -30,7 +30,7 @@ local default_options = { } -- This function is duplicated in tabs ----returns the proper hl for buffer in section. used for setting default highlights +---returns the proper hl for buffer in section. Used for setting default highlights ---@param section string name of section buffers component is in ---@param is_active boolean ---@return string hl name @@ -178,7 +178,7 @@ function M:update_status() data[#data + 1] = rendered_after end end - -- draw elipsis (...) on relevent sides if all buffers don't fit in max_length + -- draw ellipsis (...) on relevant sides if all buffers don't fit in max_length if total_length > max_length then if before ~= nil then before.ellipse = true diff --git a/lua/lualine/components/diff/init.lua b/lua/lualine/components/diff/init.lua index ef8dd92..976bd54 100644 --- a/lua/lualine/components/diff/init.lua +++ b/lua/lualine/components/diff/init.lua @@ -57,7 +57,7 @@ function M:init(options) modules.git_diff.init(self.options) end --- Function that runs everytime statusline is updated +-- Function that runs every time statusline is updated function M:update_status(is_focused) local git_diff = modules.git_diff.get_sign_count((not is_focused and vim.api.nvim_get_current_buf())) if git_diff == nil then diff --git a/lua/lualine/components/fileformat.lua b/lua/lualine/components/fileformat.lua index 7e5011d..49e3b3e 100644 --- a/lua/lualine/components/fileformat.lua +++ b/lua/lualine/components/fileformat.lua @@ -17,7 +17,7 @@ function M:init(options) self.symbols = vim.tbl_extend('keep', self.options.symbols or {}, symbols) end --- Function that runs everytime statusline is updated +-- Function that runs every time statusline is updated function M:update_status() local format = vim.bo.fileformat if self.options.icons_enabled then diff --git a/lua/lualine/components/special/vim_var_component.lua b/lua/lualine/components/special/vim_var_component.lua index 6ef778d..6cf89f3 100644 --- a/lua/lualine/components/special/vim_var_component.lua +++ b/lua/lualine/components/special/vim_var_component.lua @@ -4,13 +4,13 @@ local M = require('lualine.component'):extend() function M:update_status() local component = self.options[1] - -- vim veriable component + -- vim variable 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?') -- filters var portion from g:var local var_name = component:sub(#scope + 2, #component) - -- Displays nothing when veriable aren't present + -- Displays nothing when variable aren't present if not (scope and var_name) then return '' end diff --git a/lua/lualine/components/tabs/init.lua b/lua/lualine/components/tabs/init.lua index ae3b5a7..c99b7d3 100644 --- a/lua/lualine/components/tabs/init.lua +++ b/lua/lualine/components/tabs/init.lua @@ -15,7 +15,7 @@ local default_options = { } -- This function is duplicated in buffers ----returns the proper hl for tab in section. used for setting default highlights +---returns the proper hl for tab in section. Used for setting default highlights ---@param section string name of section tabs component is in ---@param is_active boolean ---@return string hl name @@ -84,7 +84,7 @@ function M:update_status() local current_tab = tabs[current] -- start drawing from current tab and draw left and right of it until -- all tabpages are drawn or max_length has been reached. - if current_tab == nil then -- maybe redundent code + if current_tab == nil then -- maybe redundant code local t = Tab { tabId = vim.api.nvim_get_current_tabpage(), tabnr = vim.fn.tabpagenr(), @@ -126,7 +126,7 @@ function M:update_status() data[#data + 1] = rendered_after end end - -- draw elipsis (...) on relevent sides if all tabs don't fit in max_length + -- draw ellipsis (...) on relevant sides if all tabs don't fit in max_length if total_length > max_length then if before ~= nil then before.ellipse = true diff --git a/lua/lualine/components/tabs/tab.lua b/lua/lualine/components/tabs/tab.lua index 1d9e191..e9d75ab 100644 --- a/lua/lualine/components/tabs/tab.lua +++ b/lua/lualine/components/tabs/tab.lua @@ -5,7 +5,7 @@ local modules = require('lualine_require').lazy_require { utils = 'lualine.utils.utils', } ----intialize a new tab from opts +---initialize a new tab from opts ---@param opts table function Tab:init(opts) assert(opts.tabnr, 'Cannot create Tab without tabnr') @@ -15,7 +15,7 @@ function Tab:init(opts) self.highlights = opts.highlights end ----returns name for tab. tabs name is the name of buffer in last active window +---returns name for tab. Tabs name is the name of buffer in last active window --- of the tab. ---@return string function Tab:label() @@ -51,7 +51,7 @@ function Tab:render() if self.options.fmt then name = self.options.fmt(name or '') end - if self.ellipse then -- show elipsis + if self.ellipse then -- show ellipsis name = '...' else -- different formats for different modes diff --git a/lua/lualine/components/windows/init.lua b/lua/lualine/components/windows/init.lua index 0ee6a95..ee00b00 100644 --- a/lua/lualine/components/windows/init.lua +++ b/lua/lualine/components/windows/init.lua @@ -7,12 +7,12 @@ local default_options = { } function M:init(options) - options.buffers_color = nil -- bufers_color isn't windpws option. + options.buffers_color = nil -- buffers_color isn't windows option. M.super.init(self, options) self.options = vim.tbl_deep_extend('keep', self.options or {}, default_options) self.options.windows_color = vim.tbl_deep_extend('keep', self.options.windows_color or {}, self.options.buffers_color) - self.options.buffers_color = nil -- this is the default value of colors generated by parent bufferes component. + self.options.buffers_color = nil -- this is the default value of colors generated by parent buffers component. self.highlights = { active = self:create_hl(self.options.windows_color.active, 'active'), diff --git a/lua/lualine/components/windows/window.lua b/lua/lualine/components/windows/window.lua index 73f7301..8c7e0a1 100644 --- a/lua/lualine/components/windows/window.lua +++ b/lua/lualine/components/windows/window.lua @@ -1,6 +1,6 @@ local Window = require('lualine.components.buffers.buffer'):extend() ----intialize a new buffer from opts +---initialize a new buffer from opts ---@param opts table function Window:init(opts) assert(opts.winnr, 'Cannot create Window without winnr') diff --git a/lua/lualine/config.lua b/lua/lualine/config.lua index 3a5dc91..dc4a476 100644 --- a/lua/lualine/config.lua +++ b/lua/lualine/config.lua @@ -48,7 +48,7 @@ local function fix_separators(separators) return separators end ----extends config based on configtable +---extends config based on config_table ---@param config_table table ---@return table copy of config local function apply_configuration(config_table) diff --git a/lua/lualine/highlight.lua b/lua/lualine/highlight.lua index 086d9b7..576fb23 100644 --- a/lua/lualine/highlight.lua +++ b/lua/lualine/highlight.lua @@ -95,7 +95,7 @@ end ---@param name string ---@param foreground string|number: color ---@param background string|number: color ----@param gui table cterm/gui options like bold/italic ect +---@param gui table cterm/gui options like bold/italic etc. ---@param link string hl_group name to link new hl to function M.highlight(name, foreground, background, gui, link) local command = { 'highlight!' } @@ -132,10 +132,10 @@ function M.highlight(name, foreground, background, gui, link) local old_hl_def = loaded_highlights[name] if old_hl_def and next(old_hl_def.attached) then -- Update attached hl groups as they announced to depend on hl_group 'name' - -- 'hl' being in 'name'a attached table means 'hl' + -- 'hl' being in 'name's attached table means 'hl' -- depends of 'name'. -- 'hl' key in attached table will contain a table that - -- defines the reletaion between 'hl' & 'name'. + -- defines the relation between 'hl' & 'name'. -- name.attached.hl = { bg = 'fg' } means -- hl's fg is same as 'names' bg . So 'hl's fg should -- be updated when ever 'name' changes it's 'bg' @@ -182,7 +182,7 @@ function M.highlight(name, foreground, background, gui, link) } end ----Attach an hl to another so attachee auto updated on change to hl it's attached too. +---Attach a hl to another, so the attachee auto updates on change to hl that it's attached too. ---@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 provider_el_type string (fg/bg) what element receiver relates to of provider diff --git a/lua/lualine/themes/OceanicNext.lua b/lua/lualine/themes/OceanicNext.lua index 72c74d2..9169139 100644 --- a/lua/lualine/themes/OceanicNext.lua +++ b/lua/lualine/themes/OceanicNext.lua @@ -1,6 +1,6 @@ -- Copyright (c) 2020-2021 shadmansaleh -- MIT license, see LICENSE for more details. --- Genarated by lightline to lualine theme converter +-- Generated by lightline to lualine theme converter -- https://gist.github.com/shadmansaleh/000871c9a608a012721c6acc6d7a19b9 -- stylua: ignore local colors = { diff --git a/lua/lualine/themes/Tomorrow.lua b/lua/lualine/themes/Tomorrow.lua index 8e101a8..48031b0 100644 --- a/lua/lualine/themes/Tomorrow.lua +++ b/lua/lualine/themes/Tomorrow.lua @@ -1,6 +1,6 @@ -- Copyright (c) 2020-2021 shadmansaleh -- MIT license, see LICENSE for more details. --- Genarated by lightline to lualine theme converter +-- Generated by lightline to lualine theme converter -- https://gist.github.com/shadmansaleh/000871c9a608a012721c6acc6d7a19b9 -- stylua: ignore local colors = { diff --git a/lua/lualine/themes/auto.lua b/lua/lualine/themes/auto.lua index 256c2ec..9f2339d 100644 --- a/lua/lualine/themes/auto.lua +++ b/lua/lualine/themes/auto.lua @@ -11,7 +11,7 @@ if color_name then end -- Check if there's a theme for current colorscheme - -- If there is load that instead of genarating a new one + -- If there is load that instead of generating a new one local ok, theme = pcall(loader.load_theme, color_name) if ok and theme then return theme @@ -19,14 +19,14 @@ if color_name then end --------------- --- Constents -- +-- Constants -- --------------- -- fg and bg must have this much contrast range 0 < contrast_threshold < 0.5 local contrast_threshold = 0.3 -- how much brightness is changed in percentage for light and dark themes local brightness_modifier_parameter = 10 --- truns #rrggbb -> { red, green, blue } +-- Turns #rrggbb -> { red, green, blue } local function rgb_str2num(rgb_color_str) if rgb_color_str:find('#') == 1 then rgb_color_str = rgb_color_str:sub(2, #rgb_color_str) @@ -37,14 +37,14 @@ local function rgb_str2num(rgb_color_str) return { red = red, green = green, blue = blue } end --- turns { red, green, blue } -> #rrggbb +-- 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) return rgb_color_str end --- returns brightness lavel of color in range 0 to 1 --- arbitary value it's basicaly an weighted average +-- Returns brightness level of color in range 0 to 1 +-- arbitrary value it's basically an weighted average local function get_color_brightness(rgb_color) local color = rgb_str2num(rgb_color) local brightness = (color.red * 2 + color.green * 3 + color.blue) / 6 @@ -52,13 +52,13 @@ local function get_color_brightness(rgb_color) end -- returns average of colors in range 0 to 1 --- used to ditermine contrast lavel +-- used to determine contrast level local function get_color_avg(rgb_color) local color = rgb_str2num(rgb_color) return (color.red + color.green + color.blue) / 3 / 256 end --- clamps the val between left and right +-- Clamps the val between left and right local function clamp(val, left, right) if val > right then return right @@ -69,7 +69,7 @@ local function clamp(val, left, right) return val end --- changes braghtness of rgb_color by percentage +-- Changes brightness of rgb_color by percentage local function brightness_modifier(rgb_color, parcentage) local color = rgb_str2num(rgb_color) color.red = clamp(color.red + (color.red * parcentage / 100), 0, 255) @@ -78,7 +78,7 @@ local function brightness_modifier(rgb_color, parcentage) return rgb_num2str(color) end --- changes contrast of rgb_color by amount +-- Changes contrast of rgb_color by amount local function contrast_modifier(rgb_color, amount) local color = rgb_str2num(rgb_color) color.red = clamp(color.red + amount, 0, 255) @@ -87,7 +87,7 @@ local function contrast_modifier(rgb_color, amount) return rgb_num2str(color) end --- Changes brightness of foreground color to achive contrast +-- Changes brightness of foreground color to achieve contrast -- without changing the color local function apply_contrast(highlight) local hightlight_bg_avg = get_color_avg(highlight.bg) @@ -97,7 +97,7 @@ local function apply_contrast(highlight) contranst_change_step = -contranst_change_step end - -- donn't waste too much time here max 25 interation should be more than enough + -- Don't waste too much time here max 25 iteration 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 @@ -121,8 +121,7 @@ local colors = { } -- Change brightness of colors --- darken incase of light theme lighten incase of dark theme - +-- Darken if light theme (or) Lighten if dark theme local normal_color = utils.extract_highlight_colors('Normal', 'bg') if normal_color ~= nil then if get_color_brightness(normal_color) > 0.5 then @@ -133,7 +132,7 @@ if normal_color ~= nil then end end --- basic theme defination +-- Basic theme definition local M = { normal = { a = { bg = colors.normal, fg = colors.back1, gui = 'bold' }, @@ -165,7 +164,7 @@ local M = { M.terminal = M.command M.inactive = M.normal --- Apply prpper contrast so text is readable +-- Apply proper contrast so text is readable for _, section in pairs(M) do for _, highlight in pairs(section) do apply_contrast(highlight) diff --git a/lua/lualine/themes/ayu_dark.lua b/lua/lualine/themes/ayu_dark.lua index a116e97..7dc8f75 100644 --- a/lua/lualine/themes/ayu_dark.lua +++ b/lua/lualine/themes/ayu_dark.lua @@ -1,6 +1,6 @@ -- Copyright (c) 2020-2021 shadmansaleh -- MIT license, see LICENSE for more details. --- Genarated by lightline to lualine theme converter +-- Generated by lightline to lualine theme converter -- https://gist.github.com/shadmansaleh/000871c9a608a012721c6acc6d7a19b9 -- stylua: ignore local colors = { diff --git a/lua/lualine/themes/ayu_light.lua b/lua/lualine/themes/ayu_light.lua index bcb3f0e..0c0d1b6 100644 --- a/lua/lualine/themes/ayu_light.lua +++ b/lua/lualine/themes/ayu_light.lua @@ -1,6 +1,6 @@ -- Copyright (c) 2020-2021 shadmansaleh -- MIT license, see LICENSE for more details. --- Genarated by lightline to lualine theme converter +-- Generated by lightline to lualine theme converter -- https://gist.github.com/shadmansaleh/000871c9a608a012721c6acc6d7a19b9 -- stylua: ignore local colors = { diff --git a/lua/lualine/themes/ayu_mirage.lua b/lua/lualine/themes/ayu_mirage.lua index 8a6b55e..5bc9f38 100644 --- a/lua/lualine/themes/ayu_mirage.lua +++ b/lua/lualine/themes/ayu_mirage.lua @@ -1,6 +1,6 @@ -- Copyright (c) 2020-2021 shadmansaleh -- MIT license, see LICENSE for more details. --- Genarated by lightline to lualine theme converter +-- Generated by lightline to lualine theme converter -- https://gist.github.com/shadmansaleh/000871c9a608a012721c6acc6d7a19b9 -- stylua: ignore local colors = { diff --git a/lua/lualine/themes/iceberg_dark.lua b/lua/lualine/themes/iceberg_dark.lua index e6f3f20..1dd9be9 100644 --- a/lua/lualine/themes/iceberg_dark.lua +++ b/lua/lualine/themes/iceberg_dark.lua @@ -1,6 +1,6 @@ -- Copyright (c) 2020-2021 shadmansaleh -- MIT license, see LICENSE for more details. --- Genarated by lightline to lualine theme converter +-- Generated by lightline to lualine theme converter -- https://gist.github.com/shadmansaleh/000871c9a608a012721c6acc6d7a19b9 -- stylua: ignore local colors = { diff --git a/lua/lualine/themes/iceberg_light.lua b/lua/lualine/themes/iceberg_light.lua index c936b57..3d9ada9 100644 --- a/lua/lualine/themes/iceberg_light.lua +++ b/lua/lualine/themes/iceberg_light.lua @@ -1,6 +1,6 @@ -- Copyright (c) 2020-2021 shadmansaleh -- MIT license, see LICENSE for more details. --- Genarated by lightline to lualine theme converter +-- Generated by lightline to lualine theme converter -- https://gist.github.com/shadmansaleh/000871c9a608a012721c6acc6d7a19b9 -- stylua: ignore local colors = { diff --git a/lua/lualine/themes/jellybeans.lua b/lua/lualine/themes/jellybeans.lua index c6f44ad..d421561 100644 --- a/lua/lualine/themes/jellybeans.lua +++ b/lua/lualine/themes/jellybeans.lua @@ -1,6 +1,6 @@ -- Copyright (c) 2020-2021 shadmansaleh -- MIT license, see LICENSE for more details. --- Genarated by lightline to lualine theme converter +-- Generated by lightline to lualine theme converter -- https://gist.github.com/shadmansaleh/000871c9a608a012721c6acc6d7a19b9 -- stylua: ignore local colors = { diff --git a/lua/lualine/themes/seoul256.lua b/lua/lualine/themes/seoul256.lua index 49463ee..3748e36 100644 --- a/lua/lualine/themes/seoul256.lua +++ b/lua/lualine/themes/seoul256.lua @@ -1,6 +1,6 @@ -- Copyright (c) 2020-2021 shadmansaleh -- MIT license, see LICENSE for more details. --- Genarated by lightline to lualine theme converter +-- Generated by lightline to lualine theme converter -- https://gist.github.com/shadmansaleh/000871c9a608a012721c6acc6d7a19b9 -- stylua: ignore local colors = { diff --git a/lua/lualine/utils/class.lua b/lua/lualine/utils/class.lua index c6c8e6e..3531ad4 100644 --- a/lua/lualine/utils/class.lua +++ b/lua/lualine/utils/class.lua @@ -8,7 +8,7 @@ Object.__index = Object function Object:init(...) end -- luacheck: pop ----Extened base class to create a child class +---Extend base class to create a child class function Object:extend() local cls = {} for k, v in pairs(self) do diff --git a/lua/lualine/utils/color_utils.lua b/lua/lualine/utils/color_utils.lua index b44e407..90b5f65 100644 --- a/lua/lualine/utils/color_utils.lua +++ b/lua/lualine/utils/color_utils.lua @@ -274,7 +274,7 @@ local color_table = { } -- stylua: ignore end ----converts #rrggbb fomated color to cterm ('0'-'255') color +---converts #rrggbb formatted color to cterm ('0'-'255') color ---@param hex_color string ---@return string function M.rgb2cterm(hex_color) @@ -306,7 +306,7 @@ function M.rgb2cterm(hex_color) return closest_cterm_color end ----converts color name (only ones supported by neovim) formated colors to #rrggbb +---converts color name (only ones supported by neovim) formatted colors to #rrggbb ---@param name string like red,green,grey ---@return string function M.color_name2rgb(name) diff --git a/lua/lualine/utils/job.lua b/lua/lualine/utils/job.lua index 95a928f..eadcbfe 100644 --- a/lua/lualine/utils/job.lua +++ b/lua/lualine/utils/job.lua @@ -1,7 +1,7 @@ -- Copyright (c) 2020-2021 shadmansaleh -- MIT license, see LICENSE for more details. ---- wrapper arround job api +--- wrapper around job api --- creates a job handler when called local Job = setmetatable({ --- start the job @@ -9,7 +9,7 @@ local Job = setmetatable({ self.job_id = vim.fn.jobstart(self.args.cmd, self.args) return self.job_id > 0 end, - --- stop the job. also imidiately disables io from the job. + --- stop the job. Also immediately disables io from the job. stop = function(self) if self.killed then return diff --git a/lua/lualine/utils/loader.lua b/lua/lualine/utils/loader.lua index 1805301..6a2893c 100644 --- a/lua/lualine/utils/loader.lua +++ b/lua/lualine/utils/loader.lua @@ -12,7 +12,7 @@ local sep = lualine_require.sep --- function that loads specific type of component local component_types = { - -- loads custion component + -- loads custom component custom = function(component) return component[1](component) end, @@ -42,7 +42,7 @@ local component_types = { end return require('lualine.components.special.function_component')(component) end, - --- loads variables & options (g:,go:,b:,bo:...) as componenta + --- loads variables & options (g:,go:,b:,bo:...) as components var = function(component) return require('lualine.components.special.vim_var_component')(component) end, @@ -52,7 +52,7 @@ local component_types = { end, } ----load a component from component confif +---load a component from component config ---@param component table component + component options ---@return table the loaded & initialized component local function component_loader(component) @@ -110,7 +110,7 @@ Something like: This commonly occurs when you forget to pass table with option for component. When a component has option that component needs to be a table which holds -the component as first element and the options as key value paris. +the component as first element and the options as key value pairs. For example: ```lua lualine_c = { @@ -159,7 +159,7 @@ local function load_components(config) end ---loads all the extensions ----@param config table user confif +---@param config table user config local function load_extensions(config) local loaded_extensions = {} for _, extension in pairs(config.extensions) do @@ -207,9 +207,9 @@ local function load_all(config) end ---loads a theme from lua module ----priotizes external themes (from user config or other plugins) over the bundled ones +---prioritizes external themes (from user config or other plugins) over the bundled ones ---@param theme_name string ----@return table theme defination from module +---@return table theme definition from module local function load_theme(theme_name) assert(is_valid_filename(theme_name), 'Invalid filename') local retval diff --git a/lua/lualine/utils/utils.lua b/lua/lualine/utils/utils.lua index 3ec25bf..ed768d6 100644 --- a/lua/lualine/utils/utils.lua +++ b/lua/lualine/utils/utils.lua @@ -6,8 +6,8 @@ local M = {} -- attr parameter like bold/italic/reverse ---@param color_group string hl_group name ---@param scope string bg | fg ----@return table|string returns #rrggbb formated color when scope is specified ----- or comolete color table when scope isn't specified +---@return table|string returns #rrggbb formatted color when scope is specified +---- or complete color table when scope isn't specified function M.extract_highlight_colors(color_group, scope) local color = require('lualine.highlight').get_lualine_hl(color_group) if not color then @@ -30,7 +30,7 @@ function M.extract_highlight_colors(color_group, scope) return color end ---- retrives color value from highlight group name in syntax_list +--- retrieves color value from highlight group name in syntax_list --- first present highlight is returned ---@param scope string ---@param syntaxlist table @@ -70,24 +70,24 @@ end --- Check if a auto command is already defined ---@param event string ----@param patern string +---@param pattern string ---@param command_str string ---@return boolean whether autocmd 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 +local function autocmd_is_defined(event, pattern, command_str) + return vim.api.nvim_exec(string.format('au lualine %s %s', event, pattern), true):find(command_str) ~= nil end --- Define a auto command if it's not already defined ---@param event string event name ----@param patern string event patern +---@param pattern string event pattern ---@param cmd string command to run on event -function M.define_autocmd(event, patern, cmd) +function M.define_autocmd(event, pattern, cmd) if not cmd then - cmd = patern - patern = '*' + cmd = pattern + pattern = '*' end - if not autocmd_is_defined(event, patern, cmd) then - vim.cmd(string.format('autocmd lualine %s %s %s', event, patern, cmd)) + if not autocmd_is_defined(event, pattern, cmd) then + vim.cmd(string.format('autocmd lualine %s %s %s', event, pattern, cmd)) end end @@ -96,10 +96,10 @@ function M.is_focused() return tonumber(vim.g.actual_curwin) == vim.api.nvim_get_current_win() end ---- Check what's the charecter at pos +--- Check what's the character at pos ---@param str string ---@param pos number ----@return string charecter at position pos in string str +---@return string character at position pos in string str function M.charAt(str, pos) return string.char(str:byte(pos)) end @@ -166,7 +166,7 @@ end --- Wrap a function in retry_call ---@param fn function Function to call. ---@param times number Number of times to retry on error. ----@return function retry call wraped function +---@return function retry call wrapped function function M.retry_call_wrap(fn, times) return function(...) return M.retry_call(fn, { ... }, times) diff --git a/scripts/docgen.sh b/scripts/docgen.sh index 04b1b48..fbc139b 100644 --- a/scripts/docgen.sh +++ b/scripts/docgen.sh @@ -11,7 +11,7 @@ PANVIMDOC_VERSION="NVIM v0.5.0" PANVIMDOC_TOC=true PANDOC_OUTPUT="doc/lualine.txt" -PANVIMDOC_INSTALLED=false # Whther panvimdoc was installed by this script +PANVIMDOC_INSTALLED=false # Whether panvimdoc was installed by this script if [ ! -d "panvimdoc/" ];then # Grab panvimdoc if not present @@ -22,7 +22,7 @@ if [ ! -d "panvimdoc/" ];then "https://github.com/kdheepak/panvimdoc" "panvimdoc" fi -echo "Genarating docs" +echo "Generating docs" pandoc --metadata=project:"${PANVIMDOC_VIMDOC}"\ --metadata=toc:${PANVIMDOC_TOC}\ --metadata=vimversion:"${PANVIMDOC_VERSION}"\ diff --git a/scripts/nvim_isolated_conf.sh b/scripts/nvim_isolated_conf.sh index c9c42c0..762bfd8 100644 --- a/scripts/nvim_isolated_conf.sh +++ b/scripts/nvim_isolated_conf.sh @@ -7,7 +7,7 @@ USAGE="Usage nvim_isolated_conf.sh [OPTIONS] Directory A tool to easily test isolated neovim config Options: - -c Create a mimimal config tree at Directory + -c Create a minimal config tree at Directory -e Edit init.vim of config in Directory -h Show this message -l Load neovim with config from Directory diff --git a/tests/helpers.lua b/tests/helpers.lua index 0ee1ae7..f76a3e4 100644 --- a/tests/helpers.lua +++ b/tests/helpers.lua @@ -28,7 +28,7 @@ function M.init_component(component, opts) return comp end --- Checks ouput of a component +-- Checks output of a component M.assert_component = function(component, opts, result, is_active) local comp = M.init_component(component, opts) -- for testing global options diff --git a/tests/spec/utils_spec.lua b/tests/spec/utils_spec.lua index bcb2fce..59af60c 100644 --- a/tests/spec/utils_spec.lua +++ b/tests/spec/utils_spec.lua @@ -16,9 +16,9 @@ describe('Utils', function() 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)) - -- Can retrive entire highlight table + -- Can retrieve entire highlight table eq(utils.extract_highlight_colors('hl2'), hl2) - -- Can retrive specific parts of highlight + -- Can retrieve specific parts of highlight eq(utils.extract_highlight_colors('hl2', 'fg'), hl2.fg) -- clear hl2 vim.cmd('hi clear hl2')