diff options
author | Max Christian Pohle | 2022-12-18 20:29:55 +0100 |
---|---|---|
committer | Max Christian Pohle | 2022-12-18 20:56:01 +0100 |
commit | 07797b39851da045aa1bfd0289de0858a1377c48 (patch) | |
tree | 4ca5d2b26d2ca9d01fc052fce5a26f88364a53d0 /plugin/statusline.vim | |
parent | 1086af63639d2a108f39ae077e0e201dddf4f523 (diff) | |
download | vim-07797b39851da045aa1bfd0289de0858a1377c48.tar.bz2 vim-07797b39851da045aa1bfd0289de0858a1377c48.zip |
Switched to nvim and neovide
Diffstat (limited to 'plugin/statusline.vim')
-rw-r--r-- | plugin/statusline.vim | 153 |
1 files changed, 0 insertions, 153 deletions
diff --git a/plugin/statusline.vim b/plugin/statusline.vim deleted file mode 100644 index 561a47e..0000000 --- a/plugin/statusline.vim +++ /dev/null | |||
@@ -1,153 +0,0 @@ | |||
1 | scriptencoding utf-8 | ||
2 | |||
3 | augroup MAX_FANCYLINE | ||
4 | set noshowmode | " mode would otherwise be shown twice- in lightline and below. We want to deactivate one. | ||
5 | set laststatus=2 | " required by AirLine and Lightline, without status line does not appear until a window split | ||
6 | |||
7 | let g:status_sym_start = '' | ||
8 | let g:status_sym_end = '' | ||
9 | let g:status_sym_sep_start = '│' | ||
10 | let g:status_sym_sep_end = '│' | ||
11 | let g:symbol_branch = '' | ||
12 | let g:symbol_screen_edge = '░' | ||
13 | |||
14 | if &term ==? 'linux' | ||
15 | let g:group_active = 'StatusLineTerm' | ||
16 | let g:group_inactive = 'StatusLineTermNC' | ||
17 | let g:group_tabline = 'TabLine' | ||
18 | else | ||
19 | let g:group_active = 'StatusLine' | ||
20 | let g:group_inactive = 'StatusLineNC' | ||
21 | let g:group_tabline = 'TabLine' | ||
22 | endif | ||
23 | |||
24 | " this function reverts foreground color and background color of a given | ||
25 | " highlight group and returns the name of a newly created _invert group | ||
26 | function! CreateInvertGroup(highlight_group) | ||
27 | if(synIDattr(synIDtrans(hlID(a:highlight_group)), 'reverse', 'gui')==1) | ||
28 | let w:color=synIDattr(hlID(a:highlight_group), 'fg#') | ||
29 | else | ||
30 | let w:color=synIDattr(hlID(a:highlight_group), 'bg#') | ||
31 | endif | ||
32 | |||
33 | let l:retval=a:highlight_group.'_invert' | ||
34 | if(exists('w:color') && w:color ==# '') | ||
35 | let w:color = 'NONE' | ||
36 | endif | ||
37 | silent! exec 'highlight '.l:retval.' guifg='.w:color.' ctermfg='.w:color | ||
38 | return l:retval | ||
39 | endfunction | ||
40 | |||
41 | function! UpdateStatus(highlight_group) | ||
42 | let l:invert_group = CreateInvertGroup(a:highlight_group) | ||
43 | let l:mode = get({ | ||
44 | \ 'n' : 'normal', | ||
45 | \ 'i' : 'insert', | ||
46 | \ 'R' : 'replace', | ||
47 | \ 'v' : 'visual', | ||
48 | \ 'V' : 'visual line', | ||
49 | \ "\<C-V>" : 'visual block', | ||
50 | \ 'c' : 'command', | ||
51 | \ 's' : 'select', | ||
52 | \ 'S' : 'select line', | ||
53 | \ "\<C-s>" : 'select block', | ||
54 | \ 't' : 'terminal' | ||
55 | \ }, mode(), mode()) | ||
56 | return '' | ||
57 | \ .'%#StatusLineHighlight#' | ||
58 | \ .'%#'.a:highlight_group.'#' | ||
59 | \ .g:symbol_screen_edge | ||
60 | \ .'%{&buftype != "" ? " ".&buftype : ""}' | ||
61 | \ .' '.l:mode.g:status_sym_sep_start | ||
62 | \ .'%{argc() > 1 ? " ".(argidx() + 1).":".argc()." ".g:status_sym_sep_start : ""}' | ||
63 | \ .'%{haslocaldir() ? fnamemodify(getcwd(), ":.:~")." " :""}' | ||
64 | \ .'%{&readonly ? " 🔒" : ""}' | ||
65 | \ .'%{&modified ? " 💾 " : ""}' | ||
66 | \ .'%{" [".winbufnr(0)."] "}' | ||
67 | \ .'%{bufname("%") == "" ? "" : fnamemodify(expand("%"), ":~:.")}' | ||
68 | \ .'%{&titlestring ? has("nvim") ? b:term_title:expand(&titlestring) : "" }' | ||
69 | \ .'%{exists("w:quickfix_title") ? w:quickfix_title : ""}' | ||
70 | \ .' ' | ||
71 | \ .'%#'.l:invert_group.'#' | ||
72 | \ .g:status_sym_end | ||
73 | \ .'%<' | ||
74 | \ .'' | ||
75 | \ .'%=' | ||
76 | \ .'' | ||
77 | \ .'%#'.l:invert_group.'#' | ||
78 | \ .g:status_sym_start | ||
79 | \ .'%#'.a:highlight_group.'#'.' ' | ||
80 | \ .'%{&buftype == "" ? "" : &buftype." ".g:status_sym_sep_end." "}' | ||
81 | \ .'%{&filetype == "" ? "" :&filetype." ".g:status_sym_sep_end." "}' | ||
82 | \ .'%{&spell ? &spelllang." ".g:status_sym_sep_end : ""}' | ||
83 | \ .'%{&fileencoding =~ "^$\\|^utf\-8$" ? "" : &fileencoding." ".g:status_sym_sep_end." "}' | ||
84 | \ .'%{&fileformat =~ "^$\\|^unix$" ? "" : &fileformat." ".g:status_sym_sep_end}' | ||
85 | \ .' ' | ||
86 | \ .'%cx%-l: ' | ||
87 | \ .g:status_sym_sep_end | ||
88 | \ .' ' | ||
89 | \ .'%p%% ' | ||
90 | \ .g:symbol_screen_edge | ||
91 | endfunction | ||
92 | |||
93 | function! UpdateTabline(highlight_group) | ||
94 | let l:invert_group = CreateInvertGroup(a:highlight_group) | ||
95 | let l:git_branch = FugitiveHead() | ||
96 | return '' | ||
97 | \ .'%#'.a:highlight_group.'#' | ||
98 | \ .g:symbol_screen_edge | ||
99 | \ .' ' | ||
100 | \ .'%#'.a:highlight_group.'#' | ||
101 | \ .'%-2( %)' | ||
102 | \ .'%{fnamemodify(getcwd(-1), ":~")}' | ||
103 | \ .' ' | ||
104 | \ .'%{FugitiveHead() == "" ? "" : g:status_sym_sep_start." ".g:symbol_branch." ".FugitiveHead()}' | ||
105 | \ .' ' | ||
106 | \ .'%#'.l:invert_group.'#' | ||
107 | \ .g:status_sym_end | ||
108 | \ .'%<' | ||
109 | \ .'%=' | ||
110 | \ .'%#'.l:invert_group.'#' | ||
111 | \ .g:status_sym_start | ||
112 | \ .'%(%#'.a:highlight_group.'#%)' | ||
113 | \ .' ' | ||
114 | \ .'%-2(%)' | ||
115 | \ .'%(%#'.a:highlight_group.'#%)' | ||
116 | \ .'%(%{v:servername} %{v:this_session}%)' | ||
117 | \ .g:status_sym_sep_end.' ' | ||
118 | \ .'%-3(%)' | ||
119 | \ .'%#'.a:highlight_group.'#' | ||
120 | \ .'%{tabpagenr()}/%{tabpagenr()}' | ||
121 | \ .' ' | ||
122 | \ .g:symbol_screen_edge | ||
123 | \ .'%##' | ||
124 | endfunction | ||
125 | |||
126 | |||
127 | if $USER ==? 'root' | ||
128 | let highlight_group_root = "ErrorMsg" | ||
129 | let invert_group = CreateInvertGroup(highlight_group_root) | ||
130 | let g:group_tabline = highlight_group_root | ||
131 | endif | ||
132 | |||
133 | function! ApplyColorScheme() | ||
134 | " set termguicolors | " When on, uses highlight-guifg and highlight-guibg attributes in the terminal (=24bit color) incompatible with nvim | ||
135 | " set t_ut= | ||
136 | " set up statusline, global and current window individually | ||
137 | set statusline=%!UpdateStatus(g:group_inactive) | ||
138 | setlocal statusline=%!UpdateStatus(g:group_active) | ||
139 | " set up the tabline (match colors) | ||
140 | set tabline=%!UpdateTabline(g:group_tabline) | ||
141 | |||
142 | " otherwise 'bold' can mess up icon sizes and I do not know why | ||
143 | highlight! StatusLine cterm=reverse | ||
144 | " exec 'highlight! User3 guifg=#D2A032 guibg='.l:fgcolor | ||
145 | endfunction | ||
146 | call ApplyColorScheme() | ||
147 | |||
148 | " apply colors from the loaded colorscheme... | ||
149 | " when changing the colorscheme also apply new colors to the statusbar... | ||
150 | autocmd ColorScheme * call ApplyColorScheme() | ||
151 | autocmd WinEnter * setlocal statusline=%!UpdateStatus(g:group_active) | ||
152 | autocmd WinLeave * setlocal statusline< | ||
153 | augroup END " MAX_FANCYLINE | ||