Build your own fancy statusline/tabline in Vim/Neovim
vim-crystalline is a plugin that lets you build your own statusline/tabline in Vim (and Neovim as of v1) in a vanilla style.
vim-crystalline is fast and easy to use.
Version 1 of vim-crystalline is a total overhaul and comes with many improvements.
Other statusline plugins look nice, but customizing the statusline in vanilla vim is easier. I created vim-crystalline so you can build your own statusline like in vanilla vim but with all the fanciness of statusline plugins.
Read the statusline configuration comparison here.
Here's what a basic statusline and tabline look like in version 1:
function! g:CrystallineStatuslineFn(winnr)
let l:s = crystalline#ModeSection('>', 'A', 'B')
let l:s .= ' %f%h%w%m%r '
let l:s .= crystalline#Sep('>', 'B', 'Fill') . ' %{fugitive#Head()}'
let l:s .= '%='
let l:s .= crystalline#Sep('<', 'Fill', 'B') . (&paste ? ' PASTE ' : ' ')
let l:s .= crystalline#Sep('<', 'B', 'A')
let l:s .= ' %{&ft} %l/%L %2v '
return l:s
endfunction
function! g:CrystallineTablineFn()
return crystalline#DefaultTabline({ 'enable_sep': 1, 'sep_index': '>' })
endfunction
set showtabline=2
set guioptions-=e
set laststatus=2
let g:crystalline_auto_prefix_groups = 1
" By default, these are powerline-style separators
let g:crystalline_separators = {
\ '>': { 'ch': '>', 'alt_ch': '|', 'dir': '>' },
\ '<': { 'ch': '>', 'alt_ch': '|', 'dir': '<' },
\ }
See the examples for more.
Command mode and terminal mode are now available.
Separator functions are much clearer:
" By default, these are powerline-style separators
let g:crystalline_separators = [
\ { 'ch': '>', 'alt_ch': '|', 'dir': '>' },
\ { 'ch': '<', 'alt_ch': '|', 'dir': '<' },
\ ]
" Use separator 0 between highlight groups CrystallineA and CrystallineB
let l:sep = crystalline#Sep(0, 'A', 'B')
-- ~/.config/nvim/init.lua
require("packer").startup(function(use)
use("rbong/vim-crystalline")
function vim.g.CrystallineStatuslineFn(winnr)
local cl = require("crystalline")
return cl.ModeSection(0, "A", "Fill") .. " %f%h%w%m%r "
end
function vim.g.CrystallineTablineFn()
local cl = require("crystalline")
return cl.DefaultTabline()
end
end)
Plugin performance has been improved.
Other functions are now clearer (see :help crystalline-functions
).
Tabline functions are much more flexible.
Functions such as crystalline#Tabs()
and crystalline#Buffers()
are available for showing tabs/buffers anywhere on the statusline or tabline.
The tabline now updates more responsively when the current mode changes.
Highlight group names are now clearer, for example CrystallineA
, CrystallineB
, etc.
(See :help crystalline-highlight-groups
.)
Every highlight group now has a variation for the current mode, for example CrystallineNormalModeFill
, CrystallineCommandModeTab
, etc.
These groups have been added to many existing themes.
You can automatically add the current mode/inactive status to highlight groups with let g:crystalline_auto_prefix_groups = 1
Themes can now define variants for highlight groups, for example CrystallineA1
, CrystallineA2
, CrystallineB1
, etc.
These can be used for showing different settings and state in the statusline, such as if the file has been modified or if the paste setting is active.
Variants have been added to many existing themes.
You can automatically add variants onto highlight groups with let g:crystalline_group_suffix = 1
You no longer have to define every highlight group/attribute in a theme, they will fall back on reasonable defaults.
Added new themes: ayu (dark)/ayu (light), iceberg (dark)/iceberg (light), onehalfdark/onehalflight, and nord.
Added function to port vim-airline themes (see Porting Airline Themes).
Almost everything has changed, so please review :help vim-crystalline
and the examples.
You'll get deprecation warnings when possible.
Major new features in this release:
CrystallineSetTheme
)Please check the README for screenshots and examples.
I have also updated the wiki with a performance comparison and configuration comparison between crystalline, airline, and lightline.