Browse Source

update vimrc statusline

master
Dirk Alders 1 year ago
parent
commit
9695880948
1 changed files with 21 additions and 14 deletions
  1. 21
    14
      .vimrc

+ 21
- 14
.vimrc View File

@@ -76,21 +76,28 @@ set statusline+=%#NormalColor#%{(mode()=='n')?'\ \ NORMAL\ \ ':''}
76 76
 set statusline+=%#InsertColor#%{(mode()=='i')?'\ \ INSERT\ \ ':''}
77 77
 set statusline+=%#VisualColor#%{(mode()=='v')?'\ \ VISUAL\ \ ':''}
78 78
 set statusline+=%#CommandColor#%{(mode()=='c')?'\ \ COMMAND\ ':''}
79
-set statusline+=%#NormalColor#
80 79
 
81
-set statusline+=%f                           " file name
82
-set statusline+=[%{strlen(&fenc)?&fenc:'none'}, "file encoding
83
-set statusline+=%{&ff}] "file format
84
-set statusline+=%y      "filetype
85
-set statusline+=%h      "help file flag
86
-set statusline+=[%{getbufvar(bufnr('%'),'&mod')?'modified':'saved'}]
87
-"modified flag
88
-set statusline+=%r      "read only flag
89
-set statusline+=\ %=                        " align left
90
-set statusline+=Line:%l/%L[%p%%]            " line X of Y [percent of file]
91
-set statusline+=\ Col:%c                    " current column
92
-"set statusline+=\ Buf:%n                    " Buffer number
93
-set statusline+=\ [0x%B]\               " ASCII and byte code under cursor
80
+function! GitBranch()
81
+  return system("git rev-parse --abbrev-ref HEAD 2>/dev/null | tr -d '\n'")
82
+endfunction
83
+function! StatuslineGit()
84
+  let l:branchname = GitBranch()
85
+  return strlen(l:branchname) > 0?'  '.l:branchname.' ':''
86
+endfunction
87
+
88
+set statusline+=%#PmenuSel#                                   " Statusline format PmenuSel
89
+set statusline+=%{StatuslineGit()}                            " Git status
90
+set statusline+=%#NormalColor#                                " Statusline format NormalColor
91
+set statusline+=\ %f                                          " Filename
92
+set statusline+=\ %m                                          " Modified token
93
+set statusline+=%=                                            " Allign right
94
+set statusline+=%#CursorColumn#                               " Statusline format CursorColumn
95
+set statusline+=\ %y                                          " file type
96
+set statusline+=\ %{&fileencoding?&fileencoding:&encoding}    " encoding
97
+set statusline+=\[%{&fileformat}\]                            " file format
98
+set statusline+=\ %p%%                                        " line percent
99
+set statusline+=\ %l:%c                                       " line:column
100
+set statusline+=\ [0x%B]\                                     " ASCII hex code under cursor
94 101
 
95 102
 " Always show cursor position.
96 103
 "set ruler

Loading…
Cancel
Save