diff options
author | Max Christian Pohle | 2021-05-16 03:48:02 +0200 |
---|---|---|
committer | Max Christian Pohle | 2021-05-16 03:48:02 +0200 |
commit | 58f19ec9cc50310b6eaaa937ced21c424bdfcf7a (patch) | |
tree | 1007102c3bfc27df51ad8044691def4fa557bdec | |
download | vim-fancy-line-58f19ec9cc50310b6eaaa937ced21c424bdfcf7a.tar.bz2 vim-fancy-line-58f19ec9cc50310b6eaaa937ced21c424bdfcf7a.zip |
First off-tree version
-rw-r--r-- | README.md | 38 | ||||
-rw-r--r-- | doc/vim-recently-used.txt | 22 | ||||
-rwxr-xr-x | plugin/vim-fancy-line.vim | 176 |
3 files changed, 236 insertions, 0 deletions
diff --git a/README.md b/README.md new file mode 100644 index 0000000..d808107 --- /dev/null +++ b/README.md | |||
@@ -0,0 +1,38 @@ | |||
1 | # vim-fancy-line | ||
2 | |||
3 | This statusline is kept minimalistic and easy to understand. Its main feature | ||
4 | is, that it uses Vims highlight groups correctly and displays the status- | ||
5 | and tab-bar after the definitions in the currently selected colorscheme. | ||
6 | That means, that the highlight groups `StatusLine`, `StatusLineNC`, | ||
7 | `StatusLineTerm` and `StatusLineTermNC` are considered. Otherwise the bars | ||
8 | look similar to powerline, but that is no wonder, because the `` symbol | ||
9 | is the only one, which used to be available in code page 437 and thus broadly | ||
10 | compatible. | ||
11 | |||
12 | ## Installation | ||
13 | |||
14 | This should be sufficient: | ||
15 | |||
16 | git clone https://git.entwicklerseite.de/vim-fancy-line \ | ||
17 | ~/.vim/pack/coderonline/start/vim-fancy-line | ||
18 | |||
19 | Or as submodule: | ||
20 | |||
21 | git submodule add https://git.entwicklerseite.de/vim-fancy-line \ | ||
22 | ~/.vim/pack/coderonline/start/vim-fancy-line | ||
23 | |||
24 | Or download the zip file and extract it under `~/.vim/pack/coderonline/start/`. | ||
25 | |||
26 | ## Installation using plugin managers | ||
27 | |||
28 | ### vim-plug | ||
29 | |||
30 | Plug 'coderonline/vim-fancy-line' | ||
31 | |||
32 | ### dein.vim | ||
33 | |||
34 | call dein#add('coderonline/vim-fancy-line') | ||
35 | |||
36 | ## Design goals | ||
37 | |||
38 | * Keep it simple | ||
diff --git a/doc/vim-recently-used.txt b/doc/vim-recently-used.txt new file mode 100644 index 0000000..f8cb8d6 --- /dev/null +++ b/doc/vim-recently-used.txt | |||
@@ -0,0 +1,22 @@ | |||
1 | *vim-fancy-line.txt* A plugin to make the status and tab line look nicer | ||
2 | |||
3 | ============================================================================== | ||
4 | USAGE INSTRUCTIONS *vim-recently-used-usage* | ||
5 | |||
6 | |||
7 | While this plugin does not have any configuration options in Vim right now, | ||
8 | it is necessary to configure the operating system to get the best use out | ||
9 | of it. It is recommend to install powerline-console-fonts and set them in | ||
10 | `/etc/vconsole.conf` so that the linux terminal displays the bars correctly. | ||
11 | |||
12 | |||
13 | CONSOLE FONTS | ||
14 | |||
15 | To test ca console font try this (it will not survive a reboot as long | ||
16 | as it is not copied to vconsole.conf): | ||
17 | |||
18 | $ setfont /usr/share/kbd/consolefont/ter-powerline-v16n.psf.gz | ||
19 | $ showconsolefont | ||
20 | |||
21 | |||
22 | vim:tw=78:ts=8:ft=help:norl: | ||
diff --git a/plugin/vim-fancy-line.vim b/plugin/vim-fancy-line.vim new file mode 100755 index 0000000..8e470ff --- /dev/null +++ b/plugin/vim-fancy-line.vim | |||
@@ -0,0 +1,176 @@ | |||
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 | |||
8 | if (&term ==? 'linux' && &termguicolors == 0) | ||
9 | let g:group_active = 'StatusLineTerm' | ||
10 | let g:group_inactive = 'StatusLineTermNC' | ||
11 | let g:group_tabline = 'TabLine' | ||
12 | let g:status_sym_start = '' | ||
13 | let g:status_sym_end = '▶' | ||
14 | let g:status_sym_sep_start = '│' | ||
15 | let g:status_sym_sep_end = '│' | ||
16 | let g:symbol_branch = '' | ||
17 | let g:symbol_screen_edge = '░' | ||
18 | else | ||
19 | let g:group_active = 'StatusLine' | ||
20 | let g:group_inactive = 'StatusLineNC' | ||
21 | let g:group_tabline = 'TabLine' | ||
22 | let g:status_sym_start = '' | ||
23 | let g:status_sym_end = '' | ||
24 | let g:status_sym_sep_start = '│' | ||
25 | let g:status_sym_sep_end = '│' | ||
26 | let g:symbol_branch = '' | ||
27 | let g:symbol_screen_edge = '░' | ||
28 | endif | ||
29 | |||
30 | |||
31 | " this function reverts foreground color and background color of a given | ||
32 | " highlight group and returns the name of a newly created _invert group | ||
33 | function! CreateInvertGroup(highlight_group) | ||
34 | |||
35 | if(synIDattr(synIDtrans(hlID(a:highlight_group)), 'reverse')==0) | ||
36 | let w:color=synIDattr(hlID(a:highlight_group), 'bg#') | ||
37 | let w:termcolor=synIDattr(hlID(a:highlight_group), 'bg') | ||
38 | else | ||
39 | let w:color=synIDattr(hlID(a:highlight_group), 'fg#') | ||
40 | let w:termcolor=synIDattr(hlID(a:highlight_group), 'fg') | ||
41 | endif | ||
42 | |||
43 | let l:retval=a:highlight_group.'_invert' | ||
44 | if(exists('w:color') && w:color ==# '') | ||
45 | let w:color = 'NONE' | ||
46 | endif | ||
47 | if(exists('w:termcolor') && w:termcolor ==# '') | ||
48 | let w:termcolor = 'NONE' | ||
49 | endif | ||
50 | |||
51 | silent! exec 'highlight! '.l:retval.' guifg='.w:color | ||
52 | silent! exec 'highlight! '.l:retval.' ctermfg='.w:termcolor | ||
53 | |||
54 | return l:retval | ||
55 | endfunction | ||
56 | |||
57 | function! UpdateStatus(highlight_group) | ||
58 | let l:invert_group = CreateInvertGroup(a:highlight_group) | ||
59 | let l:mode = get({ | ||
60 | \ 'n' : 'normal', | ||
61 | \ 'i' : 'insert', | ||
62 | \ 'R' : 'replace', | ||
63 | \ 'v' : 'visual', | ||
64 | \ 'V' : 'visual line', | ||
65 | \ "\<C-V>" : 'visual block', | ||
66 | \ 'c' : 'command', | ||
67 | \ 's' : 'select', | ||
68 | \ 'S' : 'select line', | ||
69 | \ "\<C-s>" : 'select block', | ||
70 | \ 't' : 'terminal' | ||
71 | \ }, mode(), mode()) | ||
72 | return '' | ||
73 | \ .'%#StatusLineHighlight#' | ||
74 | \ .'%#'.a:highlight_group.'#' | ||
75 | \ .g:symbol_screen_edge | ||
76 | \ .'%{&buftype != "" ? " ".&buftype : ""}' | ||
77 | \ .' '.l:mode.g:status_sym_sep_start | ||
78 | \ .'%{argc() > 1 ? " ".(argidx() + 1).":".argc()." ".g:status_sym_sep_start : ""}' | ||
79 | \ .'%{haslocaldir() ? fnamemodify(getcwd(), ":.:~")." " :""}' | ||
80 | \ .'%{&readonly ? " 🔒" : ""}' | ||
81 | \ .'%{&modified ? " 💾 " : ""}' | ||
82 | \ .'%{" [".winbufnr(0)."] "}' | ||
83 | \ .'%{bufname("%") == "" ? "" : fnamemodify(expand("%"), ":~:.")}' | ||
84 | \ .'%{&titlestring ? has("nvim") ? b:term_title:expand(&titlestring) : "" }' | ||
85 | \ .'%{exists("w:quickfix_title") ? w:quickfix_title : ""}' | ||
86 | \ .' ' | ||
87 | \ .'%#'.l:invert_group.'#' | ||
88 | \ .g:status_sym_end | ||
89 | \ .'%<' | ||
90 | \ .'' | ||
91 | \ .'%=' | ||
92 | \ .'' | ||
93 | \ .'%#'.l:invert_group.'#' | ||
94 | \ .g:status_sym_start | ||
95 | \ .'%#'.a:highlight_group.'#'.' ' | ||
96 | \ .'%{&buftype == "" ? "" : &buftype." ".g:status_sym_sep_end." "}' | ||
97 | \ .'%{&filetype == "" ? "" :&filetype." ".g:status_sym_sep_end." "}' | ||
98 | \ .'%{&spell ? &spelllang." ".g:status_sym_sep_end : ""}' | ||
99 | \ .'%{&fileencoding =~ "^$\\|^utf\-8$" ? "" : &fileencoding." ".g:status_sym_sep_end." "}' | ||
100 | \ .'%{&fileformat =~ "^$\\|^unix$" ? "" : &fileformat." ".g:status_sym_sep_end}' | ||
101 | \ .' ' | ||
102 | \ .'%cx%-l: ' | ||
103 | \ .g:status_sym_sep_end | ||
104 | \ .' ' | ||
105 | \ .'%p%% ' | ||
106 | \ .g:symbol_screen_edge | ||
107 | \ .'%#NonText#' | ||
108 | endfunction | ||
109 | |||
110 | function! UpdateTabline(highlight_group) | ||
111 | let l:invert_group = CreateInvertGroup(a:highlight_group) | ||
112 | let l:git_branch = FugitiveHead() | ||
113 | return '' | ||
114 | \ .'%#'.a:highlight_group.'#' | ||
115 | \ .g:symbol_screen_edge | ||
116 | \ .' ' | ||
117 | \ .'%#'.a:highlight_group.'#' | ||
118 | \ .'%-2( %)' | ||
119 | \ .'%{fnamemodify(getcwd(-1), ":~")}' | ||
120 | \ .' ' | ||
121 | \ .'%{FugitiveHead() == "" ? "" : g:status_sym_sep_start." ".g:symbol_branch." ".FugitiveHead()}' | ||
122 | \ .' ' | ||
123 | \ .'%#'.l:invert_group.'#' | ||
124 | \ .g:status_sym_end | ||
125 | \ .'%<' | ||
126 | \ .'%=' | ||
127 | \ .'%#'.l:invert_group.'#' | ||
128 | \ .g:status_sym_start | ||
129 | \ .'%(%#'.a:highlight_group.'#%)' | ||
130 | \ .' ' | ||
131 | \ .'%-2(%)' | ||
132 | \ .'%(%#'.a:highlight_group.'#%)' | ||
133 | \ .'%(%{v:servername} %{v:this_session}%)' | ||
134 | \ .g:status_sym_sep_end.' ' | ||
135 | \ .'%-3(%)' | ||
136 | \ .'%#'.a:highlight_group.'#' | ||
137 | \ .'%{tabpagenr()}/%{tabpagenr()}' | ||
138 | \ .' ' | ||
139 | \ .g:symbol_screen_edge | ||
140 | \ .'%##' | ||
141 | endfunction | ||
142 | |||
143 | |||
144 | if $USER ==? 'root' | ||
145 | let highlight_group_root = "ErrorMsg" | ||
146 | let invert_group = CreateInvertGroup(highlight_group_root) | ||
147 | let g:group_tabline = highlight_group_root | ||
148 | endif | ||
149 | |||
150 | function! ApplyColorScheme() | ||
151 | " set termguicolors | " When on, uses highlight-guifg and highlight-guibg attributes in the terminal (=24bit color) incompatible with nvim | ||
152 | " set t_ut= | ||
153 | " set up statusline, global and current window individually | ||
154 | set statusline=%!UpdateStatus(g:group_inactive) | ||
155 | setlocal statusline=%!UpdateStatus(g:group_active) | ||
156 | " set up the tabline (match colors) | ||
157 | set tabline=%!UpdateTabline(g:group_tabline) | ||
158 | |||
159 | " otherwise 'bold' can mess up icon sizes and I do not know why | ||
160 | highlight! StatusLine cterm=reverse | ||
161 | " exec 'highlight! User3 guifg=#D2A032 guibg='.l:fgcolor | ||
162 | |||
163 | " workaround for VertSplit looking as a repeated slash, because its an | ||
164 | " italic bar... | ||
165 | highlight! VertSplit gui=NONE cterm=NONE term=NONE | ||
166 | endfunction | ||
167 | call ApplyColorScheme() | ||
168 | |||
169 | " apply colors from the loaded colorscheme... | ||
170 | " when changing the colorscheme also apply new colors to the statusbar... | ||
171 | autocmd ColorScheme * call ApplyColorScheme() | ||
172 | autocmd WinEnter * setlocal statusline=%!UpdateStatus(g:group_active) | ||
173 | autocmd WinLeave * setlocal statusline< | ||
174 | augroup END " MAX_FANCYLINE | ||
175 | |||
176 | " vim: shiftwidth=4 tabstop=4 expandtab softtabstop=4 | ||