-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathinit.lua
194 lines (183 loc) · 4.91 KB
/
init.lua
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
-- Feline statusline definition.
--
-- Note: This statusline does not define any colors. Instead the statusline is
-- built on custom highlight groups that I define. The colors for these
-- highlight groups are pulled from the current colorscheme applied. Check the
-- file: `lua/eden/modules/ui/colors.lua` to see how they are defined.
local u = require("eden.modules.ui.feline.util")
local fmt = string.format
-- "┃", "█", "", "", "", "", "", "", "●"
local get_diag = function(str)
local count = vim.lsp.diagnostic.get_count(0, str)
return (count > 0) and " " .. count .. " " or ""
end
local function vi_mode_hl()
return u.vi.colors[vim.fn.mode()] or "FlnViBlack"
end
local function vi_sep_hl()
return u.vi.sep[vim.fn.mode()] or "FlnBlack"
end
local c = {
vimode = {
provider = function()
return string.format(" %s ", u.vi.text[vim.fn.mode()])
end,
hl = vi_mode_hl,
right_sep = { str = " ", hl = vi_sep_hl },
},
gitbranch = {
provider = "git_branch",
icon = " ",
hl = "FlnGitBranch",
right_sep = { str = " ", hl = "FlnGitBranch" },
enabled = function()
return vim.b.gitsigns_status_dict ~= nil
end,
},
file_type = {
provider = function()
return fmt(" %s ", vim.bo.filetype:upper())
end,
hl = "FlnAlt",
},
fileinfo = {
provider = { name = "file_info", opts = { type = "relative" } },
hl = "FlnAlt",
left_sep = { str = " ", hl = "FlnAltSep" },
right_sep = { str = "", hl = "FlnAltSep" },
},
file_enc = {
provider = function()
local os = u.icons[vim.bo.fileformat] or ""
return fmt(" %s %s ", os, vim.bo.fileencoding)
end,
hl = "StatusLine",
left_sep = { str = u.icons.left_filled, hl = "FlnAltSep" },
},
cur_position = {
provider = function()
-- TODO: What about 4+ diget line numbers?
return fmt(" %3d:%-2d ", unpack(vim.api.nvim_win_get_cursor(0)))
end,
hl = vi_mode_hl,
left_sep = { str = u.icons.left_filled, hl = vi_sep_hl },
},
cur_percent = {
provider = function()
return " " .. require("feline.providers.cursor").line_percentage() .. " "
end,
hl = vi_mode_hl,
left_sep = { str = u.icons.left, hl = vi_mode_hl },
},
default = { -- needed to pass the parent StatusLine hl group to right hand side
provider = "",
hl = "StatusLine",
},
lsp_status = {
provider = function()
return require("lsp-status").status()
end,
hl = "FlnStatus",
left_sep = { str = "", hl = "FlnStatusBg", always_visible = true },
right_sep = { str = "", hl = "FlnErrorStatus", always_visible = true },
},
lsp_error = {
provider = function()
return get_diag("Error")
end,
hl = "FlnError",
right_sep = { str = "", hl = "FlnWarnError", always_visible = true },
},
lsp_warn = {
provider = function()
return get_diag("Warning")
end,
hl = "FlnWarn",
right_sep = { str = "", hl = "FlnInfoWarn", always_visible = true },
},
lsp_info = {
provider = function()
return get_diag("Information")
end,
hl = "FlnInfo",
right_sep = { str = "", hl = "FlnHintInfo", always_visible = true },
},
lsp_hint = {
provider = function()
return get_diag("Hint")
end,
hl = "FlnHint",
right_sep = { str = "", hl = "FlnBgHint", always_visible = true },
},
in_fileinfo = {
provider = "file_info",
hl = "StatusLine",
},
in_position = {
provider = "position",
hl = "StatusLine",
},
}
local active = {
{ -- left
c.vimode,
c.gitbranch,
c.fileinfo,
c.default, -- must be last
},
{ -- right
c.lsp_status,
c.lsp_error,
c.lsp_warn,
c.lsp_info,
c.lsp_hint,
c.file_type,
c.file_enc,
c.cur_position,
c.cur_percent,
},
}
local inactive = {
{ c.in_fileinfo }, -- left
{ c.in_position }, -- right
}
-- -- Define autocmd that generates the highlight groups from the new colorscheme
-- -- Then reset the highlights for feline
-- edn.aug.FelineColorschemeReload = {
-- {
-- { "SessionLoadPost", "ColorScheme" },
-- function()
-- require("eden.modules.ui.feline.colors").gen_highlights()
-- -- This does not look like it is required. If this is called I see the ^^^^^^ that
-- -- seperates the two sides of the bar. Since the entire config uses highlight groups
-- -- all that is required is to redefine them.
-- -- require("feline").reset_highlights()
-- end,
-- },
-- }
require("feline").setup({
components = { active = active, inactive = inactive },
highlight_reset_triggers = {},
force_inactive = {
filetypes = {
"NvimTree",
"packer",
"dap-repl",
"dapui_scopes",
"dapui_stacks",
"dapui_watches",
"dapui_repl",
"LspTrouble",
"qf",
"help",
},
buftypes = { "terminal" },
bufnames = {},
},
disable = {
filetypes = {
"dashboard",
"startify",
},
},
})