localsearch.vim 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. " MIT License. Copyright (c) 2018-2021 mox et al.
  2. " Plugin: https://github.com/mox-mox/vim-localsearch
  3. " vim: et ts=2 sts=2 sw=2
  4. scriptencoding utf-8
  5. let s:enabled = get(g:, 'airline#extensions#localsearch#enabled', 1)
  6. if !get(g:, 'loaded_localsearch', 0) || !s:enabled || get(g:, 'airline#extensions#localsearch#loaded', 0)
  7. finish
  8. endif
  9. let g:airline#extensions#localsearch#loaded = 001
  10. let s:spc = g:airline_symbols.space
  11. let g:airline#extensions#localsearch#inverted = get(g:, 'airline#extensions#localsearch#inverted', 0)
  12. function! airline#extensions#localsearch#load_theme(palette) abort
  13. call airline#highlighter#exec('localsearch_dark', [ '#ffffff' , '#000000' , 15 , 1 , ''])
  14. endfunction
  15. function! airline#extensions#localsearch#init(ext) abort
  16. call a:ext.add_theme_func('airline#extensions#localsearch#load_theme')
  17. call a:ext.add_statusline_func('airline#extensions#localsearch#apply')
  18. endfunction
  19. function! airline#extensions#localsearch#apply(...) abort
  20. " first variable is the statusline builder
  21. let builder = a:1
  22. """"" WARNING: the API for the builder is not finalized and may change
  23. if exists('#localsearch#WinEnter') && !g:airline#extensions#localsearch#inverted " If localsearch mode is enabled and 'invert' option is false
  24. call builder.add_section('localsearch_dark', s:spc.airline#section#create('LS').s:spc)
  25. endif
  26. if !exists('#localsearch#WinEnter') && g:airline#extensions#localsearch#inverted " If localsearch mode is disabled and 'invert' option is true
  27. call builder.add_section('localsearch_dark', s:spc.airline#section#create('GS').s:spc)
  28. endif
  29. return 0
  30. endfunction