Search code examples
vimvim-plugin

Configuring vim lightline


I've got plug itchyny/lightline.vim and it's work fine. I would like to reconfigure my status line and add same fields e.g. spell. When I copy from help this code into my .vimrc to add e.g. spell fields,

let g:lightline.active = { 
\ 'left': [ [ 'mode', 'paste' ],
\           [ 'readonly', 'filename', 'modified' ] ],
\ 'right': [ [ 'lineinfo' ],
\            [ 'percent' ], 
\            [ 'fileformat', 'fileencoding', 'filetype' ] ] }

VIM gives me a error:
E121: Undefined variable: g:lightline

Could someone help


Solution

  • You can't address a field within dictionary if the dictionary doesn't exist yet. For this reason the docs suggest something like this:

    let g:lightline = {
        'active': {
            ...
        }
        ...
    }
    

    Or, alternatively, you can create an empty dict and then set its fields like this:

    let g:lightline = {}
    let g:lightline.active = { ... }