sw.vim 1.2 KB
Newer Older
C
Cosmin Popescu 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
" MIT License. Copyright (c) 2013-2015 Bailey Ling.
" vim: et ts=2 sts=2 sw=2

" Due to some potential rendering issues, the use of the `space` variable is
" recommended.
let g:sw_airline_support = 1
let s:spc = g:airline_symbols.space
let s:airline_section_c = ''

" First we define an init function that will be invoked from extensions.vim
function! airline#extensions#sw#init(ext)
  " Here we define a new part for the plugin.  This allows users to place this
  " extension in arbitrary locations.
  call a:ext.add_statusline_func('airline#extensions#sw#apply')
endfunction

" This function will be invoked just prior to the statusline getting modified.
function! airline#extensions#sw#apply(...)
  if s:airline_section_c == ''
    let s:airline_section_c = g:airline_section_c
  endif

  if exists('b:sw_channel')
C
Cosmin Popescu 已提交
24
    let url = sw#server#get_buffer_url(fnamemodify(bufname('%'), ':p'))
C
Cosmin Popescu 已提交
25 26 27 28 29 30 31 32 33 34 35 36 37
    if url != ''
      let g:airline_section_c = s:airline_section_c . s:spc . g:airline_left_alt_sep . s:spc . url
      return
    else
      let g:airline_section_c = s:airline_section_c . s:spc . g:airline_left_alt_sep . s:spc . 'NOT CONNECTED'
      return 
    endif
  endif

  if (s:airline_section_c != '')
    let g:airline_section_c = s:airline_section_c
  endif
endfunction