1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
local M = {
"nvim-lualine/lualine.nvim",
dependencies = {
"kyazdani42/nvim-web-devicons",
"SmiteshP/nvim-navic",
},
}
function M.config()
local lualine = require("lualine")
local utils = require("tobyvin.utils")
local get_short_cwd = function()
return vim.fn.fnamemodify(vim.fn.getcwd(), ":~")
end
local to_char = function(str)
return str:sub(1, 1)
end
local winbar_cond = function()
return vim.bo.buflisted
end
local git = {
"branch",
{
"diff",
source = function()
local gitsigns = vim.b["gitsigns_status_dict"]
if gitsigns then
return {
added = gitsigns.added,
modified = gitsigns.changed,
removed = gitsigns.removed,
}
end
end,
padding = { left = 0, right = 1 },
},
}
local workspace = {
{
function()
return utils.diagnostic
.indicator(nil)
:gsub("DiagnosticSignError", "lualine_b_diagnostics_error_normal")
:gsub("DiagnosticSignWarn", "lualine_b_diagnostics_warn_normal")
:gsub("DiagnosticSignInfo", "lualine_b_diagnostics_info_normal")
:gsub("DiagnosticSignHint", "lualine_b_diagnostics_hint_normal")
end,
padding = { left = 1, right = 0 },
color = "StatusLineNC",
},
{
"filename",
path = 1,
},
}
local buffer = {
{
"filename",
color = "WinBar",
cond = winbar_cond,
},
{
"diagnostics",
source = { utils.diagnostic.buf_count },
symbols = {
error = utils.diagnostic.signs.error.text,
warn = utils.diagnostic.signs.warn.text,
info = utils.diagnostic.signs.info.text,
hint = utils.diagnostic.signs.hint.text,
},
update_in_insert = true,
color = "WinBar",
padding = { left = 0, right = 1 },
cond = winbar_cond,
},
}
lualine.setup({
options = {
component_separators = "",
section_separators = "",
disabled_filetypes = {
"netrw",
"alpha",
winbar = vim.fn.getcompletion("Neogit*", "filetype"),
},
},
sections = {
lualine_a = { { "mode", fmt = to_char } },
lualine_b = git,
lualine_c = workspace,
lualine_x = {
"encoding",
"fileformat",
"filetype",
},
},
inactive_sections = {
lualine_c = { "filename" },
lualine_x = {
"filetype",
"location",
},
},
winbar = {
lualine_b = buffer,
lualine_c = {
{
-- Hack to prevent lualine_b from taking over the lualine_c when navic has no results
function()
return require("nvim-navic").get_location():gsub("^$", " ")
end,
color = "WinBarNC",
cond = winbar_cond,
},
},
},
tabline = {
lualine_b = { { "buffers", mode = 4 } },
lualine_y = { "tabs" },
},
extensions = {
"fzf",
"man",
"nvim-dap-ui",
"symbols-outline",
"quickfix",
"toggleterm",
{
sections = {
lualine_c = {
get_short_cwd,
},
},
filetypes = {
"netrw",
},
},
},
})
end
return M
|