<commit_before>scriptencoding utf-8

" Constants
let s:true = 1
let s:false = 0
let s:filled = '█'
let s:empty = '░'

" Private functions
function! s:set_colors() abort
	highlight! link User1 Directory
	highlight! link User2 ErrorMsg
endfunction

function! s:set_status_line(active) abort
	if &buftype ==# 'nofile' || &filetype ==# 'netrw'
		" Likely a file explorer.
		setlocal statusline=%!NoFileStatusLine()
	elseif &buftype ==# 'nowrite'
		" Don't set a custom status line for certain special windows.
		return
	elseif a:active
		setlocal statusline=%!ActiveStatusLine()
	else
		setlocal statusline=%!InactiveStatusLine()
	endif
endfunction

function! s:update_inactive_windows() abort
	for l:winnum in range(1, winnr('$'))
		if l:winnum != winnr()
			call setwinvar(l:winnum, '&statusline', '%!InactiveStatusLine()')
		endif
	endfor
endfunction

" Public Functions

function! StatuslineScrollbar(width) abort
	" The various calls to round() are to make Numbers into Floats, otherwise
	" Vim just drops the remainder because a Number/Number -> Number.
	let l:pos = line('.') / round(line('$'))

	let l:scrollbar = map(range(a:width), '"' . s:empty . '"')
	for l:n in range(a:width)
		if (((l:n + 1) / round(a:width)) > l:pos)
			break
		endif
	endfor
	let l:scrollbar[l:n] = s:filled

	return join(l:scrollbar, '')
endfunction

function! ShortFilePath() abort
	if &buftype ==# 'terminal'
		return expand('%:t')
	else
		return pathshorten(fnamemodify(expand('%:p'), ':~:.'))
	endif
endfunction

function! ObsessionStatusLine() abort
	if !exists('g:loaded_obsession')
		return ''
	else
		return ObsessionStatus()
	endif
endfunction

function! ActiveStatusLine() abort
	" Sections:
	" Mode:
	let l:statusline = '%([%-2{mode(1)}]%)'
	" Location/Flags
	let l:statusline .= '%(%1* %{ShortFilePath()}%h%2*%m%r%1* %)%0*'
	" split and file info
	let l:statusline .= '%=%(%y[%{&ff}]%)'
	" Location:
	" let l:statusline .= '%{StatuslineScrollbar(10)}'
	let l:statusline .= '%([%3p%%]%)%([l:%2l c:%2c]%)'
	" Obsession:
	let l:statusline .= '%)%{ObsessionStatusLine()}%)'
	return l:statusline<commit_msg>Add 3rd axis to statusline.<commit_after>scriptencoding utf-8

" Constants
let s:true = 1
let s:false = 0
let s:filled = '█'
let s:empty = '░'

" Private functions
function! s:set_colors() abort
	highlight! link User1 Directory
	highlight! link User2 ErrorMsg
endfunction

function! s:set_status_line(active) abort
	if &buftype ==# 'nofile' || &filetype ==# 'netrw'
		" Likely a file explorer.
		setlocal statusline=%!NoFileStatusLine()
	elseif &buftype ==# 'nowrite'
		" Don't set a custom status line for certain special windows.
		return
	elseif a:active
		setlocal statusline=%!ActiveStatusLine()
	else
		setlocal statusline=%!InactiveStatusLine()
	endif
endfunction

function! s:update_inactive_windows() abort
	for l:winnum in range(1, winnr('$'))
		if l:winnum != winnr()
			call setwinvar(l:winnum, '&statusline', '%!InactiveStatusLine()')
		endif
	endfor
endfunction

" Public Functions

function! StatuslineScrollbar(width) abort
	" The various calls to round() are to make Numbers into Floats, otherwise
	" Vim just drops the remainder because a Number/Number -> Number.
	let l:pos = line('.') / round(line('$'))

	let l:scrollbar = map(range(a:width), '"' . s:empty . '"')
	for l:n in range(a:width)
		if (((l:n + 1) / round(a:width)) > l:pos)
			break
		endif
	endfor
	let l:scrollbar[l:n] = s:filled

	return join(l:scrollbar, '')
endfunction

function! ShortFilePath() abort
	if &buftype ==# 'terminal'
		return expand('%:t')
	else
		return pathshorten(fnamemodify(expand('%:p'), ':~:.'))
	endif
endfunction

function! ObsessionStatusLine() abort
	if !exists('g:loaded_obsession')
		return ''
	else
		return ObsessionStatus()
	endif
endfunction

function! ActiveStatusLine() abort
	" Sections:
	" Mode:
	let l:statusline = '%([%-2{mode(1)}]%)'
	" Location/Flags
	let l:statusline .= '%(%1* %{ShortFilePath()}%h%2*%m%r%1* %)%0*'
	" split and file info
	let l:statusline .= '%=%(%y[%{&ff}]%)'
	" Location:
	" let l:statusline .= '%{StatuslineScrollbar(10)}'
	let l:statusline .= '%([%3p%%]%)%([x:%2c y:%2l z:%{&foldlevel}]%)'
	" Obsession:
	let l:statusline .= '%)%{ObsessionStatusLine()}%)'
	return l:statusline
{'fraction_non_alphanumeric': 0.16540284360189572, 'fraction_numerical': 0.008767772511848342, 'mean_word_length': 5.162043795620438, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4203931', 'n_tokens_mistral': 1616, 'n_tokens_neox': 1540, 'n_words': 394}