VimPlugin: lightline: Difference between revisions

From wikinotes
Line 65: Line 65:
       \ 'component_function': {
       \ 'component_function': {
       \  'fileformat': 'LightlineFileformat',
       \  'fileformat': 'LightlineFileformat',
      \  'filetype': 'LightlineFiletype',
       \ },
       \ },
       \ }
       \ }

Revision as of 17:14, 10 February 2024

lightweight viml powerline clone w/ api for hooking other plugin info.

Documentation

github https://github.com/itchyny/lightline.vim

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'] ],
  \}

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 &statusline

component text can be:

"regular text"   " regular text
'0x%B'           " statusline formatter syntax
vim functions    " vim functions

Shorten/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