Default to mode() if not in dictionary
dblume

dblume commited on 2023-12-17 21:43:08
Showing 1 changed files, with 12 additions and 12 deletions.

... ...
@@ -94,8 +94,8 @@ function! StatuslineGit()
94 94
   return strlen(l:branchname) > 0 ? ' | branch:'.l:branchname : ''
95 95
 endfunction
96 96
 
97
-"    \ '' : 'S·BLOCK',
98
-let g:currentmode={
97
+function! Current_mode()
98
+  let l:currentmode={
99 99
     \ 'n'  : 'NORMAL',
100 100
     \ 'v'  : 'VISUAL',
101 101
     \ 'V'  : 'V·LINE',
... ...
@@ -103,11 +103,13 @@ let g:currentmode={
103 103
     \ 's'  : 'SELECT',
104 104
     \ 'S'  : 'S·LINE',
105 105
     \ 'i'  : 'INSERT',
106
-    \ 'r'  : 'replace',
106
+    \ 'r'  : 'I·REPLACE',
107 107
     \ 'R'  : 'REPLACE',
108 108
     \ 'Rv' : 'V·REPLACE',
109 109
     \ 'c'  : 'COMMAND',
110 110
     \}
111
+    return get(l:currentmode, mode(), mode())
112
+endfunction
111 113
 
112 114
 function! Trim_brackets(fn)
113 115
   if v:version > 800
... ...
@@ -117,22 +119,20 @@ function! Trim_brackets(fn)
117 119
   endif
118 120
 endfunction
119 121
 
120
-set statusline=
121
-set statusline+=\ %{g:currentmode[mode()]}
122
+set statusline=\ %{Current_mode()}
122 123
 set statusline+=%{&paste?'\ \ ·\ PASTE':''}
123 124
 "set statusline+=%{StatuslineGit()}
124 125
 set statusline+=\ \|\ %f
125
-set statusline+=%m\ 
126
-set statusline+=%r\ 
127
-set statusline+=%=
126
+set statusline+=%m
127
+set statusline+=\ %r
128
+set statusline+=\ %=
128 129
 set statusline+=%h
129
-set statusline+=\ %{Trim_brackets(&filetype)}\ 
130
-set statusline+=%#StatusLineNC#
130
+set statusline+=\ %{Trim_brackets(&filetype)}
131
+set statusline+=\ %#StatusLineNC#
131 132
 set statusline+=\ %{&fileencoding?&fileencoding:&encoding}
132 133
 set statusline+=\[%{&fileformat}\]
133 134
 set statusline+=\ \|\ %p%%\ Ξ
134
-set statusline+=\ %l/%L\ :\ %c
135
-set statusline+=\ 
135
+set statusline+=\ %l/%L\ :\ %c\ 
136 136
 
137 137
 set encoding=utf-8
138 138
 
139 139