Skip to content

Commit 6504388

Browse files
committed
style: 💅 lualine refactor
1 parent 323bcee commit 6504388

1 file changed

Lines changed: 69 additions & 96 deletions

File tree

Lines changed: 69 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,107 +1,80 @@
11
return {
22
"nvim-lualine/lualine.nvim",
3-
event = "BufReadPost",
4-
opts = {
5-
extensions = { "fzf", "lazy", "mason", "quickfix", "neo-tree" },
6-
options = {
7-
disabled_filetypes = { "neo-tree", "snacks_dashboard", "Outline" },
8-
},
9-
sections = {
10-
lualine_a = {}, -- hide mode
11-
lualine_b = {
12-
"branch",
13-
"diff",
14-
"diagnostics",
15-
},
16-
lualine_c = {
17-
{
18-
"filename",
19-
file_status = true, -- Displays file status (readonly status, modified status)
20-
newfile_status = true, -- Display new file status (new file means no write after created)
21-
path = 3, -- 0: Just the filename
22-
-- 1: Relative path
23-
-- 2: Absolute path
24-
-- 3: Absolute path, with tilde as the home directory
25-
-- 4: Filename and parent dir, with tilde as the home directory
26-
},
27-
},
28-
lualine_x = { "filetype" },
29-
lualine_y = { "progress" },
30-
lualine_z = { "mode" },
31-
},
32-
},
33-
config = function(_, opts)
34-
-- Show info when recording a macro
35-
local function is_macro_recording()
36-
local reg = vim.fn.reg_recording()
37-
if reg == "" then
3+
dependencies = { "nvim-tree/nvim-web-devicons" },
4+
event = "VeryLazy",
5+
config = function()
6+
-- Custom Lualine component to show attached language server
7+
local clients_lsp = function()
8+
local clients = vim.lsp.get_clients()
9+
if next(clients) == nil then
3810
return ""
3911
end
40-
return "󰑋 " .. reg
41-
end
4212

43-
table.insert(opts.sections.lualine_x, 1, {
44-
is_macro_recording,
45-
color = { fg = "#333333", bg = "#ff6666" },
46-
separator = { left = "", right = "" },
47-
cond = function()
48-
return is_macro_recording() ~= ""
49-
end,
50-
})
51-
52-
-- Don't display encoding if encoding is UTF-8
53-
local function encoding()
54-
local ret, _ = (vim.bo.fenc or vim.go.enc):gsub("^utf%-8$", "")
55-
return ret
56-
end
57-
58-
table.insert(opts.sections.lualine_x, 1, {
59-
encoding,
60-
cond = function()
61-
return encoding() ~= ""
62-
end,
63-
})
64-
65-
-- Don't display fileformat if fileformat is unix
66-
local function fileformat()
67-
local ret, _ = vim.bo.fileformat:gsub("^unix$", "")
68-
return ret
69-
end
70-
71-
table.insert(opts.sections.lualine_x, 1, {
72-
fileformat,
73-
cond = function()
74-
return fileformat() ~= ""
75-
end,
76-
})
77-
78-
local function wordCount()
79-
local wc = vim.fn.wordcount()
80-
if wc == nil then
81-
return ""
82-
end
83-
if wc["visual_words"] then -- text is selected in visual mode
84-
return wc["visual_words"] .. " Words/" .. wc["visual_chars"] .. " Chars (Vis)"
85-
else -- all of the document
86-
return wc["words"] .. " Words"
13+
local c = {}
14+
for _, client in pairs(clients) do
15+
table.insert(c, client.name)
8716
end
17+
return "" .. table.concat(c, "|")
8818
end
8919

90-
table.insert(opts.sections.lualine_y, 1, {
91-
wordCount,
92-
cond = function()
93-
local ft = vim.bo.filetype
94-
local count = {
95-
latex = true,
96-
tex = true,
97-
text = true,
98-
markdown = true,
99-
vimwiki = true,
100-
}
101-
return count[ft] ~= nil
102-
end,
20+
require("lualine").setup({
21+
options = {
22+
component_separators = "",
23+
section_separators = { left = "", right = "" },
24+
disabled_filetypes = { "alpha", "Outline", "snacks_dashboard" },
25+
},
26+
sections = {
27+
lualine_a = {
28+
{ "mode", icon = "" },
29+
},
30+
lualine_b = {
31+
{
32+
"filetype",
33+
icon_only = true,
34+
padding = { left = 1, right = 0 },
35+
},
36+
{
37+
"filename",
38+
path = 0, -- 0: Just the filename, 1: Relative path, 2: Absolute path
39+
symbols = { modified = "", readonly = "" },
40+
},
41+
},
42+
lualine_c = {
43+
{
44+
"branch",
45+
icon = "",
46+
},
47+
{
48+
"diff",
49+
symbols = { added = "", modified = "", removed = "" },
50+
colored = true,
51+
},
52+
},
53+
lualine_x = {
54+
{
55+
"diagnostics",
56+
symbols = { error = "", warn = "", info = "", hint = "" },
57+
update_in_insert = true,
58+
},
59+
},
60+
lualine_y = { clients_lsp },
61+
lualine_z = {
62+
{ "location", icon = "" },
63+
},
64+
},
65+
inactive_sections = {
66+
lualine_a = { "filename" },
67+
lualine_b = {},
68+
lualine_c = {},
69+
lualine_x = {},
70+
lualine_y = {},
71+
lualine_z = { "location" },
72+
},
73+
extensions = { "toggleterm", "trouble" },
10374
})
104-
105-
require("lualine").setup(opts)
75+
vim.api.nvim_set_hl(0, "lualine_a_visual", { fg = "#000000", bg = "#dc4c44", bold = true })
76+
vim.api.nvim_set_hl(0, "lualine_a_replace", { fg = "#000000", bg = "#dc4c44", bold = true })
77+
vim.api.nvim_set_hl(0, "lualine_a_command", { fg = "#000000", bg = "#f9e2af", bold = true })
78+
vim.api.nvim_set_hl(0, "lualine_a_insert", { fg = "#000000", bg = "#a6e3a1", bold = true })
10679
end,
10780
}

0 commit comments

Comments
 (0)