~yerinalexey/dotfiles

ref: b75055cfb2820b41efd348481e49a2f487355931 dotfiles/nvim/lightline.vim -rw-r--r-- 1.6 KiB
b75055cf — Alexey Yerin bottom: fix indents 1 year, 2 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
"" Configuration for lightline

" Do not duplicate modes
set noshowmode

" Main configuration
let g:lightline = {
  \  'colorscheme': 'onedark',
  \  'active': {
  \    'left': [['mode', 'paste'], ['git_branch'], ['file']],
  \    'right': [['lineinfo'], ['percent'], ['filetype']],
  \  },
  \  'component_function': {
  \    'git_branch': 'LightlineGitBranch',
  \    'mode': 'LightlineMode',
  \    'file': 'LightlineFile'
  \  },
  \  'separator': { 'left': '', 'right': '' },
  \  'subseparator': { 'left': '', 'right': '' },
  \}

" Show git branch along with a branch icon
function! LightlineGitBranch()
  let branch = FugitiveHead()

  if branch != ''
    return ' ' . branch
  endif

  return ''
endfunction

" Mode indicator
function! LightlineMode()
  let label = GetPluginLabel()

  return label == '' ? lightline#mode() : label
endfunction

" File name + others
function! LightlineFile()
  " Hide if using a plugin's window
  if GetPluginLabel() != ''
    return ''
  endif

  " Hide if file name is empty (new file)
  let filename = expand('%:t')

  if filename == ''
    return ''
  endif

  let modified = &modified ? ' פֿ' : ''
  let readonly = ((&readonly || !&modifiable) && &filetype !=# 'help') ? ' ' : ''

  let icon = nerdfont#find() . ' '

  return icon . filename . modified . readonly
endfunction

" Helper function to get plugin label (shown in mode component)
function! GetPluginLabel()
  if &filetype ==# 'fugitive'
    return 'Git'
  endif

  if &filetype ==# 'vim-plug'
    return 'Plugins'
  endif

  if expand('%:t') =~# '^__coc_refactor_.*'
    return 'Refactor'
  endif

  return ''
endfunction