aboutsummaryrefslogtreecommitdiff
path: root/.local/share/nvim/site/autoload/statusbar.vim
blob: 761fa4887cefbd03013d70f24220970f7065a7cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
function TabLabel(n)
	let buflist = tabpagebuflist(a:n)
	let winnr = tabpagewinnr(a:n)
	return fnamemodify(bufname(buflist[winnr - 1]), ':t')
endfunction

function! TabLine()
	let s = ''
	for i in range(tabpagenr('$'))
		let s ..= '%#TabLineFill# '
		" set the tab page number (for mouse clicks)
		let s ..= '%' .. (i + 1) .. 'T'
		" select the highlighting
		if i + 1 == tabpagenr()
			let s ..= '%#TabLineSel# '
		else
			let s ..= '%#TabLine# '
		endif

		" the label is made by TabLabel()
		if TabLabel(i + 1) == ""
			let s ..= "No Name"
		else
			let s ..= TabLabel(i + 1)
		endif

		let s ..= " %" .. (i + 1) .. "X"

		if i + 1 == tabpagenr()
			let s ..= ' %#StatusLine#%#TabLine#'
		else
			let s ..= ' '
		endif
	endfor

	" after the last tab fill with TabLineFill and reset tab page nr
	let s ..= '%#TabLineFill#%T'

	return s
endfunction


function! ModeLabel()
	let currentmode={
				\ 'n'  : 'NORMAL',
				\ 'v'  : 'VISUAL',
				\ 'V'  : 'V·Line',
				\ "\<C-V>" : 'V·Block',
				\ 'i'  : 'INSERT',
				\ 'R'  : 'R',
				\ 'Rv' : 'V·Replace',
				\ 'c'  : 'Command',
				\ 's'  : 'Snipped',
				\ 't'  : 'Terminal',
				\}

	return get(currentmode, mode(), '')
endfunction


function! statusbar#refresh()
	set laststatus=3


	set statusline=
	set statusline+=%#StatusLineBlock#\ %{ModeLabel()}\ %#StatusLine#"
	set statusline+=\ %#StatusLine#%#StatusLineBlock#\ %f\ %#StatusLine#
	set statusline+=%=
	set statusline+=%#StatusLine#%#StatusLineBlock#\ %l/%L\ %p%%\ 

	set tabline=%!TabLine()
endfunction