Highlight VCS flags differently

"M" flag is highlighted in yellow, "A" flag is highlighted in green,
other flags are highlighted in red. This also corresponds with the
highlighting in the output of `git status`.

Whitespace is also trimmed from the flags as the columns don't matter
much in vim statuslines, and empty columns only introduce whitespace
that looks like a bug.
This commit is contained in:
Kim Silkebækken 2013-01-04 15:02:40 +01:00
parent 102e749093
commit 3addf44a6d
2 changed files with 11 additions and 2 deletions

View File

@ -58,7 +58,6 @@
"modified_indicator": { "fg": "brightyellow", "bg": "gray4", "attr": ["bold"] },
"paste_indicator": { "fg": "white", "bg": "mediumorange", "attr": ["bold"] },
"readonly_indicator": { "fg": "brightestred", "bg": "gray4" },
"file_vcs_status": { "fg": "brightestred", "bg": "gray4" },
"branch": { "fg": "gray9", "bg": "gray4" },
"file_directory": { "fg": "gray9", "bg": "gray4" },
"file_name": { "fg": "white", "bg": "gray4", "attr": ["bold"] },
@ -67,6 +66,9 @@
"file_format": { "fg": "gray8", "bg": "gray2" },
"file_encoding": { "fg": "gray8", "bg": "gray2" },
"file_type": { "fg": "gray8", "bg": "gray2" },
"file_vcs_status": { "fg": "brightestred", "bg": "gray4" },
"file_vcs_status_M": { "fg": "brightyellow", "bg": "gray4" },
"file_vcs_status_A": { "fg": "brightgreen", "bg": "gray4" },
"line_percent": { "fg": "gray9", "bg": "gray4" },
"line_percent_gradient1": { "fg": "gradient1", "bg": "gray4" },
"line_percent_gradient2": { "fg": "gradient2", "bg": "gray4" },

View File

@ -168,5 +168,12 @@ def file_vcs_status():
if vim.current.buffer.name and not vim.eval('&buftype'):
repo = guess(os.path.abspath(vim.current.buffer.name))
if repo:
return repo.status(os.path.relpath(vim.current.buffer.name, repo.directory))
status = repo.status(os.path.relpath(vim.current.buffer.name, repo.directory))
if not status:
return None
status = status.strip()
return {
'contents': status,
'highlight': ['file_vcs_status_' + status, 'file_vcs_status'],
}
return None