diff --git a/powerline/colorschemes/default.json b/powerline/colorschemes/default.json index bdcf2605..018b42fb 100644 --- a/powerline/colorschemes/default.json +++ b/powerline/colorschemes/default.json @@ -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" }, diff --git a/powerline/ext/vim/segments/core.py b/powerline/ext/vim/segments/core.py index 5de784b8..8e96653a 100644 --- a/powerline/ext/vim/segments/core.py +++ b/powerline/ext/vim/segments/core.py @@ -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():