-
-
Save tasmo/bb79473aedb6797f016522109884ad9a to your computer and use it in GitHub Desktop.
set noshowmode | |
set noruler | |
" Get current filetype | |
function! CheckFT(filetype) | |
if a:filetype == '' | |
return '-' | |
else | |
return tolower(a:filetype) | |
endif | |
endfunction | |
function! AleStatus() abort | |
let l:counts = ale#statusline#Count(bufnr('')) | |
let l:all_errors = l:counts.error + l:counts.style_error | |
let l:all_non_errors = l:counts.total - l:all_errors | |
return l:counts.total == 0 ? 'OK' : printf( | |
\ '%dW %dE', | |
\ all_non_errors, | |
\ all_errors | |
\) | |
endfunction | |
function! GitGutterStatus() | |
let [a,m,r] = GitGutterGetHunkSummary() | |
return printf('+%d ~%d -%d', a, m, r) | |
endfunction | |
" set colors for statusline based on mode | |
function! DetectMode(mode) | |
if empty($DISPLAY) | |
let left="" | |
let right="" | |
else | |
let left="" | |
let right="" | |
end | |
let statusline="" | |
if a:mode == 'n' | |
let statusline .= "%#ModeNFGCS#\ " . left | |
let statusline .= "%#ModeNFGC#\ NORMAL\ " | |
let statusline .= "%#ModeNFGCS#" . right . "\ " . left | |
let statusline .= "%#ModeNFGC#%[%n\ ̷%{bufnr('$')}\ " | |
elseif a:mode == 'i' | |
let statusline .= "%#ModeIFGCS#\ " . left | |
let statusline .= "%#ModeIFGC#\ INSERT\ " | |
let statusline .= "%#ModeIFGCS#" . right . "\ " . left | |
let statusline .= "%#ModeIFGC#%[%n\ ̷%{bufnr('$')}\ " | |
elseif a:mode == 'R' | |
let statusline .= "%#ModeRFGCS#\ " . left | |
let statusline .= "%#ModeRFGC#\ REPLACE\ " | |
let statusline .= "%#ModeRFGCS#" . right . "\ " . left | |
let statusline .= "%#ModeRFGC#%[%n\ ̷%{bufnr('$')}\ " | |
elseif a:mode ==# 'v' | |
let statusline .= "%#ModeVFGCS#\ " . left | |
let statusline .= "%#ModeVFGC#\ VISUAL\ " | |
let statusline .= "%#ModeVFGCS#" . right . "\ " . left | |
let statusline .= "%#ModeVFGC#%[%n\ ̷%{bufnr('$')}\ " | |
elseif a:mode ==# 'V' | |
let statusline .= "%#ModeVFGCS#\ " . left | |
let statusline .= "%#ModeVFGC#\ VISUAL\ " | |
let statusline .= "%#ModeVFGCS#" . right . "\ " . left | |
let statusline .= "%#ModeVFGC#%[%n\ ̷%{bufnr('$')}\ " | |
elseif a:mode ==# '' | |
let statusline .= "%#ModeVFGCS#\ " . left | |
let statusline .= "%#ModeVFGC#\ VISUAL\ " | |
let statusline .= "%#ModeVFGCS#" . right . "\ " . left | |
let statusline .= "%#ModeVFGC#%[%n\ ̷%{bufnr('$')}\ " | |
elseif a:mode ==# 'c' | |
let statusline="" | |
let statusline .= "%#ModeCFGCS#\ " . left | |
let statusline .= "%#ModeCFGC#\ COMMAND\ " | |
let statusline .= "%#ModeCFGCS#" . right . "\ " . left | |
let statusline .= "%#ModeCFGC#%[%n\ ̷%{bufnr('$')}\ " | |
elseif a:mode ==# 't' | |
let statusline .= "%#ModeTFGCS#\ " . left | |
let statusline .= "%#ModeTFGC#\ TERMINAL\ " | |
let statusline .= "%#ModeTFGCS#" . right . "\ " . left | |
let statusline .= "%#ModeTFGC#%[%n\ ̷%{bufnr('$')}\ " | |
elseif a:mode == 'v' || a:mode == 'V' || a:mode == '^V' || a:mode == 's' || a:mode == 'S' || a:mode == '^S' | |
let statusline .= "%#ModeVFGCS#\ " . left | |
let statusline .= "%#ModeVFGC#\ VISUAL\ " | |
let statusline .= "%#ModeVFGCS#" . right . "\ " . left | |
let statusline .= "%#ModeVFGC#%[%n\ ̷%{bufnr('$')}\ " | |
endif | |
if &mod == 1 | |
let statusline .= "%#Modified#\ %.20f\ ⁺%#ModifiedS#" . right . "\ " | |
else | |
let statusline .= "%#Buffer#\ %.20f\ %#BufferS#" . right . "\ " | |
endif | |
let statusline .= "%=" | |
if exists('*fugitive#statusline') || &rtp =~ 'GitGutter' | |
if exists('*fugitive#statusline') | |
let statusline .= "%#BufferS#" . left . "%#SLGreen#\ %{FugitiveHead()}\ " | |
else | |
let statusline .= "%#BufferS#" . left | |
endif | |
if &rtp =~ 'GitGutter' | |
let statusline .= "%#SLBlue#\ %{GitGutterStatus()}\ %#BufferS#" . right . "\ " | |
else | |
let statusline .= "%#BufferS#" . right . "\ " | |
endif | |
endif | |
let statusline .= "%#BufferS#" . left . "%#Buffer#\ %{CheckFT(&filetype)}\ " | |
if &rtp =~ 'ale' | |
if AleStatus() == "OK" | |
let statusline .= "%#SLLimiter#│%#CursorStatus#\ %{AleStatus()}\ %#BufferS#" . right . "\ " | |
else | |
let statusline .= "\ %#BufferError#\ %{AleStatus()}\ %#BufferErrorS#" . right . "\ " | |
endif | |
else | |
let statusline .= "%#BufferS#" . right . "\ " | |
endif | |
let statusline .= "%#BufferS#" . left . "%#CursorStatus#\ %-8.(%l,%c%)%#ModeNFGC#\ %P\ %#ModeNFGCS#" . right . "\ " | |
return statusline | |
return ' ' | |
endfunction | |
set laststatus=2 | |
set statusline=%!DetectMode(mode()) | |
" vim:set ft=vim et sw=2: |
I use the latest standard version of Iosevka. Maybe the Nerdfont does not have the rounded blocks.
I think I managed to do it, basically I use nvim-qt so if empty($DISPLAY)
seems to be true for me always, so I removed the if from my script.
Good finding.
I came from Reddit as well. I am a new VIM user. Can you please tell me how to use this ? I am using NVIM and I just pasted all the above in my init.vim , but there are bunch of errors happening as soon as my launch my instance of Neovim. Please suggest.
Thanks
but there are bunch of errors happening as soon as my launch my instance of Neovim
Without knowing the errors I just could guess badly. Please give more details.
I came from Reddit as well. I am a new VIM user. Can you please tell me how to use this ? I am using NVIM and I just pasted all the above in my init.vim , but there are bunch of errors happening as soon as my launch my instance of Neovim. Please suggest.
Thanks
Install ALE and GitGutter even if you dont use them. This script depends on them. GitGutter is a must but ALE for my workflow isn't. I was thinking of editing the script further to be independent of ale but I dont know much vimscript. Maybe I might make one later
Thank you for the input. Hopefully it will work now. If not, please keep hinting what is wrong.
Just please keep in mind that this is not an official "package" I maintain.
Thanks a lot for this! It inspired me to write my own statusline.
Where did you get the rounded circle unicodes, and do you have the exact codes?
I found a pair, but they were smaller. I could use a pair that is a little bit smaller, but i'm guessing that isn't possible
Cheers!
I came here from reddit. How do I make the rounded corners in the statusline? I'm using a nerd font version of Iosevka if that helps.