Another copy of my dotfiles. Because I don't completely trust GitHub.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.6 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. let g:lightline = {
  2. \ 'colorscheme': 'material_vim',
  3. \ 'active': {
  4. \ 'right': [ [ 'lineinfo' ], [ 'percent', 'wordcount' ], [ 'fileformat', 'fileencoding', 'filetype' ] ],
  5. \ 'left': [ [ 'mode', 'paste' ], [ 'readonly', 'filename', 'modified' ] ],
  6. \ },
  7. \ 'component_function': {
  8. \ 'wordcount': 'WordCount',
  9. \ },
  10. \ 'tabline': {
  11. \ 'left': [ ['buffers'] ],
  12. \ 'right': [ ['close'] ],
  13. \ },
  14. \ 'component_expand': {
  15. \ 'buffers': 'lightline#bufferline#buffers',
  16. \ },
  17. \ 'component_type': {
  18. \ 'buffers': 'tabsel',
  19. \ }
  20. \ }
  21. function! WordCount()
  22. let currentmode = mode()
  23. if !exists("g:lastmode_wc")
  24. let g:lastmode_wc = currentmode
  25. endif
  26. " if we modify file, open a new buffer, be in visual ever, or switch modes
  27. " since last run, we recompute.
  28. if &modified || !exists("b:wordcount") || currentmode =~? '\c.*v' || currentmode != g:lastmode_wc
  29. let g:lastmode_wc = currentmode
  30. let l:old_position = getpos('.')
  31. let l:old_status = v:statusmsg
  32. execute "silent normal g\<c-g>"
  33. if v:statusmsg == "--No lines in buffer--"
  34. let b:wordcount = 0
  35. else
  36. let s:split_wc = split(v:statusmsg)
  37. if index(s:split_wc, "Selected") < 0
  38. let b:wordcount = str2nr(s:split_wc[11])
  39. else
  40. let b:wordcount = str2nr(s:split_wc[5])
  41. endif
  42. let v:statusmsg = l:old_status
  43. endif
  44. call setpos('.', l:old_position)
  45. return b:wordcount
  46. else
  47. return b:wordcount
  48. endif
  49. endfunction
  50. let g:lightline#trailing_whitespace#indicator = ''