├── .gitignore ├── README.md ├── LICENSE ├── plugin └── lightline_powerful.vim └── autoload └── lightline_powerful.vim /.gitignore: -------------------------------------------------------------------------------- 1 | /doc/tags 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This is my lightline configuration. 2 | You can look into the code how the lightline author configures the plugin, but I don't recommend installing this plugin. 3 | You can create and improve your own lightline configuration. 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013-2021 itchyny 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /plugin/lightline_powerful.vim: -------------------------------------------------------------------------------- 1 | " ============================================================================= 2 | " Filename: plugin/lightline_powerful.vim 3 | " Author: itchyny 4 | " License: MIT License 5 | " Last Change: 2021/02/15 01:04:08. 6 | " ============================================================================= 7 | 8 | if exists('g:loaded_lightline_powerful') || v:version < 800 9 | finish 10 | endif 11 | let g:loaded_lightline_powerful = 1 12 | 13 | let g:lightline = extend(get(g:, 'lightline', {}), { 14 | \ 'active': { 15 | \ 'left': [ [ 'mode', 'paste' ], [ 'gitbranch', 'filename' ] ], 16 | \ 'right': [ [ 'lineinfo' ], [ 'percent' ], [ 'binary', 'fileformat', 'fileencoding', 'filetype' ] ] 17 | \ }, 18 | \ 'inactive': { 19 | \ 'left': [ [ 'filename' ] ], 20 | \ 'right': [ [ 'lineinfo' ], [ 'percent' ] ] 21 | \ }, 22 | \ 'tabline': { 23 | \ 'left': [ [ 'tabs' ] ], 24 | \ 'right': [] 25 | \ }, 26 | \ 'tab': { 27 | \ 'active': [ 'tabnum', 'readonly', 'filename', 'modified' ], 28 | \ 'inactive': [ 'tabnum', 'readonly', 'filename', 'modified' ] 29 | \ }, 30 | \ 'component': { 31 | \ 'binary': '%{&binary?"binary":""}', 32 | \ 'lineinfo': '%3l:%-2c%<', 33 | \ }, 34 | \ 'component_visible_condition': { 35 | \ 'binary': '&binary', 36 | \ }, 37 | \ 'component_function': { 38 | \ 'gitbranch': 'lightline_powerful#gitbranch', 39 | \ 'filename': 'lightline_powerful#filename', 40 | \ 'mode': 'lightline_powerful#mode', 41 | \ }, 42 | \ 'component_function_visible_condition': { 43 | \ 'filename': 'get(b:,"lightline_filename","")!=#""', 44 | \ 'mode': '1', 45 | \ }, 46 | \ 'tab_component_function': { 47 | \ 'filename': 'lightline_powerful#tabfilename', 48 | \ 'readonly': 'lightline_powerful#tabreadonly', 49 | \ }, 50 | \ }, 'keep') 51 | -------------------------------------------------------------------------------- /autoload/lightline_powerful.vim: -------------------------------------------------------------------------------- 1 | " ============================================================================= 2 | " Filename: autoload/lightline_powerful.vim 3 | " Author: itchyny 4 | " License: MIT License 5 | " Last Change: 2024/11/08 22:31:05. 6 | " ============================================================================= 7 | 8 | let s:e = { 9 | \ 'vimfiler' : 'vimfiler#get_status_string()', 10 | \ 'unite' : 'unite#get_status_string()', 11 | \ 'quickrun' : "''", 12 | \ 'qf' : "''", 13 | \ 'dictionary' : "exists('b:dictionary.input') ? b:dictionary.input : default", 14 | \ 'calendar' : "strftime('%Y/%m/%d')", 15 | \ 'thumbnail' : "exists('b:thumbnail.status') ? b:thumbnail.status : 'Thumbnail'", 16 | \ 'agit' : "''", 17 | \ 'agit_diff' : "''", 18 | \ 'agit_stat' : "''", 19 | \ '[Command Line]': "'Command Line'", 20 | \ } 21 | let s:f = [ 'vimfiler', 'unite', 'dictionary', 'thumbnail' ] 22 | function! lightline_powerful#filename() abort 23 | let f = expand('%:t') 24 | if has_key(b:, 'lightline_filename') && get(b:, 'lightline_filename_', '') ==# f . &mod . &ma . &ft && (&ft ==# '' || index(s:f, &ft) < 0 && index(s:f, f) < 0) 25 | return b:lightline_filename 26 | endif 27 | let b:lightline_filename_ = f . &mod . &ma . &ft 28 | let default = join(filter([&ro ? 'RO' : '', f, &mod ? '+' : &ma ? '' : '-'], 'len(v:val)'), ' ') 29 | let b:lightline_filename = &ft ==# '' && f ==# '' ? 'No Name' : f =~# '^\[preview' ? 'Preview' : eval(get(s:e, &ft, get(s:e, f, 'default'))) 30 | return b:lightline_filename 31 | endfunction 32 | 33 | let s:gitbranch_time = reltime() 34 | function! lightline_powerful#gitbranch() abort 35 | if has_key(b:, 'lightline_gitbranch') && reltimefloat(reltime(s:gitbranch_time)) < 0.5 36 | return b:lightline_gitbranch 37 | endif 38 | let b:lightline_gitbranch = exists('*gitbranch#name') ? gitbranch#name() : '' 39 | let s:gitbranch_time = reltime() 40 | return b:lightline_gitbranch 41 | endfunction 42 | 43 | let s:p = { 'unite': 'Unite', 'vimfiler': 'VimFiler', 'quickrun': 'Quickrun', 'dictionary': 'Dictionary', 'calendar': 'Calendar', 'thumbnail': 'Thumbnail', 'agit' : 'Agit', 'agit_diff' : 'Agit', 'agit_stat' : 'Agit', 'qf': 'QuickFix' } 44 | function! lightline_powerful#mode() abort 45 | if &ft ==# 'calendar' 46 | call lightline#link("nvV\"[b:calendar.visual_mode()]) 47 | elseif &ft ==# 'thumbnail' 48 | if !empty(b:thumbnail.view.visual_mode) 49 | call lightline#link(b:thumbnail.view.visual_mode) 50 | endif 51 | endif 52 | return get(s:p, &ft, lightline#mode()) 53 | endfunction 54 | 55 | function! lightline_powerful#tabreadonly(n) abort 56 | let winnr = tabpagewinnr(a:n) 57 | return gettabwinvar(a:n, winnr, '&readonly') ? 'RO' : '' 58 | endfunction 59 | 60 | let s:buffer_count_by_basename = {} 61 | augroup lightline_powerful_filenames 62 | autocmd! 63 | autocmd BufEnter,WinEnter,WinLeave * call s:update_bufnrs() 64 | augroup END 65 | 66 | function! s:update_bufnrs() abort 67 | let s:buffer_count_by_basename = {} 68 | let bufnrs = filter(range(1, bufnr('$')), 'buflisted(v:val) && bufexists(v:val) && len(bufname(v:val))') 69 | for name in map(bufnrs, 'expand("#" . v:val . ":t")') 70 | if name !=# '' 71 | let s:buffer_count_by_basename[name] = get(s:buffer_count_by_basename, name) + 1 72 | endif 73 | endfor 74 | endfunction 75 | 76 | function! lightline_powerful#tabfilename(n) abort 77 | let bufnr = tabpagebuflist(a:n)[tabpagewinnr(a:n) - 1] 78 | let bufname = expand('#' . bufnr . ':t') 79 | let ft = gettabwinvar(a:n, tabpagewinnr(a:n), '&ft') 80 | if get(s:buffer_count_by_basename, bufname) > 1 81 | let fname = substitute(expand('#' . bufnr . ':p'), '.*/\([^/]\+/\)', '\1', '') 82 | else 83 | let fname = bufname 84 | endif 85 | return fname =~# '^\[preview' ? 'Preview' : get(s:p, ft, fname) 86 | endfunction 87 | --------------------------------------------------------------------------------