nvim1/lua/plugins/lualine.lua

142 lines
2.9 KiB
Lua

return {
"nvim-lualine/lualine.nvim",
event = "VeryLazy",
init = function()
vim.g.lualine_laststatus = vim.o.laststatus
if vim.fn.argc(-1) > 0 then
vim.o.statusline = " "
else
vim.o.laststatus = 0
end
end,
opts = function()
local lualine = require("lualine")
local conditions = {
buffer_not_empty = function() return vim.fn.empty(vim.fn.expand("%:t")) ~= 1 end,
hide_in_width = function() return vim.fn.winwidth(0) > 80 end,
check_git_workspace = function()
local filepath = vim.fn.expand("%:p:h")
local gitdir = vim.fn.finddir(".git", filepath .. ";")
return gitdir and #gitdir > 0 and #gitdir < #filepath
end,
}
-- Config
local config = {
options = {
component_separators = "",
section_separators = "",
theme = "auto",
},
sections = {
-- these are to remove the defaults
lualine_a = {},
lualine_b = {},
lualine_y = {},
lualine_z = {},
-- These will be filled later
lualine_c = {},
lualine_x = {},
},
inactive_sections = {
-- these are to remove the defaults
lualine_a = {},
lualine_b = {},
lualine_y = {},
lualine_z = {},
lualine_c = {},
lualine_x = {},
},
}
-- Inserts a component in lualine_c at left section
local function ins_left(component) table.insert(config.sections.lualine_c, component) end
-- Inserts a component in lualine_x ot right section
local function ins_right(component) table.insert(config.sections.lualine_x, component) end
ins_left({
-- mode component
function() return "" end,
})
ins_left({
"filename",
cond = conditions.buffer_not_empty,
})
ins_left({
"branch",
icon = "",
})
ins_left({
"diff",
-- Is it me or the symbol for modified us really weird
symbols = {
added = "",
modified = "",
removed = "",
},
cond = conditions.hide_in_width,
})
-- Insert mid section. You can make any number of sections in neovim :)
-- for lualine it"s any number greater then 2
ins_left({
function() return "%=" end,
})
ins_right({
-- Lsp server name .
function()
local msg = "null"
local clients = vim.lsp.get_clients()
if next(clients) == nil then return msg end
local client_names = {}
for _, client in ipairs(clients) do
table.insert(client_names, client.name)
end
return table.concat(client_names, ",")
end,
icon = " LSP:",
})
ins_right({
"diagnostics",
sources = { "nvim_diagnostic" },
symbols = {
error = "",
warn = "",
info = "",
hints = "󰛩 ",
},
always_visible = true,
})
ins_right({
"o:encoding", -- option component same as &encoding in viml
fmt = string.upper,
cond = conditions.hide_in_width,
})
ins_right({
"fileformat",
fmt = string.upper,
icons_enabled = true,
})
ins_right({
"location",
})
ins_right({
"progress",
})
-- Now don"t forget to initialize lualine
lualine.setup(config)
end,
}