VimPlugin: lightline: Difference between revisions
From wikinotes
(Created page with "lightweight viml powerline clone w/ api for hooking other plugin info. = Documentation = <blockquote> {| class="wikitable" |- | github || https://github.com/itchyny/lightline.vim |- |} </blockquote><!-- documentation -->") |
|||
(5 intermediate revisions by the same user not shown) | |||
Line 6: | Line 6: | ||
|- | |- | ||
| github || https://github.com/itchyny/lightline.vim | | github || https://github.com/itchyny/lightline.vim | ||
|- | |||
| default config || https://github.com/itchyny/lightline.vim/blob/master/autoload/lightline.vim#L94-L152 | |||
|- | |- | ||
|} | |} | ||
</blockquote><!-- documentation --> | </blockquote><!-- documentation --> | ||
= Configuration = | |||
<blockquote> | |||
== Statusline Configuration == | |||
<blockquote> | |||
* sublists have separators between them | |||
* each left/right element is a component (see below) | |||
<source lang="vim"> | |||
let g:lightline = { | |||
\ 'active': { | |||
\ 'left': [ ['filename'], ['modified', 'readonly'] ], | |||
\ 'right': [ ['fileencoding'] ], | |||
\ }, | |||
\ 'inactive': { | |||
\ 'left': [['filename']], | |||
\ } | |||
\} | |||
</source> | |||
</blockquote><!-- statusline configuration --> | |||
== Components == | |||
<blockquote> | |||
Information that is presented in the line is encapsulated into a '''component''' | |||
<source lang="vim"> | |||
let g:lightline = { | |||
\ 'active': { | |||
\ 'left': [ 'filename', 'modified', 'helloworld' ] | |||
\ }, | |||
\ 'component': { | |||
\ 'helloworld': 'Hello, world!', | |||
\ }, | |||
\ 'component_function': { | |||
\ 'git_branch': 'FugitiveHead', | |||
\ } | |||
\ } | |||
" now this will show 'Hello, world' | |||
echo &statusline | |||
</source> | |||
component text can be: | |||
<source lang="vim"> | |||
"regular text" " regular text | |||
'0x%B' " statusline formatter syntax | |||
vim functions " vim functions | |||
</source> | |||
</blockquote><!-- components --> | |||
== Shorten/Hide Components in thin windows == | |||
<blockquote> | |||
Just use a '''component function''' to return different results based on <code>winwidth()</code> | |||
<source lang="vim"> | |||
let g:lightline = { | |||
\ 'component_function': { | |||
\ 'fileformat': 'LightlineFileformat', | |||
\ }, | |||
\ } | |||
function! LightlineFileformat() | |||
return winwidth(0) > 70 ? &fileformat : '' | |||
endfunction | |||
</source> | |||
</blockquote><!-- shorten display in narrow windows --> | |||
</blockquote><!-- configuration --> |
Latest revision as of 17:23, 10 February 2024
lightweight viml powerline clone w/ api for hooking other plugin info.
Documentation
github https://github.com/itchyny/lightline.vim default config https://github.com/itchyny/lightline.vim/blob/master/autoload/lightline.vim#L94-L152
Configuration
Statusline Configuration
- sublists have separators between them
- each left/right element is a component (see below)
let g:lightline = { \ 'active': { \ 'left': [ ['filename'], ['modified', 'readonly'] ], \ 'right': [ ['fileencoding'] ], \ }, \ 'inactive': { \ 'left': [['filename']], \ } \}Components
Information that is presented in the line is encapsulated into a component
let g:lightline = { \ 'active': { \ 'left': [ 'filename', 'modified', 'helloworld' ] \ }, \ 'component': { \ 'helloworld': 'Hello, world!', \ }, \ 'component_function': { \ 'git_branch': 'FugitiveHead', \ } \ } " now this will show 'Hello, world' echo &statuslinecomponent text can be:
"regular text" " regular text '0x%B' " statusline formatter syntax vim functions " vim functionsShorten/Hide Components in thin windows
Just use a component function to return different results based on
winwidth()
let g:lightline = { \ 'component_function': { \ 'fileformat': 'LightlineFileformat', \ }, \ } function! LightlineFileformat() return winwidth(0) > 70 ? &fileformat : '' endfunction