tangled
alpha
login
or
join now
robinwobin.dev
/
lylla.nvim
3
fork
atom
🪴 a tiny, customizable statusline for neovim
3
fork
atom
overview
issues
pulls
pipelines
doc: add README
robin
7 months ago
fc672e4c
d7b4560d
+263
1 changed file
expand all
collapse all
unified
split
README.md
+263
README.md
reviewed
···
1
1
+
# lylla.nvim
2
2
+
3
3
+
a minimal statusline plugin for neovim with extensive configuration; simple by default, flexible if needed.
4
4
+
5
5
+
## features
6
6
+
7
7
+
- minimal default look, based on neovim default statusline implementation
8
8
+
- flexible configuration; define your own components
9
9
+
- lightweight design; no required dependencies
10
10
+
11
11
+
## goals
12
12
+
13
13
+
lylla is designed to be:
14
14
+
15
15
+
- minimal in features (no clutter)
16
16
+
- maximal in configuration
17
17
+
- stable and predictable; i wanted to prevent any hidden logic that i got
18
18
+
annoyed by in other statusline plugins
19
19
+
20
20
+
## installation
21
21
+
22
22
+
###### `vim.pack`
23
23
+
24
24
+
```lua
25
25
+
vim.pack.add({ src = "comfysage/lylla.nvim" })
26
26
+
```
27
27
+
28
28
+
###### `lazy.nvim`
29
29
+
30
30
+
```lua
31
31
+
{
32
32
+
"comfysage/lylla.nvim", lazy = false,
33
33
+
}
34
34
+
```
35
35
+
36
36
+
### dependencies
37
37
+
38
38
+
some of the utilities included in lylla use
39
39
+
[mini.nvim](https://github.com/mini-nvim/mini.nvim) but these are not required
40
40
+
in the default implementation.
41
41
+
42
42
+
## configuration
43
43
+
44
44
+
the default configuration is as follows:
45
45
+
46
46
+
```lua
47
47
+
require("lylla").setup({
48
48
+
refresh_rate = 300,
49
49
+
events = {
50
50
+
"WinEnter",
51
51
+
"BufEnter",
52
52
+
"BufWritePost",
53
53
+
"SessionLoadPost",
54
54
+
"FileChangedShellPost",
55
55
+
"VimResized",
56
56
+
"Filetype",
57
57
+
"CursorMoved",
58
58
+
"CursorMovedI",
59
59
+
"ModeChanged",
60
60
+
"CmdlineEnter",
61
61
+
},
62
62
+
hls = {},
63
63
+
modules = {
64
64
+
"%<%f %h%w%m%r",
65
65
+
"%=",
66
66
+
{
67
67
+
fn = function()
68
68
+
if vim.o.showcmdloc == "statusline" then
69
69
+
return "%-10.S"
70
70
+
end
71
71
+
return ""
72
72
+
end,
73
73
+
},
74
74
+
{ " " },
75
75
+
{
76
76
+
fn = function()
77
77
+
if not vim.b.keymap_name then
78
78
+
return ""
79
79
+
end
80
80
+
return "<" .. vim.b.keymap_name .. ">"
81
81
+
end,
82
82
+
},
83
83
+
{ " " },
84
84
+
{
85
85
+
fn = function()
86
86
+
if vim.bo.busy > 0 then
87
87
+
return "◐ "
88
88
+
end
89
89
+
return ""
90
90
+
end,
91
91
+
},
92
92
+
{ " " },
93
93
+
{
94
94
+
fn = function()
95
95
+
if not package.loaded["vim.diagnostic"] then
96
96
+
return ""
97
97
+
end
98
98
+
return vim.diagnostic.status()
99
99
+
end,
100
100
+
opts = {
101
101
+
events = { "DiagnosticChanged" },
102
102
+
},
103
103
+
},
104
104
+
{ " " },
105
105
+
{
106
106
+
fn = function()
107
107
+
if not vim.o.ruler then
108
108
+
return ""
109
109
+
end
110
110
+
if vim.o.rulerformat == "" then
111
111
+
return "%-14.(%l,%c%V%) %P"
112
112
+
end
113
113
+
return vim.o.rulerformat
114
114
+
end,
115
115
+
},
116
116
+
},
117
117
+
winbar = {},
118
118
+
})
119
119
+
```
120
120
+
121
121
+
### example configuration
122
122
+
123
123
+
#### use `mini.icons` for colors
124
124
+
125
125
+
some nice highlights that i personally use:
126
126
+
127
127
+
```lua
128
128
+
hls = {
129
129
+
normal = { link = "MiniIconsAzure" },
130
130
+
visual = { link = "MiniIconsPurple" },
131
131
+
command = { link = "MiniIconsOrange" },
132
132
+
insert = { link = "MiniIconsGrey" },
133
133
+
},
134
134
+
```
135
135
+
136
136
+
### example components
137
137
+
138
138
+
you can define custom components by passing lua functions:
139
139
+
140
140
+
```lua
141
141
+
local lylla = require("lylla")
142
142
+
143
143
+
lylla.setup({
144
144
+
modules = {
145
145
+
lylla.component(function()
146
146
+
return "hi " .. vim.env.USER
147
147
+
end, { events = { "VimEnter" } }),
148
148
+
},
149
149
+
})
150
150
+
```
151
151
+
152
152
+
components return strings to be shown in the statusline and can register
153
153
+
autocmds to refresh them.
154
154
+
155
155
+
components can also return a tuple combining text with a highlight group:
156
156
+
157
157
+
```lua
158
158
+
{
159
159
+
{
160
160
+
{ "meow", "ModeMsg" },
161
161
+
{ " | ", "WinSeparator" },
162
162
+
},
163
163
+
{ fn = function() return { vim.bo.filetype, "MsgArea" } end },
164
164
+
}
165
165
+
```
166
166
+
167
167
+
these tables can be nested to any amount; they all get folded down on refresh.
168
168
+
169
169
+
### change refresh rate and events
170
170
+
171
171
+
```lua
172
172
+
require("lylla").setup {
173
173
+
refresh_rate = 100, -- update faster
174
174
+
events = { "WinEnter", "BufEnter", "CursorMoved" }, -- only update on these
175
175
+
}
176
176
+
```
177
177
+
178
178
+
(events control when the statusline is redrawn)
179
179
+
180
180
+
### add a custom module
181
181
+
182
182
+
modules are just tables that return strings.
183
183
+
this example shows your current working directory:
184
184
+
185
185
+
```lua
186
186
+
local lylla = require("lylla")
187
187
+
188
188
+
lylla.setup {
189
189
+
modules = {
190
190
+
"%<%f %h%w%m%r", -- filename etc
191
191
+
"%=", -- spacer
192
192
+
{
193
193
+
fn = function()
194
194
+
return vim.fn.fnamemodify(vim.fn.getcwd(), ":t")
195
195
+
end, opts = {
196
196
+
events = { "DirChanged" },
197
197
+
},
198
198
+
},
199
199
+
},
200
200
+
}
201
201
+
```
202
202
+
203
203
+
### conditional modules
204
204
+
205
205
+
modules can react to options, buffers, or plugins.
206
206
+
example: only show diagnostics if `vim.diagnostic` is loaded:
207
207
+
208
208
+
```lua
209
209
+
{
210
210
+
lylla.component(function()
211
211
+
if not package.loaded["vim.diagnostic"] then
212
212
+
return ""
213
213
+
end
214
214
+
return vim.diagnostic.status()
215
215
+
end, { events = { "DiagnosticChanged" } }),
216
216
+
}
217
217
+
```
218
218
+
219
219
+
### lsp information
220
220
+
221
221
+
lylla utils has a builtin helper for getting the current lsp client.
222
222
+
223
223
+
```lua
224
224
+
local utils = require("lylla.utils")
225
225
+
226
226
+
{
227
227
+
lylla.component(function()
228
228
+
local client = utils.get_client()
229
229
+
return client and {
230
230
+
{ { "lsp :: " }, { client } },
231
231
+
}
232
232
+
end, { events = { "FileType" } }),
233
233
+
}
234
234
+
```
235
235
+
236
236
+
### winbar
237
237
+
238
238
+
the winbar can be configured in the same way as the statusline:
239
239
+
240
240
+
```lua
241
241
+
winbar = {
242
242
+
lylla.component(function()
243
243
+
return {
244
244
+
utils.getfilepath(),
245
245
+
utils.getfilename(),
246
246
+
{ " " },
247
247
+
"%h%w%m%r",
248
248
+
}
249
249
+
end, {
250
250
+
events = {
251
251
+
"WinEnter",
252
252
+
"BufEnter",
253
253
+
"BufWritePost",
254
254
+
"FileChangedShellPost",
255
255
+
"Filetype",
256
256
+
},
257
257
+
}),
258
258
+
{ " " },
259
259
+
lylla.component(function()
260
260
+
return utils.get_searchcount()
261
261
+
end),
262
262
+
},
263
263
+
```