Last active
October 12, 2021 20:14
-
-
Save mheiber/45678d13b4351b102711e9261dd3950f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" add visual indication of progress in a buffer to the status bar. To use: | |
" set statusline=%{ProgRock()}REST_OF_YOUR_STATUS_LINE HERE} | |
" for example: | |
" set statusline=%{ProgRock()}%{coc#status()}%{get(b:,'coc_current_function','')} | |
function! ProgRock() | |
let magic_width_number = 30 | |
let width = winwidth(0) | |
let lcur = line('.') | |
let lend = line('$') | |
let full = max([width - magic_width_number, 3]) | |
let cur_render = float2nr((lcur / (lend + 0.0)) * full) | |
let rem_render = (full - cur_render) - 1 | |
return '|' . RepeatStr('_', cur_render) . RepeatStr(' ', rem_render) . '|' | |
endfunction | |
function RepeatStr(str, n) | |
let res = '' | |
for _ in range(max([a:n, 0])) | |
let res .= a:str | |
endfor | |
return res | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment