- Notifications
You must be signed in to change notification settings - Fork3
Another statusline ? - this statusline is a personal pursuit in a less bloated option
License
leath-dub/stat.nvim
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Another statusline ? - this statusline is a personal pursuit in a less bloatedoption.
Currently it is ~ 300 LOC long. This makes it a less daunting read as it isvery simple, feel free to use this as a base for your own statusline or plugin.
Laziness was the big motivator for this project, I could not be botheredreading the source of a standard statusline plugin these days.
default config:
- winbar and statusline customization
- allows low level customization ( for those who have their own custom statusline )
- abstraction over highlight groups ( the theme )
- NEW lualine theme support - seeThemes
Refer to your plugin manager ( I recommenddep )
NOTE you should probably make sure that you callsetup()
after yourcolorscheme plugin is loaded ( you can add stat.nvim it as a dependency of yourcolorscheme in your prefered plugin manager )
Here is the default config:
local___=Stat.___require("stat").setup({winbar= {___,Stat.mod.file() },statusline= {___,Stat.mod.mode,Stat.mod.filetype,Stat.mod.git_diff },theme= { ["N"]= {fg="#2d353b",bg="#83c092"}, ["I"]= {fg="#2d353b",bg="#7fbbb3"}, ["V"]= {fg="#2d353b",bg="#dbbc7f"}, ["C"]= {fg="#2d353b",bg="#d699b6"}, ["T"]= {fg="#2d353b",bg="#a7c080"}, ["S"]= {fg="#2d353b",bg="#e67e80"}, ["File"]= {fg="#d3c6aa",bg="#343f44"}, ["Filetype"]= {fg="#d3c6aa",bg="#272e33"}, ["GitDiffDeletion"]= {fg="#e67e80",bg="#232a2e"}, ["GitDiffInsertion"]= {fg="#a7c080",bg="#232a2e"} }})
Thetheme
field can be a table like above or a table (array) of tables, this meansyou can utilize the default themes (see lua/themes directory) along side other definitionsof themes (themes are just sets of highlight group definitions), e.g
theme= { ["MyHighlight"]= {fg="#000000"},}-- Or you can do thistheme= {Stat.themes.rose_pine_moon, ["MyHighlight"]= {fg="#000000"}, {-- nest multiple ["MyHighlight2"]= {bg="#FFFFFF"}, ["ElectricBoogaloo"]= {fg="#000000",bg="#FFFFFF"}, },}
The basic idea is that you can providefunctions,strings ortablestowinbar
andstatusline
fields. Any builtin functions are of formStat.mod.[function]
, however you can implement your own functions likeso:
functioncurrent_bufnr()localbufnr=vim.api.nvim_get_current_buf()returnStat.lib.set_highlight("MyHighlight",tostring(bufnr))end
Any functions must take 0 arguments ( or must be able to run with none ) andreturn astring. The function above alsoapplys the "MyHighlight" highlight group which would need to be defined in thetheme
field of the config.
check out the examples/
If you want to evenly space sections of your statusline you can use thebuiltinStat.___
(oof thats ugly :> maybe setlocal ___ = Stat.___
?).If you put it before any sections, like in the default config, it will have theeffect of right justifying the items ( I would play around with this to understandit fully, also refer to:help statusline
in neovim )
As well as this you can set minimum and maximum widths of your modules, to doso you must, rather than provide a string or function directly, wrap yourstring/function in a table e.g:
statusline= {"Unwrapped section", {minwid=0,maxwid=5,"Wrapped section"-- Will be truncated as its length is more than 5 }, {left_justify=true,-- default is right justifyminwid=50,-- section length 50"I am not 50 characters!",-- left justify this in 50 character section }}
Also if you add more than one function or string in a table, the contents willbe "grouped", this means that when using alignment withStat.___
thatsection will be kept together.
For those who have read:help statusline
, you may find it useful that youcan set "raw strings" ( they will not be wrapped or changed by stat.nvim ),this allows you to easily use the builtin vim statusline codes, with leastruntime overhead ( no functions are called from stat.nvim it is literally acomponent of thevim.opt.statusline
variable directly )
To do this you can do the following:
statusline= { {raw=true,value=" %f"},-- raw text " %f " will go directly in statusline"More non raw stuff as before"}
If you want to add a theme, make a pr (it needs to go in the lua/themes directory)
A lot of coloreschemes have built in lualine support. This means that the colorscheme hasa hidden module that lualine knows where to look. This plugin uses a tweaked version of howlualine loads the module. Using this you do not have to set your colorscheme manually.
just do the following in the theme field
theme=stat.lib.lualine('<colorscheme plugin name>'),
for more flexibility you can directly call thestat.lib.load_lualine_theme(1)
function if youwant to get the given colorschemes lualine config directly.