~mlb/dotfiles

ref: d0bd096ba4445c78e96fae40cef2a79f7e6ab485 dotfiles/nvim/conf/50-lightline.vim -rw-r--r-- 4.4 KiB
d0bd096bMatías Larre Borges [ZSH] Add asdf integration 9 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
" Lightline config {{{
set showtabline=2
let g:lightline = {}
let g:lightline.colorscheme = 'purify'
let g:lightline.separator = { 'left': "\ue0b8", 'right': "\ue0be" }
let g:lightline.subseparator = { 'left': "\ue0b9", 'right': "\ue0b9" }
let g:lightline.tabline_separator = { 'left': "\ue0bc", 'right': "\ue0ba" }
let g:lightline.tabline_subseparator = { 'left': "\ue0bb", 'right': "\ue0bb" }
let g:lightline.inactive = {
            \ 'left': [ [ 'relativepath' ] ],
            \ 'right': [ [ 'percent' ] ],
            \}
let g:lightline.active = {
            \ 'left': [ [ 'mode', 'paste', ],
            \           [ 'gitbranch', 'readonly', 'relativepath', 'modified' ],
            \           [ 'currentFunc' ] ],
            \ 'right': [ [ 'lineinfo' ],
            \            [ 'devicons_filetype', 'devicons_fileformat'],
            \            [ 'obsession' ],
            \            [ 'coc_error', 'coc_warning' ] ]
            \}

let g:lightline.tabline = {
            \ 'left': [ [ 'vim_logo', 'tabs' ] ],
            \ 'right': [ ['myCurrentDir'],
            \            [ 'gitstatus' ] ]
            \ }

let g:lightline.component = {
            \ 'myCurrentDir': "\uf413 %{fnamemodify(getcwd(), ':t')}",
            \ 'currentFunc': '%{CocCurrentFunction()}',
            \ 'obsession': '%{ObsessionStatusEnhance()}',
            \ 'gitstatus': '%{lightline_gitdiff#get_status()}',
            \ 'bufinfo': '%{bufname("%")}:%{bufnr("%")}',
            \ 'vim_logo': "\ue7c5",
            \ 'mode': '%{lightline#mode()}',
            \ 'absolutepath': '%F',
            \ 'relativepath': '%f',
            \ 'filename': '%t',
            \ 'filesize': "%{HumanSize(line2byte('$') + len(getline('$')))}",
            \ 'fileencoding': '%{&fenc!=#""?&fenc:&enc}',
            \ 'fileformat': '%{&fenc!=#""?&fenc:&enc}[%{&ff}]',
            \ 'filetype': '%{&ft!=#""?&ft:"no ft"}',
            \ 'modified': '%M',
            \ 'bufnum': '%n',
            \ 'paste': '%{&paste?"PASTE":""}',
            \ 'readonly': '%R',
            \ 'charvalue': '%b',
            \ 'charvaluehex': '%B',
            \ 'percent': '%2p%%',
            \ 'percentwin': '%P',
            \ 'spell': '%{&spell?&spelllang:""}',
            \ 'lineinfo': '%2p%% %3l:%-2v',
            \ 'line': '%l',
            \ 'column': '%c',
            \ 'close': '%999X X ',
            \ 'winnr': '%{winnr()}'
            \ }
function! LightlineFugitive()
    if exists('*FugitiveHead')
        let branch = FugitiveHead()
        return branch !=# '' ? ' '.branch : ''
    endif
    return ''
endfunction
let g:lightline_gitdiff#indicator_added = "\uf067"
let g:lightline_gitdiff#indicator_deleted = "\uf068"
let g:lightline_gitdiff#indicator_modified = "\uf12a"

function! CocCurrentFunction()
    let currentFunctionSymbol = get(b:, 'coc_current_function', '')
    " See :h lightline expand_component & https://github.com/itchyny/lightline.vim/issues/236
    " return currentFunctionSymbol !=# '' ? "%%#LineNr#%% \uf6a6 " .currentFunctionSymbol : ''
    " return currentFunctionSymbol !=# '' ? "\uf6a6 " .currentFunctionSymbol : ''
    return currentFunctionSymbol !=# '' ? "\ufb26 [" . currentFunctionSymbol . ']' : ''
endfunction


function! CocError() abort
  let info = get(b:, 'coc_diagnostic_info', {})
  if empty(info) | return '' | endif
  if get(info, 'error', 0)
    return "\u2716 " . info['error']
  else
    return ''
  endif
endfunction

function! CocWarning() abort
  let info = get(b:, 'coc_diagnostic_info', {})
  if empty(info) | return '' | endif
  if get(info, 'warning', 0)
    return "\uf071 " . info['warning']
  else
    return ''
  endif
endfunction

let g:lightline.component_function = {
            \ 'gitbranch': 'LightlineFugitive',
            \ 'devicons_filetype': 'WebDevIconsGetFileTypeSymbol',
            \ 'devicons_fileformat': 'WebDevIconsGetFileFormatSymbol',
            \ }

let g:lightline.component_expand = {
            \ 'coc_error': 'CocError',
            \ 'coc_warning': 'CocWarning'
            \ }
let g:lightline.component_type = {
            \ 'coc_error': 'error',
            \ 'coc_warning': 'warning'
            \}

let g:lightline.component_visible_condition = {
            \ 'gitstatus': 'lightline_gitdiff#get_status() !=# ""'
            \}
" }}}

" Helper functions {{{

function! ObsessionStatusEnhance()
    let obsStatus = ObsessionStatus("\uf04b","\uf04c")
    if obsStatus !=# ""
        return obsStatus
    else
        return "\uf04d"
    endif
endfunction

" }}}