From 442d2ab757b4de6bc492186ff76ffed9746d772b Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 4 May 2023 22:59:39 +0800 Subject: [PATCH 01/47] feat!: switch to Nerd Fonts v3.0.0 for diagnostic symbols (#1033) Ref https://github.com/ryanoasis/nerd-fonts/issues/1059#issuecomment-1404891287 --- lua/lualine/components/diagnostics/config.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lua/lualine/components/diagnostics/config.lua b/lua/lualine/components/diagnostics/config.lua index bfe3544de..ce48544cc 100644 --- a/lua/lualine/components/diagnostics/config.lua +++ b/lua/lualine/components/diagnostics/config.lua @@ -5,10 +5,10 @@ local M = {} -- default symbols for diagnostics component M.symbols = { icons = { - error = ' ', -- xf659 - warn = ' ', -- xf529 - info = ' ', -- xf7fc - hint = ' ', -- xf835 + error = '󰅚 ', -- x000f015a + warn = '󰀪 ', -- x000f002a + info = '󰋽 ', -- x000f02fd + hint = '󰌶 ', -- x000f0336 }, no_icons = { error = 'E:', warn = 'W:', info = 'I:', hint = 'H:' }, } From 8912bea65de93a56b1f70cdb7c3c26f9cce30394 Mon Sep 17 00:00:00 2001 From: Eugene Oliveros Date: Thu, 4 May 2023 23:08:04 +0800 Subject: [PATCH 02/47] fix: replace deprecated nerdfont icons (#1035) Co-authored-by: Shadman <13149513+shadmansaleh@users.noreply.github.com> --- examples/evil_lualine.lua | 2 +- tests/spec/lualine_spec.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/evil_lualine.lua b/examples/evil_lualine.lua index 251552028..138692036 100644 --- a/examples/evil_lualine.lua +++ b/examples/evil_lualine.lua @@ -200,7 +200,7 @@ ins_right { ins_right { 'diff', -- Is it me or the symbol for modified us really weird - symbols = { added = ' ', modified = '柳 ', removed = ' ' }, + symbols = { added = ' ', modified = '󰝤 ', removed = ' ' }, diff_color = { added = { fg = colors.green }, modified = { fg = colors.orange }, diff --git a/tests/spec/lualine_spec.lua b/tests/spec/lualine_spec.lua index 47854ead8..eb46a3ce1 100644 --- a/tests/spec/lualine_spec.lua +++ b/tests/spec/lualine_spec.lua @@ -732,7 +732,7 @@ describe('Lualine', function() 3: lualine_a_buffers_inactive = { bg = "#3c3836", bold = true, fg = "#a89984" } 4: lualine_c_normal = { bg = "#3c3836", fg = "#a89984" } } - |{1:  a.txt } + |{1: 󰈙 a.txt } {2:} {3: ... } {4: }| From e41d48ebcc1e39e7e57854d29544ea85ac784a9b Mon Sep 17 00:00:00 2001 From: shadmansaleh <13149513+shadmansaleh@users.noreply.github.com> Date: Thu, 4 May 2023 21:14:31 +0600 Subject: [PATCH 03/47] chore: use nvim-tree/nvim-web-devicons in ci --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9914c3716..be219e263 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,7 +47,7 @@ jobs: run: | mkdir -p ./tmp_home/nvim/pack/vendor/start git clone --depth 1 https://github.com/nvim-lua/plenary.nvim ./tmp_home/nvim/pack/vendor/start/plenary.nvim - git clone --depth 1 https://github.com/kyazdani42/nvim-web-devicons ./tmp_home/nvim/pack/vendor/start/nvim-web-devicons + git clone --depth 1 https://github.com/nvim-tree/nvim-web-devicons ./tmp_home/nvim/pack/vendor/start/nvim-web-devicons ln -s $(pwd) ./tmp_home/nvim/pack/vendor/start - name: Setup neovim ${{matrix.nvim_version}} uses: rhysd/action-setup-vim@v1 From 05d78e9fd0cdfb4545974a5aa14b1be95a86e9c9 Mon Sep 17 00:00:00 2001 From: shadmansaleh <13149513+shadmansaleh@users.noreply.github.com> Date: Thu, 4 May 2023 21:17:02 +0600 Subject: [PATCH 04/47] fixup: fix tests --- tests/spec/lualine_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/spec/lualine_spec.lua b/tests/spec/lualine_spec.lua index eb46a3ce1..47854ead8 100644 --- a/tests/spec/lualine_spec.lua +++ b/tests/spec/lualine_spec.lua @@ -732,7 +732,7 @@ describe('Lualine', function() 3: lualine_a_buffers_inactive = { bg = "#3c3836", bold = true, fg = "#a89984" } 4: lualine_c_normal = { bg = "#3c3836", fg = "#a89984" } } - |{1: 󰈙 a.txt } + |{1:  a.txt } {2:} {3: ... } {4: }| From afece9bbf960f908cbaffebaa4b5a0506e9dc8ed Mon Sep 17 00:00:00 2001 From: Ofir Gal Date: Thu, 3 Aug 2023 10:01:10 +0300 Subject: [PATCH 05/47] Added hlgroup for `diff` of lualine (#846) * added higlightgroups for lualine to allow colorscheme to set colors for lualine * chore: update docs for default diff color change --------- Co-authored-by: Shadman <13149513+shadmansaleh@users.noreply.github.com> --- README.md | 6 +++--- lua/lualine/components/diff/init.lua | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 6d988d5ac..39f792d30 100644 --- a/README.md +++ b/README.md @@ -582,9 +582,9 @@ sections = { colored = true, -- Displays a colored diff status if set to true diff_color = { -- Same color values as the general color option can be used here. - added = 'DiffAdd', -- Changes the diff's added color - modified = 'DiffChange', -- Changes the diff's modified color - removed = 'DiffDelete', -- Changes the diff's removed color you + added = 'LuaLineDiffAdd', -- Changes the diff's added color + modified = 'LuaLineDiffChange', -- Changes the diff's modified color + removed = 'LuaLineDiffDelete', -- Changes the diff's removed color you }, symbols = {added = '+', modified = '~', removed = '-'}, -- Changes the symbols used by the diff. source = nil, -- A function that works as a data source for diff. diff --git a/lua/lualine/components/diff/init.lua b/lua/lualine/components/diff/init.lua index 976bd5474..9201b2bba 100644 --- a/lua/lualine/components/diff/init.lua +++ b/lua/lualine/components/diff/init.lua @@ -19,21 +19,21 @@ local function apply_default_colors(opts) added = { fg = modules.utils.extract_color_from_hllist( 'fg', - { 'GitSignsAdd', 'GitGutterAdd', 'DiffAdded', 'DiffAdd' }, + { 'LuaLineDiffAdd', 'GitSignsAdd', 'GitGutterAdd', 'DiffAdded', 'DiffAdd' }, '#90ee90' ), }, modified = { fg = modules.utils.extract_color_from_hllist( 'fg', - { 'GitSignsChange', 'GitGutterChange', 'DiffChanged', 'DiffChange' }, + { 'LuaLineDiffChange', 'GitSignsChange', 'GitGutterChange', 'DiffChanged', 'DiffChange' }, '#f0e130' ), }, removed = { fg = modules.utils.extract_color_from_hllist( 'fg', - { 'GitSignsDelete', 'GitGutterDelete', 'DiffRemoved', 'DiffDelete' }, + { 'LuaLineDiffDelete', 'GitSignsDelete', 'GitGutterDelete', 'DiffRemoved', 'DiffDelete' }, '#ff0038' ), }, From 146f40d83c6d1f6e1b84d503b92ea0055dfa7f3e Mon Sep 17 00:00:00 2001 From: shadmansaleh Date: Thu, 3 Aug 2023 07:01:45 +0000 Subject: [PATCH 06/47] chore: autogen (vimdocs+formating) --- doc/lualine.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/lualine.txt b/doc/lualine.txt index 495275496..c2077bd67 100644 --- a/doc/lualine.txt +++ b/doc/lualine.txt @@ -606,9 +606,9 @@ Component specific options These are options that are available on colored = true, -- Displays a colored diff status if set to true diff_color = { -- Same color values as the general color option can be used here. - added = 'DiffAdd', -- Changes the diff's added color - modified = 'DiffChange', -- Changes the diff's modified color - removed = 'DiffDelete', -- Changes the diff's removed color you + added = 'LuaLineDiffAdd', -- Changes the diff's added color + modified = 'LuaLineDiffChange', -- Changes the diff's modified color + removed = 'LuaLineDiffDelete', -- Changes the diff's removed color you }, symbols = {added = '+', modified = '~', removed = '-'}, -- Changes the symbols used by the diff. source = nil, -- A function that works as a data source for diff. From 45e27ca739c7be6c49e5496d14fcf45a303c3a63 Mon Sep 17 00:00:00 2001 From: shadmansaleh <13149513+shadmansaleh@users.noreply.github.com> Date: Thu, 3 Aug 2023 13:02:44 +0600 Subject: [PATCH 07/47] chore: fix tests failing due to icon change --- tests/spec/lualine_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/spec/lualine_spec.lua b/tests/spec/lualine_spec.lua index 47854ead8..eb46a3ce1 100644 --- a/tests/spec/lualine_spec.lua +++ b/tests/spec/lualine_spec.lua @@ -732,7 +732,7 @@ describe('Lualine', function() 3: lualine_a_buffers_inactive = { bg = "#3c3836", bold = true, fg = "#a89984" } 4: lualine_c_normal = { bg = "#3c3836", fg = "#a89984" } } - |{1:  a.txt } + |{1: 󰈙 a.txt } {2:} {3: ... } {4: }| From 5d85dc785869e63191db6e5c995d59002105b2d0 Mon Sep 17 00:00:00 2001 From: Anthony Ruhier Date: Tue, 17 Oct 2023 11:37:24 +0200 Subject: [PATCH 08/47] Add options to the Tabs module to align it with the Buffers module (#920) * Add a path option for tabs Add get_props to align the module on Buffers. * Add option to set the tab max size Shorten dynamically the tab name to minimize its length when needed. * Show modified status --- README.md | 11 ++++ lua/lualine/components/tabs/init.lua | 6 ++ lua/lualine/components/tabs/tab.lua | 92 +++++++++++++++++++++++----- 3 files changed, 92 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 39f792d30..8fb021fa0 100644 --- a/README.md +++ b/README.md @@ -679,6 +679,7 @@ sections = { lualine_a = { { 'tabs', + tab_max_length = 40, -- Maximum width of each tab. The content will be shorten dynamically (example: apple/orange -> a/orange) max_length = vim.o.columns / 3, -- Maximum width of tabs component. -- Note: -- It can also be a function that returns @@ -687,6 +688,11 @@ sections = { -- 1: Shows tab_name -- 2: Shows tab_nr + tab_name + path = 0, -- 0: just shows the filename + -- 1: shows the relative path and shorten $HOME to ~ + -- 2: shows the full path + -- 3: shows the full path and shorten $HOME to ~ + -- Automatically updates active tab color to match color of other components (will be overidden if buffers_color is set) use_mode_colors = false, @@ -696,6 +702,11 @@ sections = { inactive = 'lualine_{section}_inactive', -- Color for inactive tab. }, + show_modified_status = true, -- Shows a symbol next to the tab name if the file has been modified. + symbols = { + modified = '[+]', -- Text to show when the file is modified. + }, + fmt = function(name, context) -- Show + if buffer is modified in tab local buflist = vim.fn.tabpagebuflist(context.tabnr) diff --git a/lua/lualine/components/tabs/init.lua b/lua/lualine/components/tabs/init.lua index b176b450a..5d1966e6d 100644 --- a/lua/lualine/components/tabs/init.lua +++ b/lua/lualine/components/tabs/init.lua @@ -7,12 +7,18 @@ local highlight = require('lualine.highlight') local default_options = { max_length = 0, + tab_max_length = 40, mode = 0, use_mode_colors = false, + path = 0, tabs_color = { active = nil, inactive = nil, }, + show_modified_status = true, + symbols = { + modified = '[+]', + }, } -- This function is duplicated in buffers diff --git a/lua/lualine/components/tabs/tab.lua b/lua/lualine/components/tabs/tab.lua index 8ccdc90c0..170095a6e 100644 --- a/lua/lualine/components/tabs/tab.lua +++ b/lua/lualine/components/tabs/tab.lua @@ -13,6 +13,27 @@ function Tab:init(opts) self.tabId = opts.tabId self.options = opts.options self.highlights = opts.highlights + self.modified_icon = '' + self:get_props() +end + +function Tab:get_props() + local buflist = vim.fn.tabpagebuflist(self.tabnr) + local winnr = vim.fn.tabpagewinnr(self.tabnr) + local bufnr = buflist[winnr] + self.file = modules.utils.stl_escape(vim.api.nvim_buf_get_name(bufnr)) + self.filetype = vim.api.nvim_buf_get_option(bufnr, 'filetype') + self.buftype = vim.api.nvim_buf_get_option(bufnr, 'buftype') + + if self.options.show_modified_status then + for _, b in ipairs(buflist) do + if vim.api.nvim_buf_get_option(b, 'modified') then + self.modified_icon = self.options.symbols.modified or '' + break + end + end + end + end ---returns name for tab. Tabs name is the name of buffer in last active window @@ -26,30 +47,61 @@ function Tab:label() if custom_tabname and custom_tabname ~= '' then return modules.utils.stl_escape(custom_tabname) end - local buflist = vim.fn.tabpagebuflist(self.tabnr) - local winnr = vim.fn.tabpagewinnr(self.tabnr) - local bufnr = buflist[winnr] - local file = modules.utils.stl_escape(vim.api.nvim_buf_get_name(bufnr)) - local buftype = vim.fn.getbufvar(bufnr, '&buftype') - if vim.api.nvim_buf_get_option(bufnr, 'filetype') == 'fugitive' then - return 'fugitive: ' .. vim.fn.fnamemodify(file, ':h:h:t') - elseif buftype == 'help' then - return 'help:' .. vim.fn.fnamemodify(file, ':t:r') - elseif buftype == 'terminal' then - local match = string.match(vim.split(file, ' ')[1], 'term:.*:(%a+)') + if self.filetype == 'fugitive' then + return 'fugitive: ' .. vim.fn.fnamemodify(self.file, ':h:h:t') + elseif self.buftype == 'help' then + return 'help:' .. vim.fn.fnamemodify(self.file, ':t:r') + elseif self.buftype == 'terminal' then + local match = string.match(vim.split(self.file, ' ')[1], 'term:.*:(%a+)') return match ~= nil and match or vim.fn.fnamemodify(vim.env.SHELL, ':t') - elseif vim.fn.isdirectory(file) == 1 then - return vim.fn.fnamemodify(file, ':p:.') - elseif file == '' then + elseif self.file == '' then return '[No Name]' end - return vim.fn.fnamemodify(file, ':t') + if self.options.path == 1 then + return vim.fn.fnamemodify(self.file, ':~:.') + elseif self.options.path == 2 then + return vim.fn.fnamemodify(self.file, ':p') + elseif self.options.path == 3 then + return vim.fn.fnamemodify(self.file, ':p:~') + else + return vim.fn.fnamemodify(self.file, ':t') + end +end + +---shortens path by turning apple/orange -> a/orange +---@param path string +---@param sep string path separator +---@param max_len integer maximum length of the full filename string +---@return string +local function shorten_path(path, sep, max_len) + local len = #path + if len <= max_len then + return path + end + + local segments = vim.split(path, sep) + for idx = 1, #segments - 1 do + if len <= max_len then + break + end + + local segment = segments[idx] + local shortened = segment:sub(1, vim.startswith(segment, '.') and 2 or 1) + segments[idx] = shortened + len = len - (#segment - #shortened) + end + + return table.concat(segments, sep) end ---returns rendered tab ---@return string function Tab:render() local name = self:label() + if self.options.tab_max_length ~= 0 then + local path_separator = package.config:sub(1, 1) + name = shorten_path(name, path_separator, self.options.tab_max_length) + end if self.options.fmt then name = self.options.fmt(name or '', self) end @@ -59,12 +111,18 @@ function Tab:render() -- different formats for different modes if self.options.mode == 0 then name = tostring(self.tabnr) + if self.modified_icon ~= '' then + name = string.format('%s%s', name, self.modified_icon) + end elseif self.options.mode == 1 then - name = name + if self.modified_icon ~= '' then + name = string.format('%s %s', self.modified_icon, name) + end else - name = string.format('%s %s', tostring(self.tabnr), name) + name = string.format('%s%s %s', tostring(self.tabnr), self.modified_icon, name) end end + name = Tab.apply_padding(name, self.options.padding) self.len = vim.fn.strchars(name) From e7efd7dd3a1cde676fbbc4ad4f20c64a9ee3077a Mon Sep 17 00:00:00 2001 From: shadmansaleh Date: Tue, 17 Oct 2023 09:37:53 +0000 Subject: [PATCH 09/47] chore: autogen (vimdocs+formating) --- doc/lualine.txt | 11 +++++++++++ lua/lualine/components/tabs/tab.lua | 1 - 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/doc/lualine.txt b/doc/lualine.txt index c2077bd67..6e8a0e2ab 100644 --- a/doc/lualine.txt +++ b/doc/lualine.txt @@ -708,6 +708,7 @@ Component specific options These are options that are available on lualine_a = { { 'tabs', + tab_max_length = 40, -- Maximum width of each tab. The content will be shorten dynamically (example: apple/orange -> a/orange) max_length = vim.o.columns / 3, -- Maximum width of tabs component. -- Note: -- It can also be a function that returns @@ -716,6 +717,11 @@ Component specific options These are options that are available on -- 1: Shows tab_name -- 2: Shows tab_nr + tab_name + path = 0, -- 0: just shows the filename + -- 1: shows the relative path and shorten $HOME to ~ + -- 2: shows the full path + -- 3: shows the full path and shorten $HOME to ~ + -- Automatically updates active tab color to match color of other components (will be overidden if buffers_color is set) use_mode_colors = false, @@ -725,6 +731,11 @@ Component specific options These are options that are available on inactive = 'lualine_{section}_inactive', -- Color for inactive tab. }, + show_modified_status = true, -- Shows a symbol next to the tab name if the file has been modified. + symbols = { + modified = '[+]', -- Text to show when the file is modified. + }, + fmt = function(name, context) -- Show + if buffer is modified in tab local buflist = vim.fn.tabpagebuflist(context.tabnr) diff --git a/lua/lualine/components/tabs/tab.lua b/lua/lualine/components/tabs/tab.lua index 170095a6e..56c4788a0 100644 --- a/lua/lualine/components/tabs/tab.lua +++ b/lua/lualine/components/tabs/tab.lua @@ -33,7 +33,6 @@ function Tab:get_props() end end end - end ---returns name for tab. Tabs name is the name of buffer in last active window From 388a3964119cf805220ac1f995aacbd0d4ce08d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9A=AE=E6=99=A8?= Date: Tue, 17 Oct 2023 17:51:54 +0800 Subject: [PATCH 10/47] Added extension for mason (#1113) * feat: added extension for mason * feat: update readme * feat: capitalize the first letter * feat: delete icon --------- Co-authored-by: Shadman <13149513+shadmansaleh@users.noreply.github.com> --- README.md | 1 + lua/lualine/extensions/mason.lua | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 lua/lualine/extensions/mason.lua diff --git a/README.md b/README.md index 8fb021fa0..577f18018 100644 --- a/README.md +++ b/README.md @@ -912,6 +912,7 @@ extensions = {'quickfix'} - symbols-outline - toggleterm - trouble +- mason #### Custom extensions diff --git a/lua/lualine/extensions/mason.lua b/lua/lualine/extensions/mason.lua new file mode 100644 index 000000000..16ed56b40 --- /dev/null +++ b/lua/lualine/extensions/mason.lua @@ -0,0 +1,25 @@ +-- lualine extension for mason.nvim + +local ok, mason_registry = pcall(require, 'mason-registry') +if not ok then + return '' +end + +local M = {} + +M.sections = { + lualine_a = { + function() + return 'Mason' + end, + }, + lualine_b = { + function() + return 'Installed: ' .. #mason_registry.get_installed_packages() .. '/' .. #mason_registry.get_all_package_specs() + end, + }, +} + +M.filetypes = { 'mason' } + +return M From 1a3f6bba410aff5a51bf8c84287aaa3a8ba30d0d Mon Sep 17 00:00:00 2001 From: shadmansaleh Date: Tue, 17 Oct 2023 09:52:19 +0000 Subject: [PATCH 11/47] chore: autogen (vimdocs+formating) --- doc/lualine.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/lualine.txt b/doc/lualine.txt index 6e8a0e2ab..9946c98f2 100644 --- a/doc/lualine.txt +++ b/doc/lualine.txt @@ -966,6 +966,7 @@ extensions with: - symbols-outline - toggleterm - trouble +- mason *lualine-Custom-extensions* From c55af3b39cc50109aa75d445e38f2089b023e5df Mon Sep 17 00:00:00 2001 From: Pedro Pombeiro Date: Wed, 18 Oct 2023 06:49:27 +0200 Subject: [PATCH 12/47] enhance: Update git_branch.lua to use GIT_DIR environment variable (#1114) Fix typo Remove whitespace Try GIT_DIR first --- lua/lualine/components/branch/git_branch.lua | 22 +++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/lua/lualine/components/branch/git_branch.lua b/lua/lualine/components/branch/git_branch.lua index c9f36e9a5..48625f558 100644 --- a/lua/lualine/components/branch/git_branch.lua +++ b/lua/lualine/components/branch/git_branch.lua @@ -56,14 +56,27 @@ local function update_branch() branch_cache[vim.api.nvim_get_current_buf()] = current_git_branch end +---updates the current value of current_git_branch and sets up file watch on HEAD file if value changed +local function update_current_git_dir(git_dir) + if current_git_dir ~= git_dir then + current_git_dir = git_dir + update_branch() + end +end + ---returns full path to git directory for dir_path or current directory ---@param dir_path string|nil ----@return string +---@return string|nil function M.find_git_dir(dir_path) + local git_dir = vim.env.GIT_DIR + if git_dir then + update_current_git_dir(git_dir) + return git_dir + end + -- get file dir so we can search from that dir local file_dir = dir_path or vim.fn.expand('%:p:h') local root_dir = file_dir - local git_dir -- Search upward for .git file or folder while root_dir do if git_dir_cache[root_dir] then @@ -101,9 +114,8 @@ function M.find_git_dir(dir_path) end git_dir_cache[file_dir] = git_dir - if dir_path == nil and current_git_dir ~= git_dir then - current_git_dir = git_dir - update_branch() + if dir_path == nil then + update_current_git_dir(git_dir) end return git_dir end From 343e1941ba5ae3167984ade00dad5ba4792f9dd3 Mon Sep 17 00:00:00 2001 From: Shadman <13149513+shadmansaleh@users.noreply.github.com> Date: Wed, 18 Oct 2023 11:00:32 +0600 Subject: [PATCH 13/47] drop support for nvim-0.5, 0.6 (BREAKING) (#1002) * chore: drop support for nvim-0.5, 0.6 (BREAKING) Users of these versions can still use compatibility tags compat-nvim-0.5 and compat-nvim-0.6 respectively. BREAKING CHANGE * add testing for 0.9 --- .github/workflows/ci.yml | 12 +-- README.md | 5 +- lua/lualine.lua | 37 ++++--- lua/lualine/components/diagnostics/config.lua | 2 +- .../components/diagnostics/sources.lua | 29 ++--- lua/lualine/config.lua | 6 -- tests/statusline.lua | 100 +----------------- 7 files changed, 47 insertions(+), 144 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index be219e263..2b9d52ece 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,14 +19,6 @@ jobs: fail-fast: false matrix: include: - - flavor: nvim-0.5 - runner: ubuntu-20.04 - os: linux - nvim_version: v0.5.0 - - flavor: nvim-0.6 - runner: ubuntu-20.04 - os: linux - nvim_version: v0.6.0 - flavor: nvim-0.7 runner: ubuntu-20.04 os: linux @@ -35,6 +27,10 @@ jobs: runner: ubuntu-20.04 os: linux nvim_version: v0.8.0 + - flavor: nvim-0.9 + runner: ubuntu-20.04 + os: linux + nvim_version: v0.9.0 - flavor: nvim-nightly runner: ubuntu-20.04 os: linux diff --git a/README.md b/README.md index 577f18018..fdcb653c1 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,10 @@ A blazing fast and easy to configure Neovim statusline written in Lua. -`lualine.nvim` requires Neovim >= 0.5. +`lualine.nvim` requires Neovim >= 0.7. + +For previous versoins of neovim please use compatability tags for example +compat-nvim-0.5 ## Contributing diff --git a/lua/lualine.lua b/lua/lualine.lua index 49e38a124..d996c48fb 100644 --- a/lua/lualine.lua +++ b/lua/lualine.lua @@ -27,10 +27,7 @@ local refresh_real_curwin -- The events on which lualine redraws itself local default_refresh_events = - 'WinEnter,BufEnter,SessionLoadPost,FileChangedShellPost,VimResized,Filetype,CursorMoved,CursorMovedI' -if vim.fn.has('nvim-0.7') == 1 then -- utilize ModeChanged event introduced in 0.7 - default_refresh_events = default_refresh_events .. ',ModeChanged' -end + 'WinEnter,BufEnter,SessionLoadPost,FileChangedShellPost,VimResized,Filetype,CursorMoved,CursorMovedI,ModeChanged' -- Helper for apply_transitional_separators() --- finds first applied highlight group after str_checked in status ---@param status string : unprocessed statusline string @@ -602,6 +599,20 @@ local function hide(opts) end end +--- Check neovim compatibilitu +local function verify_nvim_version() + if vim.fn.has('nvim-0.7') == 1 then return true end + modules.utils_notices.add_notice([[ +### Incompatible Neovim version +Lualine supports neovim 0.7 and up. It seems you're using a older version. +Please update to newer version. Or if you have atleast neovim 0.5 you +can use older compatible versions of lualine using compat tags like +`compat-nvim-0.5`, `compat-nvim-0.6`. +]] +) + return false +end + -- lualine.setup function --- sets new user config --- This function doesn't load components/theme etc... They are done before @@ -616,14 +627,16 @@ local function setup(user_config) -- When notices module is not loaded there are no notices to clear. modules.utils_notices.clear_notices() end - config = modules.config_module.apply_configuration(user_config) - vim.cmd([[augroup lualine | exe "autocmd!" | augroup END]]) - setup_theme() - -- load components & extensions - modules.loader.load_all(config) - set_statusline() - set_tabline() - set_winbar() + if verify_nvim_version() then + config = modules.config_module.apply_configuration(user_config) + vim.cmd([[augroup lualine | exe "autocmd!" | augroup END]]) + setup_theme() + -- load components & extensions + modules.loader.load_all(config) + set_statusline() + set_tabline() + set_winbar() + end if package.loaded['lualine.utils.notices'] then modules.utils_notices.notice_message_startup() end diff --git a/lua/lualine/components/diagnostics/config.lua b/lua/lualine/components/diagnostics/config.lua index ce48544cc..b50631207 100644 --- a/lua/lualine/components/diagnostics/config.lua +++ b/lua/lualine/components/diagnostics/config.lua @@ -18,7 +18,7 @@ M.options = { colored = true, update_in_insert = false, always_visible = false, - sources = { vim.fn.has('nvim-0.6') == 1 and 'nvim_diagnostic' or 'nvim_lsp', 'coc' }, + sources = { 'nvim_diagnostic', 'coc' }, sections = { 'error', 'warn', 'info', 'hint' }, } diff --git a/lua/lualine/components/diagnostics/sources.lua b/lua/lualine/components/diagnostics/sources.lua index 3432b9ea3..c0ef78c7d 100644 --- a/lua/lualine/components/diagnostics/sources.lua +++ b/lua/lualine/components/diagnostics/sources.lua @@ -6,28 +6,17 @@ local M = {} M.sources = { nvim_lsp = function() local error_count, warning_count, info_count, hint_count - if vim.fn.has('nvim-0.6') == 1 then - -- On nvim 0.6+ use vim.diagnostic to get lsp generated diagnostic count. - local diagnostics = vim.diagnostic.get(0) - local count = { 0, 0, 0, 0 } - for _, diagnostic in ipairs(diagnostics) do - if vim.startswith(vim.diagnostic.get_namespace(diagnostic.namespace).name, 'vim.lsp') then - count[diagnostic.severity] = count[diagnostic.severity] + 1 - end + local diagnostics = vim.diagnostic.get(0) + local count = { 0, 0, 0, 0 } + for _, diagnostic in ipairs(diagnostics) do + if vim.startswith(vim.diagnostic.get_namespace(diagnostic.namespace).name, 'vim.lsp') then + count[diagnostic.severity] = count[diagnostic.severity] + 1 end - error_count = count[vim.diagnostic.severity.ERROR] - warning_count = count[vim.diagnostic.severity.WARN] - info_count = count[vim.diagnostic.severity.INFO] - hint_count = count[vim.diagnostic.severity.HINT] - else - -- On 0.5 use older vim.lsp.diagnostic module. - -- Maybe we should phase out support for 0.5 though I haven't yet found a solid reason to. - -- Eventually this will be removed when 0.5 is no longer supported. - error_count = vim.lsp.diagnostic.get_count(0, 'Error') - warning_count = vim.lsp.diagnostic.get_count(0, 'Warning') - info_count = vim.lsp.diagnostic.get_count(0, 'Information') - hint_count = vim.lsp.diagnostic.get_count(0, 'Hint') end + error_count = count[vim.diagnostic.severity.ERROR] + warning_count = count[vim.diagnostic.severity.WARN] + info_count = count[vim.diagnostic.severity.INFO] + hint_count = count[vim.diagnostic.severity.HINT] return error_count, warning_count, info_count, hint_count end, nvim_workspace_diagnostic = function() diff --git a/lua/lualine/config.lua b/lua/lualine/config.lua index 5ee6e042b..cc92099d9 100644 --- a/lua/lualine/config.lua +++ b/lua/lualine/config.lua @@ -103,12 +103,6 @@ local function apply_configuration(config_table) end end end - if config_table.options and config_table.options.globalstatus and vim.fn.has('nvim-0.7') == 0 then - modules.utils_notices.add_notice( - '### Options.globalstatus\nSorry `globalstatus` option can only be used in neovim 0.7 or higher.\n' - ) - config_table.options.globalstatus = false - end if vim.fn.has('nvim-0.8') == 0 and (next(config_table.winbar or {}) or next(config_table.inactive_winbar or {})) then modules.utils_notices.add_notice('### winbar\nSorry `winbar can only be used in neovim 0.8 or higher.\n') config_table.winbar = {} diff --git a/tests/statusline.lua b/tests/statusline.lua index 96d1ee460..00e185599 100644 --- a/tests/statusline.lua +++ b/tests/statusline.lua @@ -71,109 +71,17 @@ --- statusline:snapshot() --- ``` -local ffi = require('ffi') local helpers = require('tests.helpers') local stub = require('luassert.stub') local M = {} -ffi.cdef([[ -typedef unsigned char char_u; -typedef struct window_S win_T; -extern win_T *curwin; -typedef struct { - char_u *start; - int userhl; -} stl_hlrec_t; -typedef struct { -} StlClickDefinition; -typedef struct { - StlClickDefinition def; - const char *start; -} StlClickRecord; -int build_stl_str_hl( - win_T *wp, - char_u *out, - size_t outlen, - char_u *fmt, - int use_sandbox, - char_u fillchar, - int maxwidth, - stl_hlrec_t **hltab, - StlClickRecord **tabtab -); -]]) - -local function process_hlrec(hltab, stlbuf, eval_type) - local function default_hl() - if eval_type == 'tabline' then - return 'TabLineFill' - elseif eval_type == 'inactive' then - return 'StatusLineNC' - else - return 'StatusLine' - end - end - local len = #ffi.string(stlbuf) - local hltab_data = hltab[0] - local result = {} - if hltab_data[0].start ~= stlbuf then - table.insert(result, { - group = default_hl(), - start = 0, - }) - end - - local n = 0 - while hltab_data[n].start ~= nil do - local group_name - if hltab_data[n].userhl == 0 then - group_name = default_hl() - elseif hltab_data[n].userhl < 0 then - group_name = vim.fn.synIDattr(-1 * hltab_data[n].userhl, 'name') - else - group_name = string.format('User%d', hltab_data[n].userhl) - end - - local hl_pos = { group = group_name } - - if n == 0 then - hl_pos.start = hltab_data[n].start - stlbuf - else - hl_pos.start = result[#result].start + result[#result].len - end - if hltab_data[n + 1].start ~= nil then - hl_pos.len = hltab_data[n + 1].start - hltab_data[n].start - else - hl_pos.len = (stlbuf + len) - hltab_data[n].start - end - table.insert(result, hl_pos) - n = n + 1 - end - return vim.tbl_filter(function(x) - return x.len ~= 0 - end, result) -end - -local function gen_stl(stl_fmt, width, eval_type) - local stlbuf = ffi.new('char_u [?]', width + 100) - local fmt = ffi.cast('char_u *', stl_fmt) - local fillchar = ffi.cast('char_u', 0x20) - local hltab = ffi.new('stl_hlrec_t *[1]', ffi.new('stl_hlrec_t *')) - ffi.C.build_stl_str_hl(ffi.C.curwin, stlbuf, width + 100, fmt, 0, fillchar, width, hltab, nil) - return { str = ffi.string(stlbuf), highlights = process_hlrec(hltab, stlbuf, eval_type) } -end - local function eval_stl(stl_expr, width, eval_type) local stl_buf, hl_list, stl_eval_res - if vim.fn.has('nvim-0.6') == 1 then - stl_eval_res = vim.api.nvim_eval_statusline( - stl_expr, - { maxwidth = width, highlights = true, fillchar = ' ', use_tabline = (eval_type == 'tabline') } - ) - else - stl_eval_res = gen_stl(stl_expr, width, eval_type) - end + stl_eval_res = vim.api.nvim_eval_statusline( + stl_expr, + { maxwidth = width, highlights = true, fillchar = ' ', use_tabline = (eval_type == 'tabline') } + ) stl_buf, hl_list = stl_eval_res.str, stl_eval_res.highlights local hl_map = {} From 2e2284db88f6e282b96c9c65e66897093ab4f705 Mon Sep 17 00:00:00 2001 From: shadmansaleh Date: Wed, 18 Oct 2023 05:00:59 +0000 Subject: [PATCH 14/47] chore: autogen (vimdocs+formating) --- doc/lualine.txt | 5 ++++- lua/lualine.lua | 7 ++++--- lua/lualine/components/diagnostics/config.lua | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/doc/lualine.txt b/doc/lualine.txt index 9946c98f2..9fdfcd87a 100644 --- a/doc/lualine.txt +++ b/doc/lualine.txt @@ -14,7 +14,10 @@ Table of Contents *lualine-table-of-contents* A blazing fast and easy to configure Neovim statusline written in Lua. -`lualine.nvim` requires Neovim >= 0.5. +`lualine.nvim` requires Neovim >= 0.7. + +For previous versoins of neovim please use compatability tags for example +compat-nvim-0.5 CONTRIBUTING *lualine-contributing* diff --git a/lua/lualine.lua b/lua/lualine.lua index d996c48fb..fa89a3e7f 100644 --- a/lua/lualine.lua +++ b/lua/lualine.lua @@ -601,15 +601,16 @@ end --- Check neovim compatibilitu local function verify_nvim_version() - if vim.fn.has('nvim-0.7') == 1 then return true end + if vim.fn.has('nvim-0.7') == 1 then + return true + end modules.utils_notices.add_notice([[ ### Incompatible Neovim version Lualine supports neovim 0.7 and up. It seems you're using a older version. Please update to newer version. Or if you have atleast neovim 0.5 you can use older compatible versions of lualine using compat tags like `compat-nvim-0.5`, `compat-nvim-0.6`. -]] -) +]]) return false end diff --git a/lua/lualine/components/diagnostics/config.lua b/lua/lualine/components/diagnostics/config.lua index b50631207..094f88efe 100644 --- a/lua/lualine/components/diagnostics/config.lua +++ b/lua/lualine/components/diagnostics/config.lua @@ -18,7 +18,7 @@ M.options = { colored = true, update_in_insert = false, always_visible = false, - sources = { 'nvim_diagnostic', 'coc' }, + sources = { 'nvim_diagnostic', 'coc' }, sections = { 'error', 'warn', 'info', 'hint' }, } From 7533b0ead663d80452210c0c089e5105089697e5 Mon Sep 17 00:00:00 2001 From: Shadman <13149513+shadmansaleh@users.noreply.github.com> Date: Wed, 18 Oct 2023 11:22:34 +0600 Subject: [PATCH 15/47] Revert "added colours to qf extension to distinguish quickfix and location list (#933)" (#1118) This reverts commit 9170434aa100f3967b43d5d34bb9adc56fae1986. --- lua/lualine/extensions/quickfix.lua | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/lua/lualine/extensions/quickfix.lua b/lua/lualine/extensions/quickfix.lua index 3a64414f6..05cced542 100644 --- a/lua/lualine/extensions/quickfix.lua +++ b/lua/lualine/extensions/quickfix.lua @@ -16,11 +16,6 @@ local function title() return vim.fn.getqflist({ title = 0 }).title end -local qf_colours = { - ll = vim.api.nvim_get_hl_by_name('Constant', false).foreground, - qf = vim.api.nvim_get_hl_by_name('Identifier', false).foreground, -} - local M = {} function M.init() @@ -29,14 +24,7 @@ function M.init() end M.sections = { - lualine_a = { - { - label, - color = function() - return is_loclist() and { bg = qf_colours['ll'] } or { bg = qf_colours['qf'] } - end, - }, - }, + lualine_a = { label }, lualine_b = { title }, lualine_z = { 'location' }, } From d3f3395b9184b0f8d82ce2bf2d8c51af18c040f4 Mon Sep 17 00:00:00 2001 From: Jethro Cao Date: Thu, 19 Oct 2023 22:32:27 -0500 Subject: [PATCH 16/47] feat: Add ctrlspace extension (#1121) --- README.md | 3 ++- lua/lualine/extensions/ctrlspace.lua | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 lua/lualine/extensions/ctrlspace.lua diff --git a/README.md b/README.md index fdcb653c1..bcde13227 100644 --- a/README.md +++ b/README.md @@ -900,11 +900,13 @@ extensions = {'quickfix'} - aerial - chadtree +- ctrlspace - fern - fugitive - fzf - lazy - man +- mason - mundo - neo-tree - nerdtree @@ -915,7 +917,6 @@ extensions = {'quickfix'} - symbols-outline - toggleterm - trouble -- mason #### Custom extensions diff --git a/lua/lualine/extensions/ctrlspace.lua b/lua/lualine/extensions/ctrlspace.lua new file mode 100644 index 000000000..912a0b021 --- /dev/null +++ b/lua/lualine/extensions/ctrlspace.lua @@ -0,0 +1,12 @@ +local M = {} + +M.sections = { + lualine_a = { function() return vim.fn['ctrlspace#context#Configuration']().Symbols.CS end }, + lualine_b = { 'ctrlspace#api#StatuslineModeSegment' }, + lualine_y = { 'ctrlspace#api#StatuslineTabSegment' }, + lualine_z = { function() return 'CtrlSpace' end }, +} + +M.filetypes = { 'ctrlspace' } + +return M From 1dc8b44423078fda163cc0abb800963eb4c8343e Mon Sep 17 00:00:00 2001 From: shadmansaleh Date: Fri, 20 Oct 2023 03:32:59 +0000 Subject: [PATCH 17/47] chore: autogen (vimdocs+formating) --- doc/lualine.txt | 3 ++- lua/lualine/extensions/ctrlspace.lua | 12 ++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/doc/lualine.txt b/doc/lualine.txt index 9fdfcd87a..b956acbcf 100644 --- a/doc/lualine.txt +++ b/doc/lualine.txt @@ -954,11 +954,13 @@ extensions with: - aerial - chadtree +- ctrlspace - fern - fugitive - fzf - lazy - man +- mason - mundo - neo-tree - nerdtree @@ -969,7 +971,6 @@ extensions with: - symbols-outline - toggleterm - trouble -- mason *lualine-Custom-extensions* diff --git a/lua/lualine/extensions/ctrlspace.lua b/lua/lualine/extensions/ctrlspace.lua index 912a0b021..bc3f7647b 100644 --- a/lua/lualine/extensions/ctrlspace.lua +++ b/lua/lualine/extensions/ctrlspace.lua @@ -1,10 +1,18 @@ local M = {} M.sections = { - lualine_a = { function() return vim.fn['ctrlspace#context#Configuration']().Symbols.CS end }, + lualine_a = { + function() + return vim.fn['ctrlspace#context#Configuration']().Symbols.CS + end, + }, lualine_b = { 'ctrlspace#api#StatuslineModeSegment' }, lualine_y = { 'ctrlspace#api#StatuslineTabSegment' }, - lualine_z = { function() return 'CtrlSpace' end }, + lualine_z = { + function() + return 'CtrlSpace' + end, + }, } M.filetypes = { 'ctrlspace' } From 2248ef254d0a1488a72041cfb45ca9caada6d994 Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Fri, 20 Oct 2023 14:36:20 +1100 Subject: [PATCH 18/47] fix(#1087): handle searchcount failures (#1088) Co-authored-by: Shadman <13149513+shadmansaleh@users.noreply.github.com> --- lua/lualine/components/searchcount.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/lualine/components/searchcount.lua b/lua/lualine/components/searchcount.lua index 8274a7f73..a70ff8384 100644 --- a/lua/lualine/components/searchcount.lua +++ b/lua/lualine/components/searchcount.lua @@ -19,8 +19,8 @@ function M:update_status() return '' end - local result = vim.fn.searchcount { maxcount = self.options.maxcount, timeout = self.options.timeout } - if next(result) == nil then + local ok, result = pcall(vim.fn.searchcount, { maxcount = self.options.maxcount, timeout = self.options.timeout }) + if not ok or next(result) == nil then return '' end From 4040b70572b3c6f29c8535771605cb9a73d8faf5 Mon Sep 17 00:00:00 2001 From: Joey Schoblaska Date: Mon, 25 Dec 2023 22:41:26 -0600 Subject: [PATCH 19/47] tweak iceberg dark (#1162) --- lua/lualine/themes/iceberg_dark.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lua/lualine/themes/iceberg_dark.lua b/lua/lualine/themes/iceberg_dark.lua index 1dd9be99e..a24b5429f 100644 --- a/lua/lualine/themes/iceberg_dark.lua +++ b/lua/lualine/themes/iceberg_dark.lua @@ -6,7 +6,7 @@ local colors = { color2 = '#161821', color3 = '#b4be82', - color4 = '#6b7089', + color4 = '#c6c8d1', color5 = '#2e313f', color8 = '#e2a478', color9 = '#3e445e', @@ -26,14 +26,14 @@ return { 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 }, }, 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.color4, bg = colors.color10 }, }, insert = { a = { fg = colors.color2, bg = colors.color15, gui = 'bold' }, From f76d9b6454978e72e902910392d7e83292963688 Mon Sep 17 00:00:00 2001 From: Oleksandr Zymohliad Date: Tue, 26 Dec 2023 06:43:29 +0200 Subject: [PATCH 20/47] fix: escape filename after it has been shortened (#1159) --- lua/lualine/components/filename.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/lualine/components/filename.lua b/lua/lualine/components/filename.lua index fe194a7f2..b17c84faf 100644 --- a/lua/lualine/components/filename.lua +++ b/lua/lualine/components/filename.lua @@ -86,8 +86,6 @@ M.update_status = function(self) data = vim.fn.expand('%:t') end - data = modules.utils.stl_escape(data) - if data == '' then data = self.options.symbols.unnamed end @@ -113,6 +111,8 @@ M.update_status = function(self) table.insert(symbols, self.options.symbols.newfile) end + data = modules.utils.stl_escape(data) + return data .. (#symbols > 0 and ' ' .. table.concat(symbols, '') or '') end From 767a239ef41301f78cc9169bc5d236494671c1be Mon Sep 17 00:00:00 2001 From: Chris1320 Date: Tue, 26 Dec 2023 13:14:43 +0800 Subject: [PATCH 21/47] docs: Add lazy.nvim installation instructions. (#1140) (#1152) * docs: Add lazy.nvim installation instructions. (#1140) Signed-off-by: chris1320 * docs: Update lazy.nvim installation instructions. Signed-off-by: chris1320 * drop lazy loading instructions from for lazy.nvim --------- Signed-off-by: chris1320 Co-authored-by: shadmansaleh <13149513+shadmansaleh@users.noreply.github.com> --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index bcde13227..6760f2792 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,15 @@ use { } ``` +### [lazy.nvim](https://github.com/folke/lazy.nvim) + +```lua +{ + 'nvim-lualine/lualine.nvim', + dependencies = { 'nvim-tree/nvim-web-devicons' } +} +``` + You'll also need to have a patched font if you want icons. ## Usage and customization From 338003a267eb642abdc28342e025198fd5ffc36f Mon Sep 17 00:00:00 2001 From: shadmansaleh Date: Tue, 26 Dec 2023 05:15:03 +0000 Subject: [PATCH 22/47] chore: autogen (vimdocs+formating) --- doc/lualine.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/doc/lualine.txt b/doc/lualine.txt index b956acbcf..080295b57 100644 --- a/doc/lualine.txt +++ b/doc/lualine.txt @@ -70,6 +70,16 @@ PACKER.NVIM ~ < +LAZY.NVIM ~ + +> + { + 'nvim-lualine/lualine.nvim', + dependencies = { 'nvim-tree/nvim-web-devicons' } + } +< + + You’ll also need to have a patched font if you want icons. USAGE AND CUSTOMIZATION *lualine-usage-and-customization* From bd148ac7e4cb4df7367fbaef4c2fd33667fc8ae9 Mon Sep 17 00:00:00 2001 From: kjuq <44694396+kjuq@users.noreply.github.com> Date: Tue, 26 Dec 2023 14:16:11 +0900 Subject: [PATCH 23/47] feat: add oil.nvim extension to show current directory (#1154) * add: extension for oil.nvim * mod: cosmetic * mod: able to load Oil lazily * mod: readme --- README.md | 1 + lua/lualine/extensions/oil.lua | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 lua/lualine/extensions/oil.lua diff --git a/README.md b/README.md index 6760f2792..07ca280c6 100644 --- a/README.md +++ b/README.md @@ -921,6 +921,7 @@ extensions = {'quickfix'} - nerdtree - nvim-dap-ui - nvim-tree +- oil - overseer - quickfix - symbols-outline diff --git a/lua/lualine/extensions/oil.lua b/lua/lualine/extensions/oil.lua new file mode 100644 index 000000000..9c8ae31de --- /dev/null +++ b/lua/lualine/extensions/oil.lua @@ -0,0 +1,20 @@ +-- Extension for oil.nvim + +local M = {} + +M.sections = { + lualine_a = { + function() + local ok, oil = pcall(require, "oil") + if ok then + return vim.fn.fnamemodify(oil.get_current_dir(), ":~") + else + return "" + end + end, + }, +} + +M.filetypes = { "oil" } + +return M From 3abbbdd5e9aa02f06ffc297d73f73ba21f4e5084 Mon Sep 17 00:00:00 2001 From: shadmansaleh Date: Tue, 26 Dec 2023 05:16:28 +0000 Subject: [PATCH 24/47] chore: autogen (vimdocs+formating) --- doc/lualine.txt | 1 + lua/lualine/extensions/oil.lua | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/doc/lualine.txt b/doc/lualine.txt index 080295b57..be4b33ab7 100644 --- a/doc/lualine.txt +++ b/doc/lualine.txt @@ -976,6 +976,7 @@ extensions with: - nerdtree - nvim-dap-ui - nvim-tree +- oil - overseer - quickfix - symbols-outline diff --git a/lua/lualine/extensions/oil.lua b/lua/lualine/extensions/oil.lua index 9c8ae31de..afcf3e12c 100644 --- a/lua/lualine/extensions/oil.lua +++ b/lua/lualine/extensions/oil.lua @@ -5,16 +5,16 @@ local M = {} M.sections = { lualine_a = { function() - local ok, oil = pcall(require, "oil") + local ok, oil = pcall(require, 'oil') if ok then - return vim.fn.fnamemodify(oil.get_current_dir(), ":~") + return vim.fn.fnamemodify(oil.get_current_dir(), ':~') else - return "" + return '' end end, }, } -M.filetypes = { "oil" } +M.filetypes = { 'oil' } return M From 566b7036f717f3d676362742630518a47f132fff Mon Sep 17 00:00:00 2001 From: Joao Sa Date: Tue, 26 Dec 2023 02:36:34 -0300 Subject: [PATCH 25/47] fix(#820): Illegal character in filename (#1147) * fix(#820): handle % in path * fix merge issues --------- merged alongside f76d9b6454978e72e902910392d7e83292963688 Co-authored-by: Shadman <13149513+shadmansaleh@users.noreply.github.com> --- lua/lualine/components/filename.lua | 4 ++-- tests/spec/component_spec.lua | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/lua/lualine/components/filename.lua b/lua/lualine/components/filename.lua index b17c84faf..22fd964a6 100644 --- a/lua/lualine/components/filename.lua +++ b/lua/lualine/components/filename.lua @@ -97,6 +97,8 @@ M.update_status = function(self) data = shorten_path(data, path_separator, estimated_space_available) end + data = modules.utils.stl_escape(data) + local symbols = {} if self.options.file_status then if vim.bo.modified then @@ -111,8 +113,6 @@ M.update_status = function(self) table.insert(symbols, self.options.symbols.newfile) end - data = modules.utils.stl_escape(data) - return data .. (#symbols > 0 and ' ' .. table.concat(symbols, '') or '') end diff --git a/tests/spec/component_spec.lua b/tests/spec/component_spec.lua index c193109cd..42dd2bcb2 100644 --- a/tests/spec/component_spec.lua +++ b/tests/spec/component_spec.lua @@ -687,6 +687,27 @@ describe('Filename component', function() vim.fn.winwidth:revert() vim.fn.expand:revert() end) + + it('shortens path with %', function() + stub(vim.fn, 'expand') + vim.fn.expand.on_call_with('%:p').returns('%dir1/%dir2/%actual_%file') + stub(vim.fn, 'winwidth') + vim.fn.winwidth.on_call_with(0).returns(100) + + local opts = build_component_opts { + component_separators = { left = '', right = '' }, + padding = 0, + file_status = false, + path = 2, + shorting_target = 90, + } + vim.cmd(':e test-file.txt') + assert_component('filename', opts, '%%/%%/%%actual_%%file') + + vim.cmd(':bdelete!') + vim.fn.winwidth:revert() + vim.fn.expand:revert() + end) end) describe('vim option & variable component', function() From ea00644e98a306a54c11c7f2058a668c38876e6f Mon Sep 17 00:00:00 2001 From: AlecJDavidson <44955224+AlecJDavidson@users.noreply.github.com> Date: Thu, 25 Jan 2024 06:16:03 -0500 Subject: [PATCH 26/47] chore: fixed typo (#1181) Typo fix "versoins" to versions. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 07ca280c6..eeb8d42c0 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ A blazing fast and easy to configure Neovim statusline written in Lua. `lualine.nvim` requires Neovim >= 0.7. -For previous versoins of neovim please use compatability tags for example +For previous versions of neovim please use compatability tags for example compat-nvim-0.5 ## Contributing From 7d131a8d3ba5016229e8a1d08bf8782acea98852 Mon Sep 17 00:00:00 2001 From: shadmansaleh Date: Thu, 25 Jan 2024 11:16:55 +0000 Subject: [PATCH 27/47] chore: autogen (vimdocs+formating) --- doc/lualine.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/lualine.txt b/doc/lualine.txt index be4b33ab7..05d456604 100644 --- a/doc/lualine.txt +++ b/doc/lualine.txt @@ -16,7 +16,7 @@ A blazing fast and easy to configure Neovim statusline written in Lua. `lualine.nvim` requires Neovim >= 0.7. -For previous versoins of neovim please use compatability tags for example +For previous versions of neovim please use compatability tags for example compat-nvim-0.5 CONTRIBUTING *lualine-contributing* From 28027a564496713969e5638d7de0d91d280365b6 Mon Sep 17 00:00:00 2001 From: shadmansaleh <13149513+shadmansaleh@users.noreply.github.com> Date: Mon, 4 Mar 2024 18:42:41 +0600 Subject: [PATCH 28/47] update bubles example config --- examples/bubbles.lua | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/examples/bubbles.lua b/examples/bubbles.lua index c1ecf3100..4cb5536c3 100644 --- a/examples/bubbles.lua +++ b/examples/bubbles.lua @@ -17,7 +17,7 @@ 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 }, + c = { fg = colors.white }, }, insert = { a = { fg = colors.black, bg = colors.blue } }, @@ -27,22 +27,20 @@ local bubbles_theme = { inactive = { a = { fg = colors.white, bg = colors.black }, b = { fg = colors.white, bg = colors.black }, - c = { fg = colors.black, bg = colors.black }, + c = { fg = colors.white }, }, } require('lualine').setup { options = { theme = bubbles_theme, - component_separators = '|', + component_separators = '', section_separators = { left = '', right = '' }, }, sections = { - lualine_a = { - { 'mode', separator = { left = '' }, right_padding = 2 }, - }, + lualine_a = { { 'mode', separator = { left = '' }, right_padding = 2 }, }, lualine_b = { 'filename', 'branch' }, - lualine_c = { 'fileformat' }, + lualine_c = {'%=', --[[ add your center compoentnts here in place of this comment ]]}, lualine_x = {}, lualine_y = { 'filetype', 'progress' }, lualine_z = { From f2de8f2fd685ae3242febc9dc918028d44ba9cd1 Mon Sep 17 00:00:00 2001 From: shadmansaleh Date: Mon, 4 Mar 2024 12:43:09 +0000 Subject: [PATCH 29/47] chore: autogen (vimdocs+formating) --- examples/bubbles.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/bubbles.lua b/examples/bubbles.lua index 4cb5536c3..88edf5746 100644 --- a/examples/bubbles.lua +++ b/examples/bubbles.lua @@ -38,9 +38,11 @@ require('lualine').setup { section_separators = { left = '', right = '' }, }, sections = { - lualine_a = { { 'mode', separator = { left = '' }, right_padding = 2 }, }, + lualine_a = { { 'mode', separator = { left = '' }, right_padding = 2 } }, lualine_b = { 'filename', 'branch' }, - lualine_c = {'%=', --[[ add your center compoentnts here in place of this comment ]]}, + lualine_c = { + '%=', --[[ add your center compoentnts here in place of this comment ]] + }, lualine_x = {}, lualine_y = { 'filetype', 'progress' }, lualine_z = { From 8b56462bfb746760465264de41b4907310f113ec Mon Sep 17 00:00:00 2001 From: Trevor Arjeski Date: Mon, 4 Mar 2024 15:45:01 +0300 Subject: [PATCH 30/47] fix: fzf extension selected element parsing (#1198) * fix: fzf extension selected element parsing On non-floating windows the selected element is not supported and showed 'nil'. This fixes that and also uses fzf's path parser for a cleaner parsing of the selection. Closes #1197 * fix: fzf-lua extension lazy loading Not calling require immediately will allow for better lazy loading using lazy.nvim while the 'fzf' extension is enabled. --- lua/lualine/extensions/fzf.lua | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/lua/lualine/extensions/fzf.lua b/lua/lualine/extensions/fzf.lua index 00fea2bf5..956a0e911 100644 --- a/lua/lualine/extensions/fzf.lua +++ b/lua/lualine/extensions/fzf.lua @@ -5,10 +5,12 @@ works with both https://github.com/junegunn/fzf.vim and https://github.com/ibhag -- fzf-lua must be set-up in split mode ]] -local fzf_lua, _ = pcall(require, 'fzf-lua') +local function has_fzf() + return pcall(require, 'fzf-lua') +end local function fzf_picker() - if not fzf_lua then + if not has_fzf() then return '' end @@ -17,16 +19,13 @@ local function fzf_picker() end local function fzf_element() - if not fzf_lua then + if not has_fzf() then return '' end - local info_string = vim.inspect(require('fzf-lua').get_info()['selected']) - local lines = {} - for w in info_string:gsub('"', ''):gmatch('%S+') do - table.insert(lines, w) - end - return lines[1] + local fzf = require('fzf-lua') + local selected = fzf.get_info().selected + return fzf.path.entry_to_file(selected).path end local function fzf_statusline() From 79c4b296d071a460ee71e18be38813fd5875f3cf Mon Sep 17 00:00:00 2001 From: Willem-J-an <51120533+Willem-J-an@users.noreply.github.com> Date: Mon, 11 Mar 2024 15:39:58 +0100 Subject: [PATCH 31/47] fix(branch): extract correct branch name for term buffers (#1204) terminal buffers have a different path that did not work to retrieve the branch name. By extracting the path out of the terminal path, the branch name can still resolve even when in term buffers. --- lua/lualine/components/branch/git_branch.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lua/lualine/components/branch/git_branch.lua b/lua/lualine/components/branch/git_branch.lua index 48625f558..6ac9ba6c0 100644 --- a/lua/lualine/components/branch/git_branch.lua +++ b/lua/lualine/components/branch/git_branch.lua @@ -76,6 +76,12 @@ function M.find_git_dir(dir_path) -- get file dir so we can search from that dir local file_dir = dir_path or vim.fn.expand('%:p:h') + + -- extract correct file dir from terminals + if file_dir and file_dir:match('term://.*') then + file_dir = vim.fn.expand(file_dir:gsub('term://(.+)//.+', "%1")) + end + local root_dir = file_dir -- Search upward for .git file or folder while root_dir do From 3c55675a7bc170d21d7ea70874ae66fbf5cfb0dc Mon Sep 17 00:00:00 2001 From: shadmansaleh Date: Mon, 11 Mar 2024 14:40:24 +0000 Subject: [PATCH 32/47] chore: autogen (vimdocs+formating) --- lua/lualine/components/branch/git_branch.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lualine/components/branch/git_branch.lua b/lua/lualine/components/branch/git_branch.lua index 6ac9ba6c0..dcc9775ff 100644 --- a/lua/lualine/components/branch/git_branch.lua +++ b/lua/lualine/components/branch/git_branch.lua @@ -79,7 +79,7 @@ function M.find_git_dir(dir_path) -- extract correct file dir from terminals if file_dir and file_dir:match('term://.*') then - file_dir = vim.fn.expand(file_dir:gsub('term://(.+)//.+', "%1")) + file_dir = vim.fn.expand(file_dir:gsub('term://(.+)//.+', '%1')) end local root_dir = file_dir From 26dac2fcadb6e622790ab08e36d0dba3d3765398 Mon Sep 17 00:00:00 2001 From: Riley Bruins Date: Wed, 13 Mar 2024 07:34:38 -0700 Subject: [PATCH 33/47] fix: use larger ft icon when coloring applied (#1172) * fix: use larger ft icon when coloring applied * fix: pass filetype tests * fix: pass another test --- lua/lualine/components/filetype.lua | 8 +++++++- tests/spec/component_spec.lua | 6 +++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lua/lualine/components/filetype.lua b/lua/lualine/components/filetype.lua index 673379dd2..748359fe0 100644 --- a/lua/lualine/components/filetype.lua +++ b/lua/lualine/components/filetype.lua @@ -40,6 +40,9 @@ function M:apply_icon() icon = '' icon_highlight_group = 'DevIconDefault' end + if icon then + icon = icon .. ' ' + end if self.options.colored then local highlight_color = modules.utils.extract_highlight_colors(icon_highlight_group, 'fg') if highlight_color then @@ -57,6 +60,9 @@ function M:apply_icon() ok = vim.fn.exists('*WebDevIconsGetFileTypeSymbol') if ok ~= 0 then icon = vim.fn.WebDevIconsGetFileTypeSymbol() + if icon then + icon = icon .. ' ' + end end end @@ -69,7 +75,7 @@ function M:apply_icon() elseif type(self.options.icon) == 'table' and self.options.icon.align == 'right' then self.status = self.status .. ' ' .. icon else - self.status = icon .. ' ' .. self.status + self.status = icon .. self.status end end diff --git a/tests/spec/component_spec.lua b/tests/spec/component_spec.lua index 42dd2bcb2..7be377bd9 100644 --- a/tests/spec/component_spec.lua +++ b/tests/spec/component_spec.lua @@ -323,7 +323,7 @@ describe('Filetype component', function() colored = true, icon_only = false, } - assert_component('filetype', opts, '%#MyCompHl_normal#*%#lualine_c_normal# lua%#lualine_c_normal#') + assert_component('filetype', opts, '%#MyCompHl_normal#* %#lualine_c_normal#lua%#lualine_c_normal#') assert.stub(devicons.get_icon).was_called_with('test.lua') assert.stub(utils.extract_highlight_colors).was_called_with('test_highlight_group', 'fg') assert.stub(hl.create_component_highlight_group).was_called_with( @@ -393,7 +393,7 @@ describe('Filetype component', function() colored = false, icon_only = true, } - assert_component('filetype', opts, '*') + assert_component('filetype', opts, '* ') assert.stub(devicons.get_icon).was_called_with('test.lua') assert.stub(utils.extract_highlight_colors).was_not_called() assert.stub(hl.create_component_highlight_group).was_not_called() @@ -426,7 +426,7 @@ describe('Filetype component', function() icon_only = false, icon = { align = 'right' } } - assert_component('filetype', opts, 'lua *') + assert_component('filetype', opts, 'lua * ') assert.stub(devicons.get_icon).was_called_with('test.lua') assert.stub(utils.extract_highlight_colors).was_not_called() assert.stub(hl.create_component_highlight_group).was_not_called() From 3e77976c8deaf622ea7a99a38e8b64b75a76f13e Mon Sep 17 00:00:00 2001 From: "Aldric.li" <31800073+Parsifa1@users.noreply.github.com> Date: Sat, 16 Mar 2024 01:31:17 +0800 Subject: [PATCH 34/47] Fixed refresh delay issue when setting `w` in keymap (#1193) --- lua/lualine.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lualine.lua b/lua/lualine.lua index fa89a3e7f..609304929 100644 --- a/lua/lualine.lua +++ b/lua/lualine.lua @@ -27,7 +27,7 @@ local refresh_real_curwin -- The events on which lualine redraws itself local default_refresh_events = - 'WinEnter,BufEnter,SessionLoadPost,FileChangedShellPost,VimResized,Filetype,CursorMoved,CursorMovedI,ModeChanged' + 'WinEnter,BufEnter,BufWritePost,SessionLoadPost,FileChangedShellPost,VimResized,Filetype,CursorMoved,CursorMovedI,ModeChanged' -- Helper for apply_transitional_separators() --- finds first applied highlight group after str_checked in status ---@param status string : unprocessed statusline string From af4c3cf17206810880d2a93562e0a4c0d901c684 Mon Sep 17 00:00:00 2001 From: Trevor Arjeski Date: Fri, 15 Mar 2024 20:33:36 +0300 Subject: [PATCH 35/47] fix: mason extension lazy loading (#1196) Fixed mason extension to only load mason-registry when the lualine section is displayed (on 'mason' filetype). This prevents loading mason when lualine is loaded. --- lua/lualine/extensions/mason.lua | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lua/lualine/extensions/mason.lua b/lua/lualine/extensions/mason.lua index 16ed56b40..5432fe662 100644 --- a/lua/lualine/extensions/mason.lua +++ b/lua/lualine/extensions/mason.lua @@ -1,8 +1,11 @@ -- lualine extension for mason.nvim -local ok, mason_registry = pcall(require, 'mason-registry') -if not ok then - return '' +local mason_registry +local function maybe_set_registry() + local ok, registry = pcall(require, 'mason-registry') + if ok then + mason_registry = registry + end end local M = {} @@ -15,6 +18,7 @@ M.sections = { }, lualine_b = { function() + maybe_set_registry() return 'Installed: ' .. #mason_registry.get_installed_packages() .. '/' .. #mason_registry.get_all_package_specs() end, }, From b5e8bb642138f787a2c1c5aedc2a78cb2cebbd67 Mon Sep 17 00:00:00 2001 From: Daemon Date: Wed, 20 Mar 2024 22:18:13 -0700 Subject: [PATCH 36/47] fix: prioritize user config for theme-loader on windows (#1213) (#1214) --- lua/lualine/utils/loader.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/lualine/utils/loader.lua b/lua/lualine/utils/loader.lua index 37baa015d..e0c0385e3 100644 --- a/lua/lualine/utils/loader.lua +++ b/lua/lualine/utils/loader.lua @@ -229,7 +229,8 @@ local function load_theme(theme_name) -- put entries from user config path in front local user_config_path = vim.fn.stdpath('config') table.sort(files, function(a, b) - return vim.startswith(a, user_config_path) or not vim.startswith(b, user_config_path) + local pattern = table.concat { user_config_path, sep } + return string.match(a, pattern) or not string.match(b, pattern) end) -- 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) From 15d830d1645f1e104bdce0aaf2b140bbc2d07d50 Mon Sep 17 00:00:00 2001 From: Jamy Date: Fri, 5 Apr 2024 11:33:34 +0200 Subject: [PATCH 37/47] Add support for base16-vim alongside nvim-base16 (#1006) --- THEMES.md | 2 +- lua/lualine/themes/base16.lua | 24 ++++++++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/THEMES.md b/THEMES.md index 184bfc781..379b62004 100644 --- a/THEMES.md +++ b/THEMES.md @@ -54,7 +54,7 @@ But if `g:ayuprefermirage` exists, it will load ayu_mirage instead when ### base16 -This theme will automatically use 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 [tinted-theming/base16-vim](https://github.com/tinted-theming/base16-vim) or [RRethy/nvim-base16](https://github.com/RRethy/nvim-base16)] plugin. The following example is using the `tomorrow-night` colorscheme:

diff --git a/lua/lualine/themes/base16.lua b/lua/lualine/themes/base16.lua index fb7d45140..daf6a6bff 100644 --- a/lua/lualine/themes/base16.lua +++ b/lua/lualine/themes/base16.lua @@ -50,7 +50,8 @@ local function setup_default() } end -local function setup_base16() +local function setup_base16_nvim() + -- Continue to load nvim-base16 local loaded, base16 = pcall(require, 'base16-colorscheme') if not loaded then @@ -89,4 +90,23 @@ local function setup_base16() } end -return setup_base16() or setup_default() +local function setup_base16_vim() + -- Check if tinted-theming/base16-vim is already loaded + if vim.g.base16_gui00 and vim.g.base16_gui0F then + return setup { + bg = vim.g.base16_gui01, + alt_bg = vim.g.base16_gui02, + dark_fg = vim.g.base16_gui03, + fg = vim.g.base16_gui04, + light_fg = vim.g.base16_gui05, + normal = vim.g.base16_gui0D, + insert = vim.g.base16_gui0B, + visual = vim.g.base16_gui0E, + replace = vim.g.base16_gui09, + } + end + + return nil +end + +return setup_base16_vim() or setup_base16_nvim() or setup_default() From 0a5a66803c7407767b799067986b4dc3036e1983 Mon Sep 17 00:00:00 2001 From: Antoine Prouvost Date: Fri, 5 Apr 2024 11:46:36 +0200 Subject: [PATCH 38/47] feat: Allow cterm highlight number through (#1194) Co-authored-by: Shadman <13149513+shadmansaleh@users.noreply.github.com> --- lua/lualine/highlight.lua | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/lua/lualine/highlight.lua b/lua/lualine/highlight.lua index 22cea7e93..62343031e 100644 --- a/lua/lualine/highlight.lua +++ b/lua/lualine/highlight.lua @@ -76,6 +76,19 @@ local function sanitize_color(color) end end +---converts color_name type colors to cterm format and let cterm color pass through +---@param color string|number +---@return string +local function sanitize_color_for_cterm(color) + if type(color) == 'number' then + if color > 255 then + error("What's this it can't be higher then 255 and you've given " .. color) + end + return color + end + return modules.color_utils.rgb2cterm(sanitize_color(color)) +end + function M.get_lualine_hl(name) local hl = loaded_highlights[name] if hl and not hl.empty then @@ -113,24 +126,25 @@ function M.highlight(name, foreground, background, gui, link) end vim.list_extend(command, { 'link', name, link }) else - foreground = sanitize_color(foreground) - background = sanitize_color(background) + local foreground_rgb = sanitize_color(foreground) + local background_rgb = sanitize_color(background) gui = (gui ~= nil and gui ~= '') and gui or 'None' if loaded_highlights[name] - and loaded_highlights[name].fg == foreground - and loaded_highlights[name].bg == background + and loaded_highlights[name].fg == foreground_rgb + and loaded_highlights[name].bg == background_rgb and loaded_highlights[name].gui == gui then return -- color is already defined why are we doing this anyway ? end table.insert(command, name) - table.insert(command, 'guifg=' .. foreground) - table.insert(command, 'guibg=' .. background) + table.insert(command, 'guifg=' .. foreground_rgb) + table.insert(command, 'guibg=' .. background_rgb) table.insert(command, 'gui=' .. gui) if create_cterm_colors then - table.insert(command, 'ctermfg=' .. modules.color_utils.rgb2cterm(foreground)) - table.insert(command, 'ctermbg=' .. modules.color_utils.rgb2cterm(background)) + -- Not setting color from xxxground_rgb to let possible user 256 number through + table.insert(command, 'ctermfg=' .. sanitize_color_for_cterm(foreground)) + table.insert(command, 'ctermbg=' .. sanitize_color_for_cterm(background)) table.insert(command, 'cterm=' .. gui) end end From 942b58628fbd513dcff64b6765a3482c76b49123 Mon Sep 17 00:00:00 2001 From: Rajat Yadav <53974841+laggedskapari@users.noreply.github.com> Date: Sun, 7 Jul 2024 12:31:11 +0530 Subject: [PATCH 39/47] Update evil_lualine.lua diagnostics colors. (#1254) fix: diagnostics colors. --- examples/evil_lualine.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/evil_lualine.lua b/examples/evil_lualine.lua index 138692036..1331132b9 100644 --- a/examples/evil_lualine.lua +++ b/examples/evil_lualine.lua @@ -141,9 +141,9 @@ ins_left { sources = { 'nvim_diagnostic' }, symbols = { error = ' ', warn = ' ', info = ' ' }, diagnostics_color = { - color_error = { fg = colors.red }, - color_warn = { fg = colors.yellow }, - color_info = { fg = colors.cyan }, + error = { fg = colors.red }, + warn = { fg = colors.yellow }, + info = { fg = colors.cyan }, }, } From e20896769ca3cd7e623f0d9f0f68c2155e1eeee2 Mon Sep 17 00:00:00 2001 From: David Trowbridge Date: Sun, 7 Jul 2024 01:03:35 -0600 Subject: [PATCH 40/47] fix: Location component was showing wrong column with inlay hints. (#1243) The location component had been previously changed to use `vim.api.virtcol` (the screen position of the cursor) instead of `vim.api.col` (the byte position of the cursor), in order to prevent showing the wrong column when multibyte characters are present. Unfortunately, the new inlay hints in neovim 0.10 make heavy use of virtual text, and therefore the column shown in the location component is often incorrect. This change fixes it to use `vim.api.charcol`, which correctly handles variable-width characters without including virtual text. --- lua/lualine/components/location.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lualine/components/location.lua b/lua/lualine/components/location.lua index 1b276acc1..a15eb91e4 100644 --- a/lua/lualine/components/location.lua +++ b/lua/lualine/components/location.lua @@ -2,7 +2,7 @@ -- MIT license, see LICENSE for more details. local function location() local line = vim.fn.line('.') - local col = vim.fn.virtcol('.') + local col = vim.fn.charcol('.') return string.format('%3d:%-2d', line, col) end From ff3fedb007a4b70f7c797cbcdccde053a14e2c23 Mon Sep 17 00:00:00 2001 From: Donatas Date: Mon, 8 Jul 2024 07:24:12 +0300 Subject: [PATCH 41/47] `branch` supports `oil` now (#1242) * lualine filename oil * git branch oil support * revert * sure fire way to get current dir --- lua/lualine/components/branch/git_branch.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lua/lualine/components/branch/git_branch.lua b/lua/lualine/components/branch/git_branch.lua index dcc9775ff..0daaab63a 100644 --- a/lua/lualine/components/branch/git_branch.lua +++ b/lua/lualine/components/branch/git_branch.lua @@ -77,6 +77,14 @@ function M.find_git_dir(dir_path) -- get file dir so we can search from that dir local file_dir = dir_path or vim.fn.expand('%:p:h') + local oil_exists, oil = pcall(require, 'oil') + if oil_exists then + local ok, dir = pcall(oil.get_current_dir) + if ok and dir and dir ~= '' then + file_dir = vim.fn.fnamemodify(dir, ":p:h") + end + end + -- extract correct file dir from terminals if file_dir and file_dir:match('term://.*') then file_dir = vim.fn.expand(file_dir:gsub('term://(.+)//.+', '%1')) From a0232429c3c573e5658813f78b2d2f1253fcf87f Mon Sep 17 00:00:00 2001 From: shadmansaleh Date: Mon, 8 Jul 2024 04:24:29 +0000 Subject: [PATCH 42/47] chore: autogen (vimdocs+formating) --- lua/lualine/components/branch/git_branch.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lualine/components/branch/git_branch.lua b/lua/lualine/components/branch/git_branch.lua index 0daaab63a..15057a756 100644 --- a/lua/lualine/components/branch/git_branch.lua +++ b/lua/lualine/components/branch/git_branch.lua @@ -81,7 +81,7 @@ function M.find_git_dir(dir_path) if oil_exists then local ok, dir = pcall(oil.get_current_dir) if ok and dir and dir ~= '' then - file_dir = vim.fn.fnamemodify(dir, ":p:h") + file_dir = vim.fn.fnamemodify(dir, ':p:h') end end From 6a40b530539d2209f7dc0492f3681c8c126647ad Mon Sep 17 00:00:00 2001 From: Oskar Meyenburg <135001586+oskarmeyenburg@users.noreply.github.com> Date: Mon, 8 Jul 2024 06:50:09 +0200 Subject: [PATCH 43/47] Use vim.diagnostic.count instead of get (Feat #1239) (#1268) --- lua/lualine/components/diagnostics/sources.lua | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lua/lualine/components/diagnostics/sources.lua b/lua/lualine/components/diagnostics/sources.lua index c0ef78c7d..48fdd2164 100644 --- a/lua/lualine/components/diagnostics/sources.lua +++ b/lua/lualine/components/diagnostics/sources.lua @@ -33,8 +33,19 @@ M.sources = { workspace_diag(diag_severity.HINT) end, nvim_diagnostic = function() + local count + + if vim.diagnostic.count ~= nil then -- neovim >= 0.10.0 + count = vim.diagnostic.count(0) + return count[vim.diagnostic.severity.ERROR] or 0, + count[vim.diagnostic.severity.WARN] or 0, + count[vim.diagnostic.severity.INFO] or 0, + count[vim.diagnostic.severity.HINT] or 0 + end + + -- fallback local diagnostics = vim.diagnostic.get(0) - local count = { 0, 0, 0, 0 } + count = { 0, 0, 0, 0 } for _, diagnostic in ipairs(diagnostics) do count[diagnostic.severity] = count[diagnostic.severity] + 1 end From be2d87683163473b87148fb9be2f63b71ef1b2a0 Mon Sep 17 00:00:00 2001 From: Sergiu <36699660+sergiuser1@users.noreply.github.com> Date: Mon, 15 Jul 2024 08:22:32 +0200 Subject: [PATCH 44/47] feat: Add BOM indicator to encoding component (#1228) * feat: Add BOM indicator to encoding component * feat: Make BOM indicator optional * chore: Add more tests for encoding component --- README.md | 14 +++++++++++++ lua/lualine/components/encoding.lua | 31 ++++++++++++++++++++++++++--- tests/spec/component_spec.lua | 31 +++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index eeb8d42c0..238b283b8 100644 --- a/README.md +++ b/README.md @@ -670,6 +670,20 @@ sections = { } ``` +#### encoding component options + +```lua +sections = { + lualine_a = { + { + 'encoding', + -- Show '[BOM]' when the file has a byte-order mark + show_bomb = false, + } + } +} +``` + #### searchcount component options ```lua diff --git a/lua/lualine/components/encoding.lua b/lua/lualine/components/encoding.lua index 80a5ece7c..936b26568 100644 --- a/lua/lualine/components/encoding.lua +++ b/lua/lualine/components/encoding.lua @@ -1,7 +1,32 @@ -- Copyright (c) 2020-2021 hoob3rt -- MIT license, see LICENSE for more details. -local function encoding() - return vim.opt.fileencoding:get() +local lualine_require = require('lualine_require') +local M = lualine_require.require('lualine.component'):extend() + +local default_options = { + -- Show '[BOM]' when the file has a byte-order mark + show_bomb = false, +} + +function M:init(options) + M.super.init(self, options) + self.options = vim.tbl_deep_extend('keep', self.options or {}, default_options) +end + +function M:update_status() + local show_bomb = self.options.show_bomb + + local result = vim.opt.fileencoding:get() + + if not show_bomb then + return result + end + + if vim.opt.bomb:get() then + result = result .. ' [BOM]' + end + + return result end -return encoding +return M diff --git a/tests/spec/component_spec.lua b/tests/spec/component_spec.lua index 7be377bd9..3311b95b1 100644 --- a/tests/spec/component_spec.lua +++ b/tests/spec/component_spec.lua @@ -242,6 +242,37 @@ describe('Encoding component', function() vim.cmd('bd!') os.remove(tmp_path) end) + it('works with BOM and default config', function() + local opts = build_component_opts { + component_separators = { left = '', right = '' }, + padding = 0, + } + local tmp_path = 'tmp.txt' + local tmp_fp = io.open(tmp_path, 'w') + tmp_fp:write('test file') + tmp_fp:close() + vim.cmd('e ' .. tmp_path) + vim.cmd('set bomb') + assert_component('encoding', opts, 'utf-8') + vim.cmd('bd!') + os.remove(tmp_path) + end) + it('works with BOM and option enabled', function() + local opts = build_component_opts { + component_separators = { left = '', right = '' }, + padding = 0, + show_bomb = true + } + local tmp_path = 'tmp.txt' + local tmp_fp = io.open(tmp_path, 'w') + tmp_fp:write('test file') + tmp_fp:close() + vim.cmd('e ' .. tmp_path) + vim.cmd('set bomb') + assert_component('encoding', opts, 'utf-8 [BOM]') + vim.cmd('bd!') + os.remove(tmp_path) + end) end) describe('Fileformat component', function() From baa7267a52a81dddff58e4705c989002919e1bf6 Mon Sep 17 00:00:00 2001 From: shadmansaleh Date: Mon, 15 Jul 2024 06:22:53 +0000 Subject: [PATCH 45/47] chore: autogen (vimdocs+formating) --- doc/lualine.txt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/doc/lualine.txt b/doc/lualine.txt index 05d456604..af0bde7e1 100644 --- a/doc/lualine.txt +++ b/doc/lualine.txt @@ -699,6 +699,21 @@ Component specific options These are options that are available on < + *lualine-encoding-component-options* + +> + sections = { + lualine_a = { + { + 'encoding', + -- Show '[BOM]' when the file has a byte-order mark + show_bomb = false, + } + } + } +< + + *lualine-searchcount-component-options* > From 544dd1583f9bb27b393f598475c89809c4d5e86b Mon Sep 17 00:00:00 2001 From: Eduardo Bray Date: Mon, 15 Jul 2024 02:24:06 -0400 Subject: [PATCH 46/47] fix: Use package.loaded instead of require to check if oil exists (#1275) --- lua/lualine/components/branch/git_branch.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/lualine/components/branch/git_branch.lua b/lua/lualine/components/branch/git_branch.lua index 15057a756..9474f3232 100644 --- a/lua/lualine/components/branch/git_branch.lua +++ b/lua/lualine/components/branch/git_branch.lua @@ -77,8 +77,8 @@ function M.find_git_dir(dir_path) -- get file dir so we can search from that dir local file_dir = dir_path or vim.fn.expand('%:p:h') - local oil_exists, oil = pcall(require, 'oil') - if oil_exists then + if package.loaded.oil then + local oil = require('oil') local ok, dir = pcall(oil.get_current_dir) if ok and dir and dir ~= '' then file_dir = vim.fn.fnamemodify(dir, ':p:h') From b431d228b7bbcdaea818bdc3e25b8cdbe861f056 Mon Sep 17 00:00:00 2001 From: Daemon Date: Mon, 12 Aug 2024 07:39:22 -0700 Subject: [PATCH 47/47] fix: prioritize user config for extensions on windows (#1215) Fixes the second part of: #1213 The same logic fixed in (#1214) is duplicated in the lualine_require module, which appears to be used internally for loading things like extensions. On windows, user defined extensions that overwrite the builtin similarly cannot be loaded due to the same string matching issue. In addition, the number of queried runtime files is always less-than or equal to 1 due to the `all` parameter for `nvim_get_runtime_file` being set to false. Making it impossible to sort the list of files and prioritize ones within the users config path `vim.fn.stdpath("config")`. --- lua/lualine_require.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lua/lualine_require.lua b/lua/lualine_require.lua index 968e9af1f..a4a369b5a 100644 --- a/lua/lualine_require.lua +++ b/lua/lualine_require.lua @@ -54,16 +54,17 @@ function M.require(module) end pattern_path = table.concat { 'lua/', module:gsub('%.', '/'), '.lua' } - local paths = vim.api.nvim_get_runtime_file(pattern_path, false) + local paths = vim.api.nvim_get_runtime_file(pattern_path, true) if #paths <= 0 then pattern_path = table.concat { 'lua/', module:gsub('%.', '/'), '/init.lua' } - paths = vim.api.nvim_get_runtime_file(pattern_path, false) + paths = vim.api.nvim_get_runtime_file(pattern_path, true) end if #paths > 0 then -- put entries from user config path in front local user_config_path = vim.fn.stdpath('config') table.sort(paths, function(a, b) - return vim.startswith(a, user_config_path) or not vim.startswith(b, user_config_path) + local pattern = table.concat { user_config_path, M.sep } + return string.match(a, pattern) or not string.match(b, pattern) end) local mod_result = dofile(paths[1]) package.loaded[module] = mod_result