-
-
Save tasmo/bb79473aedb6797f016522109884ad9a to your computer and use it in GitHub Desktop.
set noshowmode | |
set noruler | |
autocmd ColorScheme * highlight link ModeNFGC StatuslineNC | |
autocmd ColorScheme * highlight link ModeNFGCS LineNr | |
autocmd ColorScheme * highlight link ModeIFGC DiffAdd | |
autocmd ColorScheme * highlight link ModeIFGCS DiffAdded | |
autocmd ColorScheme * highlight link ModeRFGC Search | |
autocmd ColorScheme * highlight link ModeRFGCS Repeat | |
autocmd ColorScheme * highlight link ModeVFGC CursorIM | |
autocmd ColorScheme * highlight link ModeVFGCS Conditional | |
autocmd ColorScheme * highlight link ModeCFGC DiffText | |
autocmd ColorScheme * highlight link ModeCFGCS DiffChanged | |
autocmd ColorScheme * highlight link ModeTFGC TermCursor | |
autocmd ColorScheme * highlight link ModeTFGCS Normal | |
" 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 leftSymbol="" | |
let rightSymbol="" | |
else | |
let leftSymbol="" | |
let rightSymbol="" | |
end | |
let statusline="" | |
if a:mode == 'n' | |
let statusline .= "%#ModeNFGCS#\ " . leftSymbol | |
let statusline .= "%#ModeNFGC#\ NORMAL\ " | |
let statusline .= "%#ModeNFGCS#" . rightSymbol . "\ " . leftSymbol | |
let statusline .= "%#ModeNFGC#%[%n\ ̷%{bufnr('$')}\ " | |
elseif a:mode == 'i' | |
let statusline .= "%#ModeIFGCS#\ " . leftSymbol | |
let statusline .= "%#ModeIFGC#\ INSERT\ " | |
let statusline .= "%#ModeIFGCS#" . rightSymbol . "\ " . leftSymbol | |
let statusline .= "%#ModeIFGC#%[%n\ ̷%{bufnr('$')}\ " | |
elseif a:mode == 'R' | |
let statusline .= "%#ModeRFGCS#\ " . leftSymbol | |
let statusline .= "%#ModeRFGC#\ REPLACE\ " | |
let statusline .= "%#ModeRFGCS#" . rightSymbol . "\ " . leftSymbol | |
let statusline .= "%#ModeRFGC#%[%n\ ̷%{bufnr('$')}\ " | |
elseif a:mode ==# 'v' | |
let statusline .= "%#ModeVFGCS#\ " . leftSymbol | |
let statusline .= "%#ModeVFGC#\ VISUAL\ " | |
let statusline .= "%#ModeVFGCS#" . rightSymbol . "\ " . leftSymbol | |
let statusline .= "%#ModeVFGC#%[%n\ ̷%{bufnr('$')}\ " | |
elseif a:mode ==# 'V' | |
let statusline .= "%#ModeVFGCS#\ " . leftSymbol | |
let statusline .= "%#ModeVFGC#\ VISUAL\ " | |
let statusline .= "%#ModeVFGCS#" . rightSymbol . "\ " . leftSymbol | |
let statusline .= "%#ModeVFGC#%[%n\ ̷%{bufnr('$')}\ " | |
elseif a:mode ==# '' | |
let statusline .= "%#ModeVFGCS#\ " . leftSymbol | |
let statusline .= "%#ModeVFGC#\ VISUAL\ " | |
let statusline .= "%#ModeVFGCS#" . rightSymbol . "\ " . leftSymbol | |
let statusline .= "%#ModeVFGC#%[%n\ ̷%{bufnr('$')}\ " | |
elseif a:mode ==# 'c' | |
let statusline="" | |
let statusline .= "%#ModeCFGCS#\ " . leftSymbol | |
let statusline .= "%#ModeCFGC#\ COMMAND\ " | |
let statusline .= "%#ModeCFGCS#" . rightSymbol . "\ " . leftSymbol | |
let statusline .= "%#ModeCFGC#%[%n\ ̷%{bufnr('$')}\ " | |
elseif a:mode ==# 't' | |
let statusline .= "%#ModeTFGCS#\ " . leftSymbol | |
let statusline .= "%#ModeTFGC#\ TERMINAL\ " | |
let statusline .= "%#ModeTFGCS#" . rightSymbol . "\ " . leftSymbol | |
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#\ " . leftSymbol | |
let statusline .= "%#ModeVFGC#\ VISUAL\ " | |
let statusline .= "%#ModeVFGCS#" . rightSymbol . "\ " . leftSymbol | |
let statusline .= "%#ModeVFGC#%[%n\ ̷%{bufnr('$')}\ " | |
endif | |
if &mod == 1 | |
let statusline .= "%#Modified#\ %.20f\ ⁺%#ModifiedS#" . rightSymbol . "\ " | |
else | |
let statusline .= "%#Statusline#\ %.20f\ %#BufferS#" . rightSymbol . "\ " | |
endif | |
let statusline .= "%=" | |
if exists('*fugitive#statusline') || &rtp =~ 'GitGutter' | |
if exists('*fugitive#statusline') | |
let statusline .= "%#BufferS#" . leftSymbol . "%#SLGreen#\ %{FugitiveHead()}\ " | |
else | |
let statusline .= "%#BufferS#" . leftSymbol | |
endif | |
if &rtp =~ 'GitGutter' | |
let statusline .= "%#SLBlue#\ %{GitGutterStatus()}\ %#BufferS#" . rightSymbol . "\ " | |
else | |
let statusline .= "%#BufferS#" . rightSymbol . "\ " | |
endif | |
endif | |
let statusline .= "%#BufferS#" . leftSymbol . "%#Statusline#\ %{CheckFT(&filetype)}\ " | |
if !empty(get(b:, 'coc_diagnostic_info', {})) | |
if coc#status() != "" | |
let statusline .= "%#BufferError#\ \ %{coc#status()}%{get(b:,'coc_current_function','')}\ %#BufferErrorS#" . rightSymbol . "\ " | |
else | |
let statusline .= "%#BufferS#" . rightSymbol . "\ " | |
endif | |
elseif &rtp =~ 'ale' | |
if AleStatus() == "OK" | |
let statusline .= "%#SLLimiter#│%#CursorStatus#\ %{AleStatus()}\ %#BufferS#" . rightSymbol . "\ " | |
else | |
let statusline .= "\ %#BufferError#\ %{AleStatus()}\ %#BufferErrorS#" . rightSymbol . "\ " | |
endif | |
else | |
let statusline .= "%#BufferS#" . rightSymbol . "\ " | |
endif | |
let statusline .= "%#BufferS#" . leftSymbol . "%#Statusline#\ %-8.(%l,%c%)" | |
if a:mode == 'n' | |
let statusline .= "%#ModeNFGC#\ %P\ %#ModeNFGCS#" . rightSymbol . "\ " | |
elseif a:mode == 'i' | |
let statusline .= "%#ModeIFGC#\ %P\ %#ModeIFGCS#" . rightSymbol . "\ " | |
elseif a:mode == 'R' | |
let statusline .= "%#ModeRFGC#\ %P\ %#ModeRFGCS#" . rightSymbol . "\ " | |
elseif a:mode ==# 'v' | |
let statusline .= "%#ModeVFGC#\ %P\ %#ModeVFGCS#" . rightSymbol . "\ " | |
elseif a:mode ==# 'V' | |
let statusline .= "%#ModeVFGC#\ %P\ %#ModeVFGCS#" . rightSymbol . "\ " | |
elseif a:mode ==# '^V' | |
let statusline .= "%#ModeVFGC#\ %P\ %#ModeVFGCS#" . rightSymbol . "\ " | |
elseif a:mode ==# 'c' | |
let statusline .= "%#ModeCFGC#\ %P\ %#ModeCFGCS#" . rightSymbol . "\ " | |
elseif a:mode ==# 't' | |
let statusline .= "%#ModeTFGC#\ %P\ %#ModeTFGCS#" . rightSymbol . "\ " | |
elseif a:mode == 'v' || a:mode == 'V' || a:mode == '^V' || a:mode == 's' || a:mode == 'S' || a:mode == '^S' | |
let statusline .= "%#ModeVFGC#\ %P\ %#ModeVFGCS#" . rightSymbol . "\ " | |
endif | |
return statusline | |
return ' ' | |
endfunction | |
set laststatus=2 | |
set statusline=%!DetectMode(mode()) | |
" vim:set ft=vim et sw=2: |
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!
Good finding.