A minimalistic statusline and tabline configuration vim plugin.
A 4-dimensional world can be described as a sequence of 3-dimensional slices, which are the state of the world at an index t.
This plugin tries to simplify the configuration of the statusline and tabline. This is my way of extracting my statusline configuration into a detachable module and working out some behavior kinks.
Simply create a list of items as g:worldslice#config
and call
worldslice#init()
, like in the following example (it's a modification of my
own config).
function! StatusDir()
if &buftype != "nofile"
let d = expand("%:p:~:h")
if d != fnamemodify(getcwd(), ":~")
return expand("%:p:.:h").'/'
else
return ''
endif
else
return ''
endif
endfunction
let g:worldslice#config = [
\ '+(@:)', ["%{fnamemodify(getcwd(),':~')}", 'Special'],
\ '+(:)', ['%n', 'Number'],
\ '+(:)', ["%{expand('%:h')!=''? StatusDir(): ''}", 'Directory'],
\ ["%{expand('%:h')!=''? expand('%:t'): '[unnamed]'}", 'Identifier'],
\ ['%m%r', 'Boolean'],
\ ' %=\',
\ ['%{&fenc}', 'Constant'],
\ '+(:)', ['%{&ft}', 'Type'],
\ '+(:)', ['%{&fo}', 'Function'],
\ '+(:)', ["%{&spell?&spl:''}", 'SpellBad'],
\ [' %l,%c', 'Number']
\ ]
call worldslice#init()
The +(...)
format is a shortcut for defining delimiters, the text between the
parentheses is displayed.
You can also create a list and pass it as an argument to worldslice#init()
like in
let my_config = [...]
call worldslice#init(my_config)
If you are like me, you probably never use vim tabs, relying either on multiple
vim instances or on finder mechanisms. If this is the case, the tabline could,
and maybe should be (ab)used for different purposes. worldslice
treats it
as a marquee for flags, which I like to call sigils. Basically, worldslice
keeps a dictionary of sigils and watches for changes to it using the
dictionary watcher feature in nvim. Adding a new sigil is easy:
let g:worldslice#sigils.my_sigil = 'x'
(updating them works the same), and so is removing them:
call remove(g:worldslice#sigils, 'my_sigil')
Sigils always restore the tabline background color, so to colorize one you can simply specify the highlighting group, either by including it explicitly
let g:worldslice#sigils.my_sigil = '%#SLBoolean#x'
or using the following variant
let g:worldslice#sigils.my_sigil = ['x', 'Boolean']
which might be clearer to understand.