vim-fastline

A custom lean vim statusline.
git clone https://git.sr.ht/~jbauer/vim-fastline
Log | Files | Refs | README | LICENSE

commit 69cfafcdae52760e2fb7392768277da7f03ab6a7
parent 4c34f9f4ba2e3cd6336e96283cdaa2331f46137d
Author: Jake Bauer <jbauer@paritybit.ca>
Date:   Mon, 24 Feb 2020 22:16:06 -0500

Add files to repo

Diffstat:
Aplugin/statusline.vim | 101+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 101 insertions(+), 0 deletions(-)

diff --git a/plugin/statusline.vim b/plugin/statusline.vim @@ -0,0 +1,101 @@ +" Courtesy for tutorial: https://irrellia.github.io/blogs/vim-statusline/ +" Colours for the statusline +hi Base guibg=#212333 guibg=#212333 guifg=#212333 +hi Mode guibg=#82aaff guifg=#121824 gui=bold +hi Git guibg=#292d3e guifg=#929dcb +hi Filetype guibg=#292d3e guifg=#929dcb +hi LineCol guibg=#82aaff guifg=#181824 gui=bold +hi Warn guibg=#212333 guifg=#e27878 gui=bold + +let g:modes={ + \'n' : 'Normal ', + \'no' : 'N·Operator Pending ', + \'v' : 'Visual ', + \'V' : 'V·Line ', + \'^V' : 'V·Block ', + \'s' : 'Select ', + \'S' : 'S·Line ', + \'^S' : 'S·Block ', + \'i' : 'Insert ', + \'R' : 'Replace ', + \'Rv' : 'V·Replace ', + \'c' : 'Command ', + \'cv' : 'Vim Ex ', + \'ce' : 'Ex ', + \'r' : 'Prompt ', + \'rm' : 'More ', + \'r?' : 'Confirm ', + \'!' : 'Shell ', + \'t' : 'Terminal ' + \} + +" Determine current mode +function! CurrentMode() abort + let l:currentmode = mode() + let l:modelist = toupper(get(g:modes, l:currentmode, 'V·Block ')) + let l:current_status_mode = l:modelist + return l:current_status_mode +endfunction + +" Get current git branch, git plugin like vim-fugitive required +function! GitBranch(git) + if a:git == '' + return '[-]' + else + return '['.a:git.']' + endif +endfunction + +function! CheckModified(modi) + if a:modi == 1 + hi Modi guifg=#efefef guibg=#212333 gui=bold + hi Filename guifg=#efefef guibg=#212333 + if expand('%') == "" + return '[New File]'.'*' + else + return expand('%:t').'*' + endif + else + hi Modi guifg=#929dcb guibg=#212333 + hi Filename guifg=#929dcb guibg=#212333 + if expand('%') == "" + return '[New File]' + else + return expand('%:t') + endif + endif +endfunction + +function! CheckFileType(filetype) + if a:filetype == '' + return '-' + else + return tolower(a:filetype) + endif +endfunction + +function! CheckRO(roflag) + if a:roflag == 0 + return '' + else + return '⊖' + endif +endfunction + +" Statusline format and layout +function! StatusLine() + let statusline = "" + let statusline .= "%#Base#" + let statusline .= "%#Mode# %{CurrentMode()}" + let statusline .= "%#Git# %{GitBranch(fugitive#head())} " + let statusline .= "%#Warn#%( %{CheckRO(&readonly)}%w%)" + let statusline .= "%#Modi# %{CheckModified(&modified)}" + let statusline .= "%#Base#" + let statusline .= "%=" + let statusline .= "%#FileType# %{CheckFileType(&filetype)} " + let statusline .= "%#LineCol# %p%% Ln %l/%L : %c " + return statusline +endfunction + +" Activate the custom statusline +set statusline=%!StatusLine()