~yerinalexey/dotfiles

ref: 3bb7991839c26fe59674184fc6822f7477751f93 dotfiles/nvim/lightline.vim -rw-r--r-- 1.2 KiB
3bb79918Alexey Yerin river: decrease wob height 5 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
" Configuration for lightline

" Do not duplicate modes
set noshowmode

" Main configuration
let g:lightline = {
  \  'colorscheme': 'one',
  \  'active': {
  \    'left': [['mode', 'paste'], ['file']],
  \    'right': [['lineinfo'], ['percent'], ['filetype']],
  \  },
  \  'component_function': {
  \    'mode': 'LightlineMode',
  \    'file': 'LightlineFile'
  \  },
  \}

" 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

  let filename = expand('%:t')

  " Hide if file name is empty (new file)
  if filename == ''
    return ''
  endif

  let modified = &modified ? ' [+]' : ''

  let is_rdonly = ((&readonly || !&modifiable)
        \ && &filetype !=# 'help'
        \ && &filetype !=# 'man')
  let readonly = is_rdonly ? ' [RO]' : ''

  return filename . modified . readonly
endfunction

" Helper function to get plugin label (shown in mode component)
function! GetPluginLabel()
  if &filetype ==# 'vim-plug'
    return 'Plugins'
  endif

  return ''
endfunction