Skip to content

Commit

Permalink
Merge branch 'master' into 1087-handle-searchcount-failures
Browse files Browse the repository at this point in the history
  • Loading branch information
shadmansaleh authored Oct 20, 2023
2 parents 02cca9d + 1dc8b44 commit b4bcc44
Show file tree
Hide file tree
Showing 14 changed files with 221 additions and 180 deletions.
12 changes: 4 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -679,6 +682,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
Expand All @@ -687,6 +691,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,

Expand All @@ -696,6 +705,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)
Expand Down Expand Up @@ -886,11 +900,13 @@ extensions = {'quickfix'}

- aerial
- chadtree
- ctrlspace
- fern
- fugitive
- fzf
- lazy
- man
- mason
- mundo
- neo-tree
- nerdtree
Expand Down
18 changes: 17 additions & 1 deletion doc/lualine.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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*

Expand Down Expand Up @@ -708,6 +711,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
Expand All @@ -716,6 +720,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,
Expand All @@ -725,6 +734,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)
Expand Down Expand Up @@ -940,11 +954,13 @@ extensions with:

- aerial
- chadtree
- ctrlspace
- fern
- fugitive
- fzf
- lazy
- man
- mason
- mundo
- neo-tree
- nerdtree
Expand Down
38 changes: 26 additions & 12 deletions lua/lualine.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -602,6 +599,21 @@ 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
Expand All @@ -616,14 +628,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
Expand Down
22 changes: 17 additions & 5 deletions lua/lualine/components/branch/git_branch.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lua/lualine/components/diagnostics/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
}

Expand Down
29 changes: 9 additions & 20 deletions lua/lualine/components/diagnostics/sources.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 6 additions & 0 deletions lua/lualine/components/tabs/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit b4bcc44

Please sign in to comment.