From 0037cb5c6f8addc33b93026fa8082795508d6a3d Mon Sep 17 00:00:00 2001 From: Paul-Christian Volkmer Date: Thu, 20 Jan 2022 12:48:33 +0100 Subject: [PATCH] Add label configuration for git dir status --- README.md | 12 +++++++++++- autoload/fugistate.vim | 12 ++++-------- plugin/fugistate.vim | 12 ++++++++++++ 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index ea0e9b1..d4a1d93 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ It will show something like `main.c [ M]` for modified file `main.c`. :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), 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 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 This software is released under the MIT License, see LICENSE. diff --git a/autoload/fugistate.vim b/autoload/fugistate.vim index 5ea058f..8cec7e0 100644 --- a/autoload/fugistate.vim +++ b/autoload/fugistate.vim @@ -53,20 +53,16 @@ function! fugistate#gitdir() let s:out = [] - if s:changed == 1 - call add(s:out, "1 change") - endif - - if s:changed > 1 - call add(s:out, s:changed . " changes") + if s:changed > 0 + call add(s:out, s:changed . " " . g:fugistate_label_changed) endif if s:new > 0 - call add(s:out, s:new . " new") + call add(s:out, s:new . " " . g:fugistate_label_new) endif if s:unversioned > 0 - call add(s:out, s:unversioned . " unversioned") + call add(s:out, s:unversioned . " " . g:fugistate_label_unversioned) endif return join(s:out, ', ') diff --git a/plugin/fugistate.vim b/plugin/fugistate.vim index eca1447..582f353 100644 --- a/plugin/fugistate.vim +++ b/plugin/fugistate.vim @@ -11,6 +11,18 @@ if ! exists('g:fugistate_expand_filename') let g:fugistate_expand_filename = '%:t' 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 autocmd! autocmd BufEnter,BufWritePost,FocusGained * :call fugistate#update()