From 6a0f24b84d197449472eb202ee074ab147a716a8 Mon Sep 17 00:00:00 2001 From: itchyny Date: Sun, 25 Aug 2013 16:40:06 +0900 Subject: [PATCH] improve README.md --- README.md | 116 +++++++++++++++++++++++++++++------------------------- 1 file changed, 62 insertions(+), 54 deletions(-) diff --git a/README.md b/README.md index c6a9e44..fef4e72 100644 --- a/README.md +++ b/README.md @@ -447,12 +447,12 @@ How cool!!! Of course, you can name your component as you wish. ```vim - let g:lightline = { - \ 'active': { - \ 'left': [ [ 'mode', 'paste' ], - \ [ 'my_component' ] ] }, - \ 'component_function': { - \ 'my_component': 'MyComponent', ... +let g:lightline = { + \ 'active': { + \ 'left': [ [ 'mode', 'paste' ], + \ [ 'my_component' ] ] }, + \ 'component_function': { + \ 'my_component': 'MyComponent', ... ``` This is the end of the tutorial. For more information, see `:help lightline`. Good luck with your nice statuslines. @@ -460,54 +460,62 @@ This is the end of the tutorial. For more information, see `:help lightline`. Go ### My settings I show my settings. I use the patched font for vim-powerline. ```vim - let g:lightline = { - \ 'colorscheme': 'landscape', - \ 'mode_map': { 'c': 'NORMAL' }, - \ 'active': { - \ 'left': [ [ 'mode', 'paste' ], [ 'fugitive', 'filename' ] ] - \ }, - \ 'component_function': { - \ 'modified': 'MyModified', - \ 'readonly': 'MyReadonly', - \ 'fugitive': 'MyFugitive', - \ 'filename': 'MyFilename', - \ 'fileformat': 'MyFileformat', - \ 'filetype': 'MyFiletype', - \ 'fileencoding': 'MyFileencoding', - \ 'mode': 'MyMode', - \ }, - \ 'separator': { 'left': '⮀', 'right': '⮂' }, - \ 'subseparator': { 'left': '⮁', 'right': '⮃' } - \ } - function! MyModified() - return &ft =~ 'help\|vimfiler\|gundo' ? '' : &modified ? '+' : &modifiable ? '' : '-' - endfunction - function! MyReadonly() - return &ft !~? 'help\|vimfiler\|gundo' && &ro ? '⭤' : '' - endfunction - function! MyFilename() - return ('' != MyReadonly() ? MyReadonly() . ' ' : '') . - \ (&ft == 'vimfiler' ? vimfiler#get_status_string() : - \ &ft == 'unite' ? unite#get_status_string() : - \ &ft == 'vimshell' ? substitute(b:vimshell.current_dir,expand('~'),'~','') : - \ '' != expand('%t') ? expand('%t') : '[No Name]') . - \ ('' != MyModified() ? ' ' . MyModified() : '') - endfunction - function! MyFugitive() - return &ft !~? 'vimfiler\|gundo' && exists('*fugitive#head') && len(fugitive#head()) ? '⭠ '.fugitive#head() : '' - endfunction - function! MyFileformat() - return winwidth('.') > 70 ? &fileformat : '' - endfunction - function! MyFiletype() - return winwidth('.') > 70 ? (strlen(&filetype) ? &filetype : 'no ft') : '' - endfunction - function! MyFileencoding() - return winwidth('.') > 70 ? (strlen(&fenc) ? &fenc : &enc) : '' - endfunction - function! MyMode() - return winwidth('.') > 60 ? lightline#mode() : '' - endfunction +let g:lightline = { + \ 'colorscheme': 'landscape', + \ 'mode_map': { 'c': 'NORMAL' }, + \ 'active': { + \ 'left': [ [ 'mode', 'paste' ], [ 'fugitive', 'filename' ] ] + \ }, + \ 'component_function': { + \ 'modified': 'MyModified', + \ 'readonly': 'MyReadonly', + \ 'fugitive': 'MyFugitive', + \ 'filename': 'MyFilename', + \ 'fileformat': 'MyFileformat', + \ 'filetype': 'MyFiletype', + \ 'fileencoding': 'MyFileencoding', + \ 'mode': 'MyMode', + \ }, + \ 'separator': { 'left': '⮀', 'right': '⮂' }, + \ 'subseparator': { 'left': '⮁', 'right': '⮃' } + \ } + +function! MyModified() + return &ft =~ 'help\|vimfiler\|gundo' ? '' : &modified ? '+' : &modifiable ? '' : '-' +endfunction + +function! MyReadonly() + return &ft !~? 'help\|vimfiler\|gundo' && &ro ? '⭤' : '' +endfunction + +function! MyFilename() + return ('' != MyReadonly() ? MyReadonly() . ' ' : '') . + \ (&ft == 'vimfiler' ? vimfiler#get_status_string() : + \ &ft == 'unite' ? unite#get_status_string() : + \ &ft == 'vimshell' ? substitute(b:vimshell.current_dir,expand('~'),'~','') : + \ '' != expand('%t') ? expand('%t') : '[No Name]') . + \ ('' != MyModified() ? ' ' . MyModified() : '') +endfunction + +function! MyFugitive() + return &ft !~? 'vimfiler\|gundo' && exists('*fugitive#head') && len(fugitive#head()) ? '⭠ '.fugitive#head() : '' +endfunction + +function! MyFileformat() + return winwidth('.') > 70 ? &fileformat : '' +endfunction + +function! MyFiletype() + return winwidth('.') > 70 ? (strlen(&filetype) ? &filetype : 'no ft') : '' +endfunction + +function! MyFileencoding() + return winwidth('.') > 70 ? (strlen(&fenc) ? &fenc : &enc) : '' +endfunction + +function! MyMode() + return winwidth('.') > 60 ? lightline#mode() : '' +endfunction ``` When the current window width is narrow, the mode component and the file information component collapse. For example, the [gundo](https://github.com/sjl/gundo.vim) buffer is narrow.