Skip to content

Commit

Permalink
try catch in lightline#link (in case so $MYVIMRC, related to morhetz#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
itchyny committed Aug 27, 2013
1 parent 9313084 commit 465b6d2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ function! MyModified()
endfunction
function! MyReadonly()
return &ft !~? 'help\|vimfiler\|gundo' && &ro ? '⭤' : ''
return &ft !~? 'help\|vimfiler\|gundo' && &readonly ? '⭤' : ''
endfunction
function! MyFilename()
Expand Down
27 changes: 16 additions & 11 deletions autoload/lightline.vim
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
" Version: 0.0
" Author: itchyny
" License: MIT License
" Last Change: 2013/08/27 16:22:36.
" Last Change: 2013/08/27 18:29:04.
" =============================================================================

let s:save_cpo = &cpo
Expand Down Expand Up @@ -94,16 +94,21 @@ function! lightline#mode()
endfunction

function! lightline#link()
let mode = get(g:lightline._mode_, mode(), 'normal')
for i in range(len(g:lightline.active.left))
exec printf('hi link LightLineLeft_active_%d LightLineLeft_%s_%d', i, mode, i)
exec printf('hi link LightLineLeft_active_%d_%d LightLineLeft_%s_%d_%d', i, i + 1, mode, i, i + 1)
endfor
exec printf('hi link LightLineMiddle_active LightLineMiddle_%s', mode)
for i in range(len(g:lightline.active.right))
exec printf('hi link LightLineRight_active_%d LightLineRight_%s_%d', i, mode, i)
exec printf('hi link LightLineRight_active_%d_%d LightLineRight_%s_%d_%d', i, i + 1, mode, i, i + 1)
endfor
try
let mode = get(g:lightline._mode_, mode(), 'normal')
for i in range(len(g:lightline.active.left))
exec printf('hi link LightLineLeft_active_%d LightLineLeft_%s_%d', i, mode, i)
exec printf('hi link LightLineLeft_active_%d_%d LightLineLeft_%s_%d_%d', i, i + 1, mode, i, i + 1)
endfor
exec printf('hi link LightLineMiddle_active LightLineMiddle_%s', mode)
for i in range(len(g:lightline.active.right))
exec printf('hi link LightLineRight_active_%d LightLineRight_%s_%d', i, mode, i)
exec printf('hi link LightLineRight_active_%d_%d LightLineRight_%s_%d_%d', i, i + 1, mode, i, i + 1)
endfor
catch
let s:_ = 1
call lightline#update()
endtry
return ''
endfunction

Expand Down
10 changes: 5 additions & 5 deletions doc/lightline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Version: 0.0
Author: itchyny (https://github.com/itchyny)
License: MIT License
Repository: https://github.com/itchyny/lightline.vim
Last Change: 2013/08/27 16:19:02.
Last Change: 2013/08/27 17:16:34.

CONTENTS *lightline-contents*

Expand Down Expand Up @@ -113,7 +113,7 @@ OPTIONS *lightline-option*
\ },
\ }
function! MyReadonly()
return &ft !~? 'help' && &ro ? 'RO' : ''
return &ft !~? 'help' && &readonly ? 'RO' : ''
endfunction
<
g:lightline.colorscheme *g:lightline.colorscheme*
Expand Down Expand Up @@ -275,7 +275,7 @@ In order to define your own component:
\ ('' != MyModified() ? ' ' . MyModified() : '')
endfunction
function! MyReadonly()
return &ft !~? 'help' && &ro ? 'RO' : ''
return &ft !~? 'help' && &readonly ? 'RO' : ''
endfunction
function! MyModified()
return &modifiable && &modified ? '+' : ''
Expand Down Expand Up @@ -325,7 +325,7 @@ A nice example for non-patched font users.
return &ft =~ 'help\|vimfiler' ? '' : &modified ? '+' : &modifiable ? '' : '-'
endfunction
function! MyReadonly()
return &ft !~? 'help\|vimfiler' && &ro ? 'RO' : ''
return &ft !~? 'help\|vimfiler' && &readonly ? 'RO' : ''
endfunction
function! MyFilename()
return ('' != MyReadonly() ? MyReadonly() . ' ' : '') .
Expand Down Expand Up @@ -357,7 +357,7 @@ A nice example for |vim-powerline| font users:
return &ft =~ 'help\|vimfiler' ? '' : &modified ? '+' : &modifiable ? '' : '-'
endfunction
function! MyReadonly()
return &ft !~? 'help\|vimfiler' && &ro ? '⭤' : ''
return &ft !~? 'help\|vimfiler' && &readonly ? '⭤' : ''
endfunction
function! MyFilename()
return ('' != MyReadonly() ? MyReadonly() . ' ' : '') .
Expand Down

0 comments on commit 465b6d2

Please sign in to comment.