refactor custom components
This commit is contained in:
@@ -1,13 +1,13 @@
|
|||||||
return {
|
return {
|
||||||
"nvim-lualine/lualine.nvim",
|
'nvim-lualine/lualine.nvim',
|
||||||
dependencies = {
|
dependencies = {
|
||||||
"nvim-tree/nvim-web-devicons",
|
'nvim-tree/nvim-web-devicons',
|
||||||
"rmehri01/onenord.nvim",
|
'rmehri01/onenord.nvim',
|
||||||
},
|
},
|
||||||
event = "VeryLazy",
|
event = 'VeryLazy',
|
||||||
config = function()
|
config = function()
|
||||||
local lualine = require("lualine")
|
local lualine = require('lualine')
|
||||||
local lazy_status = require("lazy.status")
|
local lazy_status = require('lazy.status')
|
||||||
|
|
||||||
local custom_components = {
|
local custom_components = {
|
||||||
-- ┌
|
-- ┌
|
||||||
@@ -15,7 +15,7 @@ return {
|
|||||||
-- │ from https://github.com/wookayin/dotfiles/blob/master/nvim/lua/config/statusline.lua
|
-- │ from https://github.com/wookayin/dotfiles/blob/master/nvim/lua/config/statusline.lua
|
||||||
-- └
|
-- └
|
||||||
encoding = function()
|
encoding = function()
|
||||||
local ret, _ = (vim.bo.fenc or vim.go.enc):gsub("^utf%-8$", "")
|
local ret, _ = (vim.bo.fenc or vim.go.enc):gsub('^utf%-8$', '')
|
||||||
return ret
|
return ret
|
||||||
end,
|
end,
|
||||||
|
|
||||||
@@ -24,12 +24,25 @@ return {
|
|||||||
-- │ from https://github.com/wookayin/dotfiles/blob/master/nvim/lua/config/statusline.lua
|
-- │ from https://github.com/wookayin/dotfiles/blob/master/nvim/lua/config/statusline.lua
|
||||||
-- └
|
-- └
|
||||||
fileformat = function()
|
fileformat = function()
|
||||||
local ret, _ = vim.bo.fileformat:gsub("^unix$", "")
|
local ret, _ = vim.bo.fileformat:gsub('^unix$', '')
|
||||||
return ret
|
return ret
|
||||||
end,
|
end,
|
||||||
}
|
|
||||||
|
|
||||||
local function gitsigns_diff()
|
-- ┌
|
||||||
|
-- │ get width of current window
|
||||||
|
-- │ from https://github.com/wookayin/dotfiles/blob/master/nvim/lua/config/statusline.lua
|
||||||
|
-- └
|
||||||
|
min_window_width = function(width)
|
||||||
|
return function()
|
||||||
|
return vim.fn.winwidth(0) > width
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
|
||||||
|
-- ┌
|
||||||
|
-- │ get diff for current buffer from gitsigns
|
||||||
|
-- │ doing this for yadm integration from gitsigns
|
||||||
|
-- └
|
||||||
|
gitsigns_diff = function()
|
||||||
local gitsigns = vim.b.gitsigns_status_dict
|
local gitsigns = vim.b.gitsigns_status_dict
|
||||||
if gitsigns then
|
if gitsigns then
|
||||||
return {
|
return {
|
||||||
@@ -38,19 +51,20 @@ return {
|
|||||||
removed = gitsigns.removed,
|
removed = gitsigns.removed,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end,
|
||||||
|
}
|
||||||
|
|
||||||
lualine.setup({
|
lualine.setup({
|
||||||
options = {
|
options = {
|
||||||
icons_enabled = true,
|
icons_enabled = true,
|
||||||
theme = "onenord",
|
theme = 'onenord',
|
||||||
component_separators = { left = "", right = "" },
|
component_separators = { left = '', right = '' },
|
||||||
section_separators = { left = "", right = "" },
|
section_separators = { left = '', right = '' },
|
||||||
disabled_filetypes = {
|
disabled_filetypes = {
|
||||||
statusline = { "alpha", "dashboard", "Outline" },
|
statusline = { 'alpha', 'dashboard', 'Outline' },
|
||||||
winbar = {},
|
winbar = {},
|
||||||
},
|
},
|
||||||
ignore_focus = { "NvimTree" },
|
ignore_focus = { 'NvimTree' },
|
||||||
always_divide_middle = true,
|
always_divide_middle = true,
|
||||||
always_show_tabline = true,
|
always_show_tabline = true,
|
||||||
globalstatus = false,
|
globalstatus = false,
|
||||||
@@ -61,74 +75,79 @@ return {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
sections = {
|
sections = {
|
||||||
lualine_a = { "mode" },
|
lualine_a = { 'mode', { cond = custom_components.min_window_width(40) } },
|
||||||
lualine_b = {
|
lualine_b = {
|
||||||
{
|
{
|
||||||
"filename",
|
'filename',
|
||||||
file_status = true,
|
file_status = true,
|
||||||
newfile_status = true,
|
newfile_status = true,
|
||||||
path = 4,
|
path = 4,
|
||||||
symbols = {
|
symbols = {
|
||||||
modified = "[+]",
|
modified = '[+]',
|
||||||
readonly = "[-]",
|
readonly = '[-]',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
lualine_c = {
|
lualine_c = {
|
||||||
"branch",
|
'branch',
|
||||||
-- TODO: make it prettier...
|
{
|
||||||
{ "b:gitsigns_head", icon = "" },
|
'b:gitsigns_head',
|
||||||
{ "diff", source = gitsigns_diff },
|
icon = '',
|
||||||
|
color = { fg = '#9bcb8b' },
|
||||||
|
{ cond = custom_components.min_window_width(120) },
|
||||||
|
},
|
||||||
|
{ 'diff', source = custom_components.gitsigns_diff },
|
||||||
},
|
},
|
||||||
lualine_x = {
|
lualine_x = {
|
||||||
-- TODO: spell indicator (when on)
|
-- TODO: spell indicator (when on)
|
||||||
-- TODO: LSP
|
-- TODO: LSP
|
||||||
|
-- TODO: macro indicator
|
||||||
{
|
{
|
||||||
"diagnostics",
|
'diagnostics',
|
||||||
sources = { "nvim_workspace_diagnostic" },
|
sources = { 'nvim_workspace_diagnostic' },
|
||||||
sections = { "error", "warn", "info", "hint" },
|
sections = { 'error', 'warn', 'info', 'hint' },
|
||||||
--symbols = { error = " ", warn = " ", info = " ", hint = " " },
|
--symbols = { error = " ", warn = " ", info = " ", hint = " " },
|
||||||
colored = true,
|
colored = true,
|
||||||
always_visible = false,
|
always_visible = false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
lazy_status.updates,
|
lazy_status.updates,
|
||||||
cond = lazy_status.has_updates,
|
{ { cond = lazy_status.has_updates and custom_components.min_window_width(120) } },
|
||||||
color = { fg = "#ebcb8b" },
|
color = { fg = '#ebcb8b' },
|
||||||
},
|
},
|
||||||
-- {
|
-- {
|
||||||
-- function()
|
-- function()
|
||||||
-- return require("auto-session.lib").current_session_name(true)
|
-- return require("auto-session.lib").current_session_name(true)
|
||||||
-- end,
|
-- end,
|
||||||
-- },
|
-- },
|
||||||
{ custom_components.encoding },
|
{ custom_components.encoding, { cond = custom_components.min_window_width(120) } },
|
||||||
{ custom_components.fileformat },
|
{ custom_components.fileformat, { cond = custom_components.min_window_width(120) } },
|
||||||
"filetype",
|
'filetype',
|
||||||
},
|
},
|
||||||
lualine_y = { "searchcount", "progress" },
|
lualine_y = { 'searchcount', 'progress' },
|
||||||
lualine_z = { "selectioncount", "location" },
|
lualine_z = { 'selectioncount', 'location' },
|
||||||
},
|
},
|
||||||
inactive_sections = {
|
inactive_sections = {
|
||||||
lualine_a = {},
|
lualine_a = {},
|
||||||
lualine_b = {},
|
lualine_b = {},
|
||||||
lualine_c = { "filename" },
|
lualine_c = { 'filename' },
|
||||||
lualine_x = {
|
lualine_x = {
|
||||||
{
|
{
|
||||||
"diagnostics",
|
'diagnostics',
|
||||||
sources = { "nvim_lsp", "nvim_workspace_diagnostic", "nvim_diagnostic" },
|
sources = { 'nvim_lsp', 'nvim_workspace_diagnostic', 'nvim_diagnostic' },
|
||||||
sections = { "error", "warn", "info", "hint" },
|
sections = { 'error', 'warn', 'info', 'hint' },
|
||||||
--symbols = { error = " ", warn = " ", info = " ", hint = " " },
|
--symbols = { error = " ", warn = " ", info = " ", hint = " " },
|
||||||
colored = false,
|
colored = false,
|
||||||
always_visible = false,
|
always_visible = false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
lualine_y = {},
|
lualine_y = {},
|
||||||
lualine_z = { "location" },
|
lualine_z = { 'location' },
|
||||||
},
|
},
|
||||||
tabline = {},
|
tabline = {},
|
||||||
winbar = {},
|
winbar = {},
|
||||||
inactive_winbar = {},
|
inactive_winbar = {},
|
||||||
extensions = { "nvim-tree", "lazy", "trouble", "quickfix", "fzf", "mason" },
|
extensions = { 'nvim-tree', 'lazy', 'trouble', 'quickfix', 'fzf', 'mason' },
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user