vim9lsp.vim 990 B

123456789101112131415161718192021222324252627
  1. " MIT License. Copyright (c) 2021 DEMAREST Maxime (maxime@indelog.fr)
  2. " Plugin: https://github.com/yegappan/lsp
  3. " vim: et ts=2 sts=2 sw=2
  4. scriptencoding utf-8
  5. if !exists('*lsp#lsp#ErrorCount')
  6. finish
  7. endif
  8. let s:error_symbol = get(g:, 'airline#extensions#vim9lsp#error_symbol', 'E:')
  9. let s:warning_symbol = get(g:, 'airline#extensions#vim9lsp#warning_symbol', 'W:')
  10. function! airline#extensions#vim9lsp#get_warnings() abort
  11. let res = get(lsp#lsp#ErrorCount(), 'Warn', 0)
  12. return res > 0 ? s:warning_symbol . res : ''
  13. endfunction
  14. function! airline#extensions#vim9lsp#get_errors() abort
  15. let res = get(lsp#lsp#ErrorCount(), 'Error', 0)
  16. return res > 0 ? s:error_symbol . res : ''
  17. endfunction
  18. function! airline#extensions#vim9lsp#init(ext) abort
  19. call airline#parts#define_function('vim9lsp_warning_count', 'airline#extensions#vim9lsp#get_warnings')
  20. call airline#parts#define_function('vim9lsp_error_count', 'airline#extensions#vim9lsp#get_errors')
  21. endfunction