1
0
mirror of https://github.com/pcvolkmer/vim-fugistate.git synced 2025-04-19 15:26:50 +00:00

Add label configuration for git dir status

This commit is contained in:
Paul-Christian Volkmer 2022-01-20 12:48:33 +01:00
parent b47b8091da
commit 0037cb5c6f
3 changed files with 27 additions and 9 deletions

View File

@ -14,7 +14,7 @@ It will show something like `main.c [ M]` for modified file `main.c`.
:echo FugiStateGitDir() :echo FugiStateGitDir()
``` ```
This will show changes, new and unversioned files, e.g. `1 change, 2 new, 3 unversioned`. This will show changes, new and unversioned files, e.g. `1 changed, 2 new, 3 unversioned`.
For example, to show the filename with git status using [lightline.vim](https://github.com/itchyny/lightline.vim), For example, to show the filename with git status using [lightline.vim](https://github.com/itchyny/lightline.vim),
configure as follows. configure as follows.
@ -37,5 +37,15 @@ The plugin provides `g:fugistate_expand_filename` to modify the value the filena
Default value is set to `'%:t'` and will show filename without path. Use available values like `'%:p'` for full path Default value is set to `'%:t'` and will show filename without path. Use available values like `'%:p'` for full path
or `''` to use `@%` for directory/filename relative to current working directory. or `''` to use `@%` for directory/filename relative to current working directory.
### Labels
If you want other labels than `changed`, `new` and `unversioned`, add this to your vim config.
```vim
let g:fugistate_label_changed = '✹'
let g:fugistate_label_new = '✚'
let g:fugistate_label_unversioned = '★'
```
## License ## License
This software is released under the MIT License, see LICENSE. This software is released under the MIT License, see LICENSE.

View File

@ -53,20 +53,16 @@ function! fugistate#gitdir()
let s:out = [] let s:out = []
if s:changed == 1 if s:changed > 0
call add(s:out, "1 change") call add(s:out, s:changed . " " . g:fugistate_label_changed)
endif
if s:changed > 1
call add(s:out, s:changed . " changes")
endif endif
if s:new > 0 if s:new > 0
call add(s:out, s:new . " new") call add(s:out, s:new . " " . g:fugistate_label_new)
endif endif
if s:unversioned > 0 if s:unversioned > 0
call add(s:out, s:unversioned . " unversioned") call add(s:out, s:unversioned . " " . g:fugistate_label_unversioned)
endif endif
return join(s:out, ', ') return join(s:out, ', ')

View File

@ -11,6 +11,18 @@ if ! exists('g:fugistate_expand_filename')
let g:fugistate_expand_filename = '%:t' let g:fugistate_expand_filename = '%:t'
endif endif
if ! exists('g:fugistate_label_changed')
let g:fugistate_label_changed = 'changed'
endif
if ! exists('g:fugistate_label_new')
let g:fugistate_label_new = 'new'
endif
if ! exists('g:fugistate_label_unversioned')
let g:fugistate_label_unversioned = 'unversioned'
endif
augroup FugiState augroup FugiState
autocmd! autocmd!
autocmd BufEnter,BufWritePost,FocusGained * :call fugistate#update() autocmd BufEnter,BufWritePost,FocusGained * :call fugistate#update()