Update vim statusline to prepare to stop using vim-airline
dblume

dblume commited on 2023-11-13 19:38:23
Showing 1 changed files, with 44 additions and 23 deletions.

... ...
@@ -1,4 +1,4 @@
1
-" Version 2023-04-26.1 - Harmonize the git commands for common recipes
1
+" Version 2023-11-13.1 - Prep to stop using vim-airline
2 2
 set nocompatible    " Use Vim defaults, forget compatibility with vi.
3 3
 set bs=2            " allow backspacing over everything in insert mode
4 4
 set wildmenu        " Allows command-line completion with tab
... ...
@@ -39,20 +39,6 @@ nnoremap <C-j> <C-w>j
39 39
 nnoremap <C-k> <C-w>k
40 40
 nnoremap <C-l> <C-w>l
41 41
 
42
-" https://levelup.gitconnected.com/7-surprising-vim-tricks-that-will-save-you-hours-b158d23fe9b7
43
-"nnoremap d "_d
44
-"nnoremap D "_D
45
-"nnoremap c "_c
46
-"nnoremap C "_C
47
-"nnoremap x "_x
48
-"nnoremap X "_X
49
-"nnoremap <leader>d d
50
-"nnoremap <leader>D D
51
-"nnoremap <leader>c c
52
-"nnoremap <leader>C C
53
-"nnoremap <leader>x x
54
-"nnoremap <leader>X X
55
-
56 42
 " clear search highlights
57 43
 nnoremap <cr> :noh<cr><cr>
58 44
 
... ...
@@ -99,15 +85,50 @@ endif
99 85
 set tags=tags;/
100 86
 
101 87
 set history=50
102
-set ruler
103
-if has('statusline')
104 88
 set laststatus=2
105
-  set statusline=%<%f\   " Filename
106
-  set statusline+=%w%h%m%r " Options
107
-  "set statusline+=%{fugitive#statusline()} " Git
108
-  set statusline+=\[%{&ff}/%Y]              " filetype
109
-  set statusline+=%=%-12.(%l,%c%V%)\ %p%%   " Right aligned file nav info
110
-endif
89
+
90
+function! StatuslineGit()
91
+  let l:branchname = system("git rev-parse --abbrev-ref HEAD 2>/dev/null | tr -d '\n'")
92
+  return strlen(l:branchname) > 0 ? ' | branch:'.l:branchname : ''
93
+endfunction
94
+
95
+"    \ '' : 'S·BLOCK',
96
+let g:currentmode={
97
+    \ 'n'  : 'NORMAL',
98
+    \ 'v'  : 'VISUAL',
99
+    \ 'V'  : 'V·LINE',
100
+    \ '' : 'V·BLOCK',
101
+    \ 's'  : 'SELECT',
102
+    \ 'S'  : 'S·LINE',
103
+    \ 'i'  : 'INSERT',
104
+    \ 'R'  : 'REPLACE',
105
+    \ 'Rv' : 'V·REPLACE',
106
+    \ 'c'  : 'COMMAND',
107
+    \}
108
+
109
+function! Trim_brackets(fn)
110
+  return trim(a:fn, "[]")
111
+endfunction
112
+
113
+au InsertEnter * hi statusline guibg=Cyan ctermfg=26 guifg=Black ctermbg=7
114
+au InsertLeave * hi StatusLine term=bold,reverse cterm=bold,reverse ctermfg=24 ctermbg=7 guifg=black guibg=#c2bfa5
115
+
116
+set statusline=
117
+set statusline+=\ %{g:currentmode[mode()]}
118
+set statusline+=%{&paste?'\ \ ·\ PASTE':''}
119
+"set statusline+=%{StatuslineGit()}
120
+set statusline+=\ \|\ %f
121
+set statusline+=%m\ 
122
+set statusline+=%r\ 
123
+set statusline+=%=
124
+set statusline+=%h
125
+set statusline+=\ %{Trim_brackets(&filetype)}\ 
126
+set statusline+=%#StatusLineNC#
127
+set statusline+=\ %{&fileencoding?&fileencoding:&encoding}
128
+set statusline+=\[%{&fileformat}\]
129
+set statusline+=\ \|\ %p%%\ Ξ
130
+set statusline+=\ %l/%L\ :\ %c
131
+set statusline+=\ 
111 132
 
112 133
 set encoding=utf-8
113 134
 
114 135