From 97ee25e786b572a3e3beff762c1c6bb424328617 Mon Sep 17 00:00:00 2001 From: plrectco Date: Fri, 13 Sep 2019 13:20:37 -0700 Subject: [PATCH] add smart path to status line --- vimrcs/google.vim | 2 +- vimrcs/plugins_config.vim | 31 ++++++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/vimrcs/google.vim b/vimrcs/google.vim index f2eeeccd..4ef15905 100644 --- a/vimrcs/google.vim +++ b/vimrcs/google.vim @@ -40,7 +40,7 @@ command Headerfix call HeaderFix() command Headerquery call HeaderQuery() -let localleader=, +let localleader="," nnoremap hf :Headerfix nnoremap hq :Headerquery diff --git a/vimrcs/plugins_config.vim b/vimrcs/plugins_config.vim index 9ad74d4a..14b688b8 100644 --- a/vimrcs/plugins_config.vim +++ b/vimrcs/plugins_config.vim @@ -121,7 +121,7 @@ let g:lightline = { \ 'colorscheme': 'wombat', \ 'active': { \ 'left': [ ['mode', 'paste'], - \ ['fugitive', 'readonly', 'absolutepath', 'filename', 'modified'] ], + \ ['fugitive', 'readonly', 'SmartFilePath', 'filename', 'modified'] ], \ 'right': [ [ 'lineinfo' ], ['percent'] ] \ }, \ 'component': { @@ -134,10 +134,39 @@ let g:lightline = { \ 'modified': '(&filetype!="help"&&(&modified||!&modifiable))', \ 'fugitive': '(exists("*fugitive#head") && ""!=fugitive#head())' \ }, + \ 'component_function': { + \ 'SmartFilePath': 'GetSmartFilePath' + \ }, \ 'separator': { 'left': ' ', 'right': ' ' }, \ 'subseparator': { 'left': ' ', 'right': ' ' } \ } +function! GetSmartFilePath() + let path = expand('%:p:h') + " If in google3 path, display the client name and the absolute path + if matchstr(path, 'google3') == 'google3' + let output = '' + let subs = split(path, '/') + let add_to_output = 0 + let prev_s = '' + for s in subs + if add_to_output == 1 + let output .= '/' + let output .= s + endif + if s == 'google3' + let output .= prev_s + let output .= ':' + let add_to_output = 1 + endif + let prev_s = s + endfor + return output + else + return path + endif +endfunction + """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Vimroom """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""