summary refs log tree commit diff
path: root/.vim/plugin/line.vim
blob: 66072c35cd527dfc5bc9201bc51db4c911e003a7 (plain) (blame)
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
let g:lightline = {}
let g:lightline.colorscheme = 'papercolor_dim'

let g:lightline.enable = { 'statusline': 1, 'tabline': 1 }

let g:lightline.mode_map = {
\   'n' : 'N',
\   'i' : 'I',
\   'R' : 'R',
\   'v' : 'V',
\   'V' : 'V-LINE',
\   "\<C-v>": 'V-BLOCK',
\   'c' : '>',
\   's' : 'SELECT',
\   'S' : 'S-LINE',
\   "\<C-s>": 'S-BLOCK',
\   't': 'T',
\ }

let g:lightline.active = {
\   'left': [
\       ['mode', 'paste'],
\       ['filename', 'vista'],
\       ['neomake', 'coc', 'ctags', 'obsession'],
\   ],
\   'right': [
\       ['filetype', 'fileencoding', 'fileformat'],
\       ['lineinfo', 'percent'],
\       ['tabstatus'],
\   ],
\ }

set showtabline=2
let g:lightline.tabline = {
\   'right': [
\       ['tabs'],
\       ['porcelain'],
\   ],
\ }

let g:lightline.tab = {
\   'active': ['tabnum'],
\   'inactive': ['tabnum'],
\ }

let g:lightline.component = {
\   'lineinfo': ' %l:%v',
\   'filetype': "%{winwidth(0) > 70 ? (strlen(&filetype) ? &filetype : 'no ft') : ''}",
\   'dir': "%{substitute(expand('%:p:h'), $HOME, '~', '')}",
\ }

let g:lightline.component_function = {
\   'filename': 'LightLineFilename',
\   'fileformat': 'LightLineFileformat',
\   'fileencoding': 'LightLineFileencoding',
\   'mode': 'LightLineMode',
\   'vista': 'LightLineVista',
\   'o': 'LightLineO',
\   'porcelain': 'LightLinePorcelain',
\ }

" \ 'separator': { 'left': "\ue0b8", 'right': "\ue0be" },
" \ 'subseparator': { 'left': "\ue0b9", 'right': "\ue0b9" },
" \ 'tabline_separator': { 'left': "\ue0bc", 'right': "\ue0ba" },
" \ 'tabline_subseparator': { 'left': "\ue0bb", 'right': "\ue0bb" },
" \

let g:lightline.component_expand = {}
let g:lightline.component_type = {}


" Modified {{{
hi ModifiedColor ctermfg=196 guifg=#ff0000 gui=bold
function! LightLineModified()
  return &modified ? '+' : &modifiable ? '' : '-'
endfunction
" }}}

" Readonly {{{
function! LightLineReadonly()
  return &filetype !~? 'help\|vimfiler\|gundo' && &readonly ? '' : ''
endfunction
" }}}

" Filename {{{
function! LightLineFilename()
  return ('' !=? LightLineReadonly() ? LightLineReadonly() . ' ' : '') .
        \ (&filetype ==# 'vimfiler' ? vimfiler#get_status_string() :
        \  &filetype ==# 'unite' ? unite#get_status_string() :
        \  &filetype ==# 'vimshell' ? vimshell#get_status_string() :
        \ '' !=? expand('%:t') ? expand('%:t') : '[No Name]') .
        \ ('' !=? LightLineModified() ? ' ' . LightLineModified() : '')
endfunction
" }}}

" Fileformat {{{
function! LightLineFileformat()
  if (&fileformat == 'unix')
    return ''
  endif
  return winwidth(0) > 70 ? &fileformat : ''
endfunction
" }}}

" Fileencoding {{{
function! LightLineFileencoding()
  if (&fileencoding == 'utf-8')
    return ''
  endif
  return winwidth(0) > 70 ? (strlen(&fileencoding) ? &fileencoding : &encoding) : ''
endfunction
" }}}

" Mode {{{
function! LightLineMode()
  return winwidth(0) > 60 ? (
          \ expand('%:t') ==# '__Tagbar__' ? 'Tagbar':
          \ &filetype ==# 'vimfiler' ? 'VimFiler' :
          \ &filetype ==# 'vimshell' ? 'VimShell' :
          \ &filetype ==# 'dirvish' ? 'DIRVISH' :
          \ lightline#mode() )
          \ : ''
endfunction
" }}}

" Tabchar {{{
function! LightLineTabchar()
  return '[' 
    \   . &tabstop
    \   . (&expandtab == 1 ? '->' : '<>')
    \   . &shiftwidth
    \ . ']'
endfunction
" }}}

" Vista {{{
function! LightLineVista()
  let l:sym = get(b:, 'vista_nearest_method_or_function', '')
  return empty(l:sym) ? '' : g:vista#renderer#icons.function . ' ' . l:sym
endfunction
" }}}

" Porcelain {{{
function! LightLinePorcelain()
  if &buftype !=# 'terminal'
    let gitinfo = system('porcelain -no-color -path=' . expand('%:h'))
    return (v:shell_error ? '' : gitinfo)
  endif
endfunction
" }}}

function! LightLineO()
  let l:circ_empty="\u25CB"
  let l:circ_quart="\u25D4"
  let l:circ_half="\u25D1"
  let l:circ_threequart="\u25D5"
  let l:circ_full="\u25CF"
  return ('' != LightLineModified() ? l:circ_full : l:circ_empty)
endfunction