refactor(statusline): remove tdo count from tabline to simplify display
This commit is contained in:
1 file changed
+221
-236
+221
-236
@@ -1,254 +1,239 @@
|
|||||||
return {
|
return {
|
||||||
"nvim-lualine/lualine.nvim",
|
'nvim-lualine/lualine.nvim',
|
||||||
dependencies = {
|
dependencies = {
|
||||||
"ellisonleao/gruvbox.nvim",
|
'ellisonleao/gruvbox.nvim',
|
||||||
},
|
},
|
||||||
config = function()
|
config = function()
|
||||||
local lualine = require("lualine")
|
local lualine = require('lualine')
|
||||||
|
|
||||||
-- Get gruvbox colors
|
-- Get gruvbox colors
|
||||||
local palette = require("gruvbox").palette
|
local palette = require('gruvbox').palette
|
||||||
|
|
||||||
local colors = {
|
local colors = {
|
||||||
bg = palette.dark0,
|
bg = palette.dark0,
|
||||||
fg = palette.light1,
|
fg = palette.light1,
|
||||||
yellow = palette.bright_yellow,
|
yellow = palette.bright_yellow,
|
||||||
cyan = palette.bright_aqua,
|
cyan = palette.bright_aqua,
|
||||||
darkblue = palette.dark0_hard,
|
darkblue = palette.dark0_hard,
|
||||||
green = palette.bright_green,
|
green = palette.bright_green,
|
||||||
orange = palette.bright_orange,
|
orange = palette.bright_orange,
|
||||||
violet = palette.bright_purple,
|
violet = palette.bright_purple,
|
||||||
magenta = palette.bright_purple,
|
magenta = palette.bright_purple,
|
||||||
blue = palette.bright_blue,
|
blue = palette.bright_blue,
|
||||||
red = palette.bright_red,
|
red = palette.bright_red,
|
||||||
}
|
}
|
||||||
|
|
||||||
local mode_color = {
|
local mode_color = {
|
||||||
n = colors.green,
|
n = colors.green,
|
||||||
i = colors.blue,
|
i = colors.blue,
|
||||||
v = colors.magenta,
|
v = colors.magenta,
|
||||||
[""] = colors.magenta,
|
[''] = colors.magenta,
|
||||||
V = colors.magenta,
|
V = colors.magenta,
|
||||||
c = colors.yellow,
|
c = colors.yellow,
|
||||||
t = colors.red,
|
t = colors.red,
|
||||||
R = colors.orange,
|
R = colors.orange,
|
||||||
Rv = colors.orange,
|
Rv = colors.orange,
|
||||||
no = colors.fg,
|
no = colors.fg,
|
||||||
s = colors.violet,
|
s = colors.violet,
|
||||||
S = colors.violet,
|
S = colors.violet,
|
||||||
[""] = colors.violet,
|
[''] = colors.violet,
|
||||||
ic = colors.yellow,
|
ic = colors.yellow,
|
||||||
cv = colors.red,
|
cv = colors.red,
|
||||||
ce = colors.red,
|
ce = colors.red,
|
||||||
r = colors.cyan,
|
r = colors.cyan,
|
||||||
rm = colors.cyan,
|
rm = colors.cyan,
|
||||||
["r?"] = colors.cyan,
|
['r?'] = colors.cyan,
|
||||||
["!"] = colors.red,
|
['!'] = colors.red,
|
||||||
}
|
}
|
||||||
|
|
||||||
local conditions = {
|
local conditions = {
|
||||||
buffer_not_empty = function()
|
buffer_not_empty = function()
|
||||||
return vim.fn.empty(vim.fn.expand("%:t")) ~= 1
|
return vim.fn.empty(vim.fn.expand('%:t')) ~= 1
|
||||||
end,
|
end,
|
||||||
buffer_is_file = function()
|
buffer_is_file = function()
|
||||||
return vim.bo.buftype == ""
|
return vim.bo.buftype == ''
|
||||||
end,
|
end,
|
||||||
buffer_not_scratch = function()
|
buffer_not_scratch = function()
|
||||||
return string.find(vim.fn.bufname(), "SCRATCH") == nil
|
return string.find(vim.fn.bufname(), 'SCRATCH') == nil
|
||||||
end,
|
end,
|
||||||
hide_in_width = function()
|
hide_in_width = function()
|
||||||
return vim.fn.winwidth(0) > 80
|
return vim.fn.winwidth(0) > 80
|
||||||
end,
|
end,
|
||||||
check_git_workspace = function()
|
check_git_workspace = function()
|
||||||
local filepath = vim.fn.expand("%:p:h")
|
local filepath = vim.fn.expand('%:p:h')
|
||||||
local gitdir = vim.fn.finddir(".git", filepath .. ";")
|
local gitdir = vim.fn.finddir('.git', filepath .. ';')
|
||||||
return gitdir and #gitdir > 0 and #gitdir < #filepath
|
return gitdir and #gitdir > 0 and #gitdir < #filepath
|
||||||
end,
|
end,
|
||||||
is_note = function()
|
is_note = function()
|
||||||
local notes_dir = vim.env.NOTES_DIR
|
local notes_dir = vim.env.NOTES_DIR
|
||||||
if not notes_dir then
|
if not notes_dir then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
local current_file = vim.fn.expand("%:p")
|
local current_file = vim.fn.expand('%:p')
|
||||||
return current_file:find(vim.fn.expand(notes_dir), 1, true) == 1
|
return current_file:find(vim.fn.expand(notes_dir), 1, true) == 1
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
local searchcount = { "searchcount", color = { fg = colors.fg, gui = "bold" } }
|
local searchcount = { 'searchcount', color = { fg = colors.fg, gui = 'bold' } }
|
||||||
local selectioncount = { "selectioncount", color = { fg = colors.fg, gui = "bold" } }
|
local selectioncount = { 'selectioncount', color = { fg = colors.fg, gui = 'bold' } }
|
||||||
local progress = { "progress", color = { fg = colors.fg, gui = "bold" } }
|
local progress = { 'progress', color = { fg = colors.fg, gui = 'bold' } }
|
||||||
local filetype = { "filetype", color = { fg = colors.blue, gui = "bold" } }
|
local filetype = { 'filetype', color = { fg = colors.blue, gui = 'bold' } }
|
||||||
local filesize = { "filesize", color = { fg = colors.fg, gui = "bold" }, cond = conditions.buffer_not_empty }
|
local filesize = { 'filesize', color = { fg = colors.fg, gui = 'bold' }, cond = conditions.buffer_not_empty }
|
||||||
local fileformat = { "fileformat", icons_enabled = true, color = { fg = colors.fg, gui = "bold" } }
|
local fileformat = { 'fileformat', icons_enabled = true, color = { fg = colors.fg, gui = 'bold' } }
|
||||||
|
|
||||||
local filename = {
|
local filename = {
|
||||||
"filename",
|
'filename',
|
||||||
cond = conditions.buffer_not_empty and conditions.buffer_is_file and conditions.buffer_not_scratch,
|
cond = conditions.buffer_not_empty and conditions.buffer_is_file and conditions.buffer_not_scratch,
|
||||||
color = { fg = colors.magenta, gui = "bold" },
|
color = { fg = colors.magenta, gui = 'bold' },
|
||||||
}
|
}
|
||||||
|
|
||||||
local buffers = {
|
local buffers = {
|
||||||
"buffers",
|
'buffers',
|
||||||
mode = 2,
|
mode = 2,
|
||||||
cond = conditions.buffer_not_scratch,
|
cond = conditions.buffer_not_scratch,
|
||||||
filetype_names = {
|
filetype_names = {
|
||||||
NvimTree = " " .. "Files",
|
NvimTree = ' ' .. 'Files',
|
||||||
TelescopePrompt = " " .. "Telescope",
|
TelescopePrompt = ' ' .. 'Telescope',
|
||||||
Avante = " " .. "Avante",
|
Avante = ' ' .. 'Avante',
|
||||||
AvanteInput = " " .. "Avante",
|
AvanteInput = ' ' .. 'Avante',
|
||||||
AvanteSelectedFiles = " " .. "Avante",
|
AvanteSelectedFiles = ' ' .. 'Avante',
|
||||||
dashboard = " " .. "Dashboard",
|
dashboard = ' ' .. 'Dashboard',
|
||||||
lazy = " " .. "Lazy",
|
lazy = ' ' .. 'Lazy',
|
||||||
mason = " " .. "Mason",
|
mason = ' ' .. 'Mason',
|
||||||
minifiles = " " .. "Files",
|
minifiles = ' ' .. 'Files',
|
||||||
snacks_picker_input = " " .. "Picker",
|
snacks_picker_input = ' ' .. 'Picker',
|
||||||
spectre_panel = " " .. "Spectre",
|
spectre_panel = ' ' .. 'Spectre',
|
||||||
},
|
},
|
||||||
use_mode_colors = true,
|
use_mode_colors = true,
|
||||||
}
|
}
|
||||||
|
|
||||||
local branch = {
|
local branch = {
|
||||||
"branch",
|
'branch',
|
||||||
icon = " ",
|
icon = ' ',
|
||||||
fmt = function(str)
|
fmt = function(str)
|
||||||
return str:sub(1, 32)
|
return str:sub(1, 32)
|
||||||
end,
|
end,
|
||||||
color = { fg = colors.green, gui = "bold" },
|
color = { fg = colors.green, gui = 'bold' },
|
||||||
}
|
}
|
||||||
|
|
||||||
local diff_icons = {
|
local diff_icons = {
|
||||||
"diff",
|
'diff',
|
||||||
symbols = { added = " ", modified = " ", removed = " " },
|
symbols = { added = ' ', modified = ' ', removed = ' ' },
|
||||||
diff_color = {
|
diff_color = {
|
||||||
added = { fg = colors.green },
|
added = { fg = colors.green },
|
||||||
modified = { fg = colors.orange },
|
modified = { fg = colors.orange },
|
||||||
removed = { fg = colors.red },
|
removed = { fg = colors.red },
|
||||||
},
|
},
|
||||||
cond = conditions.hide_in_width,
|
cond = conditions.hide_in_width,
|
||||||
}
|
}
|
||||||
|
|
||||||
local diagnostics = {
|
local diagnostics = {
|
||||||
"diagnostics",
|
'diagnostics',
|
||||||
sources = { "nvim_lsp", "nvim_diagnostic", "nvim_workspace_diagnostic" },
|
sources = { 'nvim_lsp', 'nvim_diagnostic', 'nvim_workspace_diagnostic' },
|
||||||
symbols = {
|
symbols = {
|
||||||
error = " ",
|
error = ' ',
|
||||||
warn = " ",
|
warn = ' ',
|
||||||
info = " ",
|
info = ' ',
|
||||||
hint = " ",
|
hint = ' ',
|
||||||
},
|
},
|
||||||
diagnostics_color = {
|
diagnostics_color = {
|
||||||
color_error = { fg = colors.red },
|
color_error = { fg = colors.red },
|
||||||
color_warn = { fg = colors.yellow },
|
color_warn = { fg = colors.yellow },
|
||||||
color_info = { fg = colors.blue },
|
color_info = { fg = colors.blue },
|
||||||
color_hint = { fg = colors.yellow },
|
color_hint = { fg = colors.yellow },
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
local lsp = {
|
local lsp = {
|
||||||
function()
|
function()
|
||||||
local msg = "No LSP"
|
local msg = 'No LSP'
|
||||||
local buf_ft = vim.api.nvim_get_option_value("filetype", { buf = 0 })
|
local buf_ft = vim.api.nvim_get_option_value('filetype', { buf = 0 })
|
||||||
local clients = vim.lsp.get_clients()
|
local clients = vim.lsp.get_clients()
|
||||||
if next(clients) == nil then
|
if next(clients) == nil then
|
||||||
return msg
|
return msg
|
||||||
end
|
end
|
||||||
for _, client in ipairs(clients) do
|
for _, client in ipairs(clients) do
|
||||||
local filetypes = client.config and client.config.filetypes or nil
|
local filetypes = client.config and client.config.filetypes or nil
|
||||||
if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then
|
if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then
|
||||||
return client.name
|
return client.name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return msg
|
return msg
|
||||||
end,
|
end,
|
||||||
icon = " ",
|
icon = ' ',
|
||||||
color = { fg = colors.fg, gui = "bold" },
|
color = { fg = colors.fg, gui = 'bold' },
|
||||||
}
|
}
|
||||||
|
|
||||||
local tdo = {
|
local encoding = {
|
||||||
function()
|
'o:encoding',
|
||||||
local update_frequency = 300
|
fmt = string.upper,
|
||||||
if not vim.g.tdo_last_update or (os.time() - vim.g.tdo_last_update) > update_frequency then
|
cond = conditions.hide_in_width,
|
||||||
vim.g.tdo_last_update = os.time()
|
color = { fg = colors.green, gui = 'bold' },
|
||||||
local result = vim.fn.system("tdo pending")
|
}
|
||||||
vim.g.tdo_count = tonumber(result:match("%d+")) or 0
|
|
||||||
end
|
|
||||||
return vim.g.tdo_count or 0
|
|
||||||
end,
|
|
||||||
icon = " ",
|
|
||||||
color = { fg = "#8BCD5B", gui = "bold" },
|
|
||||||
cond = conditions.is_note,
|
|
||||||
}
|
|
||||||
|
|
||||||
local encoding = {
|
local function mode(icon)
|
||||||
"o:encoding",
|
icon = icon or ' '
|
||||||
fmt = string.upper,
|
return {
|
||||||
cond = conditions.hide_in_width,
|
function()
|
||||||
color = { fg = colors.green, gui = "bold" },
|
return icon
|
||||||
}
|
end,
|
||||||
|
color = function()
|
||||||
|
return { fg = mode_color[vim.fn.mode()] }
|
||||||
|
end,
|
||||||
|
padding = { left = 1, right = 0 },
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
local function mode(icon)
|
-- Create custom gruvbox theme
|
||||||
icon = icon or " "
|
local function gruvbox_custom()
|
||||||
return {
|
local function accent_status(accent)
|
||||||
function()
|
return {
|
||||||
return icon
|
a = { bg = accent, fg = palette.dark0_hard },
|
||||||
end,
|
b = { bg = palette.dark1, fg = accent },
|
||||||
color = function()
|
c = { bg = palette.dark0, fg = palette.light1 },
|
||||||
return { fg = mode_color[vim.fn.mode()] }
|
}
|
||||||
end,
|
end
|
||||||
padding = { left = 1, right = 0 },
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Create custom gruvbox theme
|
return {
|
||||||
local function gruvbox_custom()
|
normal = accent_status(palette.bright_aqua),
|
||||||
local function accent_status(accent)
|
insert = accent_status(palette.bright_green),
|
||||||
return {
|
visual = accent_status(palette.bright_purple),
|
||||||
a = { bg = accent, fg = palette.dark0_hard },
|
replace = accent_status(palette.bright_yellow),
|
||||||
b = { bg = palette.dark1, fg = accent },
|
command = accent_status(palette.bright_orange),
|
||||||
c = { bg = palette.dark0, fg = palette.light1 },
|
inactive = {
|
||||||
}
|
a = { bg = palette.dark1, fg = palette.light4 },
|
||||||
end
|
b = { bg = palette.dark1, fg = palette.light4 },
|
||||||
|
c = { bg = palette.dark1, fg = palette.light4 },
|
||||||
|
},
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
return {
|
lualine.setup({
|
||||||
normal = accent_status(palette.bright_aqua),
|
options = {
|
||||||
insert = accent_status(palette.bright_green),
|
component_separators = '',
|
||||||
visual = accent_status(palette.bright_purple),
|
-- section_separators = '',
|
||||||
replace = accent_status(palette.bright_yellow),
|
theme = gruvbox_custom(),
|
||||||
command = accent_status(palette.bright_orange),
|
disabled_filetypes = {
|
||||||
inactive = {
|
'dashboard',
|
||||||
a = { bg = palette.dark1, fg = palette.light4 },
|
},
|
||||||
b = { bg = palette.dark1, fg = palette.light4 },
|
},
|
||||||
c = { bg = palette.dark1, fg = palette.light4 },
|
-- extensions = { 'quickfix', 'man', 'mason', 'lazy', 'toggleterm', 'nvim-tree' },
|
||||||
},
|
tabline = {
|
||||||
}
|
lualine_a = {},
|
||||||
end
|
lualine_b = { mode(), buffers },
|
||||||
|
lualine_c = {},
|
||||||
lualine.setup({
|
lualine_x = { diff_icons, branch },
|
||||||
options = {
|
lualine_y = { searchcount, selectioncount },
|
||||||
component_separators = "",
|
lualine_z = {},
|
||||||
-- section_separators = '',
|
},
|
||||||
theme = gruvbox_custom(),
|
sections = {
|
||||||
disabled_filetypes = {
|
lualine_a = {},
|
||||||
"dashboard",
|
lualine_b = {},
|
||||||
},
|
lualine_c = { mode(' '), 'location', progress, filename },
|
||||||
},
|
lualine_x = { diagnostics, lsp, filetype, filesize, fileformat, encoding },
|
||||||
-- extensions = { 'quickfix', 'man', 'mason', 'lazy', 'toggleterm', 'nvim-tree' },
|
lualine_y = {},
|
||||||
tabline = {
|
lualine_z = {},
|
||||||
lualine_a = {},
|
},
|
||||||
lualine_b = { mode(), tdo, buffers },
|
})
|
||||||
lualine_c = {},
|
end,
|
||||||
lualine_x = { diff_icons, branch },
|
|
||||||
lualine_y = { searchcount, selectioncount },
|
|
||||||
lualine_z = {},
|
|
||||||
},
|
|
||||||
sections = {
|
|
||||||
lualine_a = {},
|
|
||||||
lualine_b = {},
|
|
||||||
lualine_c = { mode(" "), "location", progress, filename },
|
|
||||||
lualine_x = { diagnostics, lsp, filetype, filesize, fileformat, encoding },
|
|
||||||
lualine_y = {},
|
|
||||||
lualine_z = {},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user