Fix vim segments for empty file names/directories

This commit is contained in:
Kim Silkebækken 2012-12-13 13:48:27 +01:00
parent 98337d26ec
commit 92324a6956
2 changed files with 16 additions and 3 deletions

View File

@ -59,6 +59,7 @@
"branch": { "fg": "gray9", "bg": "gray4" },
"file_directory": { "fg": "gray9", "bg": "gray4" },
"file_name": { "fg": "white", "bg": "gray4", "attr": ["bold"] },
"file_name_no_file": { "fg": "gray9", "bg": "gray4", "attr": ["bold"] },
"file_name_empty": { "fg": "gray9", "bg": "gray4" },
"file_format": { "fg": "gray8", "bg": "gray2" },
"file_encoding": { "fg": "gray8", "bg": "gray2" },

View File

@ -94,13 +94,25 @@ def branch():
def file_directory():
'''Return file directory (head component of the file path).
'''
return vim_funcs['expand']('%:~:.:h') + os.sep
file_directory = vim_funcs['expand']('%:~:.:h')
return file_directory + os.sep if file_directory else None
def file_name():
def file_name(display_no_file=False, no_file_text='[No file]'):
'''Return file name (tail component of the file path).
'''
return vim_funcs['expand']('%:~:.:t')
file_name = vim_funcs['expand']('%:~:.:t')
if not file_name and not display_no_file:
return None
if not file_name:
return {
'contents': no_file_text,
'highlight': ['file_name_no_file', 'file_name'],
}
return file_name
def file_format():