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