denite.vim 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. " MIT License. Copyright (c) 2017 Thomas Dy
  2. " vim: et ts=2 sts=2 sw=2
  3. scriptencoding utf-8
  4. if !get(g:, 'loaded_denite', 0)
  5. finish
  6. endif
  7. " Denite does not use vim's built-in modal editing but has a custom prompt
  8. " that implements its own insert/normal mode so we have to handle changing the
  9. " highlight
  10. function! airline#extensions#denite#check_denite_mode(bufnr)
  11. let l:mode = split(denite#get_status_mode(), ' ')
  12. let l:mode = tolower(l:mode[1])
  13. call airline#highlighter#highlight([l:mode], a:bufnr)
  14. return ''
  15. endfunction
  16. function! airline#extensions#denite#apply(...)
  17. if &ft == 'denite'
  18. call a:1.add_section('airline_a', ' Denite %{airline#extensions#denite#check_denite_mode('.a:2['bufnr'].')}')
  19. call a:1.add_section('airline_c', ' %{denite#get_status_sources()}')
  20. call a:1.split()
  21. call a:1.add_section('airline_y', ' %{denite#get_status_path()} ')
  22. call a:1.add_section('airline_z', ' %{denite#get_status_linenr()} ')
  23. return 1
  24. endif
  25. endfunction
  26. function! airline#extensions#denite#init(ext)
  27. call denite#custom#option('_', 'statusline', 0)
  28. call a:ext.add_statusline_func('airline#extensions#denite#apply')
  29. " The denite window does not have FileType denite when it's created
  30. " so we have to manually update statusline when the FileType is set
  31. augroup airline_denite
  32. autocmd!
  33. autocmd FileType denite call airline#update_statusline()
  34. augroup END
  35. endfunction