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.

161 lines
4.3 KiB

  1. let g:lightline = {
  2. \ 'colorscheme': 'material_vim',
  3. \ 'active': {
  4. \ 'left': [ [ 'mode', 'paste' ], [ 'readonly', 'filename', 'modified' ] ],
  5. \ 'right':[[ 'filetype', 'percent', 'lineinfo' ], [ 'cocstatus' ]]
  6. \ },
  7. \ 'tabline': {
  8. \ 'left': [['explorer_pad'], ['buffers']],
  9. \ 'right': [['gitbranch', 'smarttabs']]
  10. \ },
  11. \ 'component_expand': {
  12. \ 'buffers': 'lightline#bufferline#buffers',
  13. \ 'smarttabs': 'SmartTabsIndicator',
  14. \ 'trailing': 'lightline#trailing_whitespace#component'
  15. \ },
  16. \ 'component_function': {
  17. \ 'explorer_pad': 'lightline#explorer_pad#left_pad',
  18. \ 'percent': 'LightlinePercent',
  19. \ 'lineinfo': 'LightlineLineinfo',
  20. \ 'filename': 'LightlineFilename',
  21. \ 'fullname': 'LightlineFullname',
  22. \ 'mode': 'LightlineMode',
  23. \ 'gitbranch': 'LightlineGitbranch',
  24. \ 'readonly': 'LightlineReadonly',
  25. \ 'modified': 'LightlineModified',
  26. \ 'filetype': 'LightlineFiletype',
  27. \ 'cocstatus': 'LightlineCoc',
  28. \ },
  29. \ 'component_type': {
  30. \ 'buffers': 'tabsel',
  31. \ 'trailing': 'warning'
  32. \ },
  33. \ }
  34. function! s:trim(maxlen, str) abort
  35. let trimed = len(a:str) > a:maxlen ? a:str[0:a:maxlen] . '..' : a:str
  36. return trimed
  37. endfunction
  38. function! LightlineCoc() abort
  39. if winwidth(0) < 60
  40. return ''
  41. endif
  42. return coc#status()
  43. endfunction
  44. function! LightlinePercent() abort
  45. if winwidth(0) < 60
  46. return ''
  47. endif
  48. let l:percent = line('.') * 100 / line('$') . '%'
  49. return printf('%-4s', l:percent)
  50. endfunction
  51. function! LightlineLineinfo() abort
  52. if winwidth(0) < 86
  53. return ''
  54. endif
  55. let l:current_line = printf('%-3s', line('.'))
  56. let l:max_line = printf('%-3s', line('$'))
  57. let l:lineinfo = ' ' . l:current_line . '/' . l:max_line
  58. return l:lineinfo
  59. endfunction
  60. function! LightlineFilename() abort
  61. let l:prefix = expand('%:p') =~? "fugitive://" ? '(fugitive) ' : ''
  62. let l:maxlen = winwidth(0) - winwidth(0) / 2
  63. let l:relative = expand('%:.')
  64. let l:tail = expand('%:t')
  65. let l:noname = 'No Name'
  66. if winwidth(0) < 50
  67. return ''
  68. endif
  69. if winwidth(0) < 86
  70. return l:tail ==# '' ? l:noname : l:prefix . s:trim(l:maxlen, l:tail)
  71. endif
  72. return l:relative ==# '' ? l:noname : l:prefix . s:trim(l:maxlen, l:relative)
  73. endfunction
  74. function! LightlineFullname() abort
  75. let l:relative = expand('%')
  76. return l:relative
  77. endfunction
  78. function! LightlineModified() abort
  79. return &modified ? '*' : ''
  80. endfunction
  81. function! LightlineMode() abort
  82. let ftmap = {
  83. \ 'coc-explorer': 'EXPLORER',
  84. \ 'fugitive': 'FUGITIVE',
  85. \ 'vista': 'OUTLINE'
  86. \ }
  87. return get(ftmap, &filetype, lightline#mode())
  88. endfunction
  89. let g:lightline.component_function = { 'lineinfo': 'LightlineLineinfo' }
  90. function! LightlineLineinfo() abort
  91. if winwidth(0) < 86
  92. return ''
  93. endif
  94. let l:current_line = printf('%-3s', line('.'))
  95. let l:max_line = printf('%-3s', line('$'))
  96. let l:lineinfo = ' ' . l:current_line . '/' . l:max_line
  97. return l:lineinfo
  98. endfunction
  99. function! LightlineReadonly() abort
  100. let ftmap = {
  101. \ 'coc-explorer': '',
  102. \ 'fugitive': '',
  103. \ 'vista': ''
  104. \ }
  105. let l:char = get(ftmap, &filetype, '')
  106. return &readonly ? l:char : ''
  107. endfunction
  108. function! LightlineGitbranch() abort
  109. if exists('*fugitive#head')
  110. let maxlen = 20
  111. let branch = fugitive#head()
  112. return branch !=# '' ? ' '. s:trim(maxlen, branch) : ''
  113. endif
  114. return fugitive#head()
  115. endfunction
  116. function! LightlineFiletype() abort
  117. let l:icon = WebDevIconsGetFileTypeSymbol()
  118. return winwidth(0) > 86 ? (strlen(&filetype) ? &filetype . ' ' . l:icon : l:icon) : ''
  119. endfunction
  120. function! String2()
  121. return 'BUFFERS'
  122. endfunction
  123. function! SmartTabsIndicator() abort
  124. let tabs = lightline#tab#tabnum(tabpagenr())
  125. let tab_total = tabpagenr('$')
  126. return tabpagenr('$') > 1 ? ('TABS ' . tabs . '/' . tab_total) : ''
  127. endfunction
  128. " autoreload
  129. command! LightlineReload call LightlineReload()
  130. function! LightlineReload() abort
  131. call lightline#init()
  132. call lightline#colorscheme()
  133. call lightline#update()
  134. endfunction
  135. let g:lightline#trailing_whitespace#indicator = ''