Lightline.vim: Sourcing `$MYVIMRC` shows erros

Created on 3 Sep 2016  Â·  3Comments  Â·  Source: itchyny/lightline.vim

I have this in my $MYVIMRC

" Automatically reload vimrc when it's saved
augroup reload_vimrc
    autocmd!
    autocmd BufWritePost $MYVIMRC nested so $MYVIMRC
augroup END

and this is my lightline set up

" Find out current buffer's size and output it.
function! FileSize()
  let bytes = getfsize(expand('%:p'))
  if (bytes >= 1024)
    let kbytes = bytes / 1024
  endif
  if (exists('kbytes') && kbytes >= 1000)
    let mbytes = kbytes / 1000
  endif

  if bytes <= 0
    return '[empty file] '
  endif

  if (exists('mbytes'))
    return mbytes . 'MB '
  elseif (exists('kbytes'))
    return kbytes . 'KB '
  else
    return bytes . 'B '
  endif
endfunction

function! ReadOnly()
  if &readonly || !&modifiable
    return 'î‚¢'
  else
    return ''
endfunction

function! Modified()
  if &filetype == "help"
    return ""
  elseif &modified
    return "+"
  elseif &modifiable
    return ""
  else
    return ""
  endif
endfunction

function! GitInfo()
  let git = fugitive#head()
  if git != ''
    return 'î‚  '.fugitive#head()
  else
    return ''
endfunction

function! Filename()
  return ('' != ReadOnly() ? ReadOnly() . ' ' : '') .
       \ ('' != expand('%:p:~') ? expand('%:p:~') : '[No Name]') .
       \ ('' != Modified() ? ' ' . Modified() : '')
endfunction

function LightlinePaste()
    return '%{&paste?"PASTE":""}'
endfunction

function LightlineNeomake()
    return '%{neomake#statusline#LoclistStatus()}'
endfunction

function LightlineTags()
    return '%{gutentags#statusline("[Generating\ tags...]")}'
endfunction

function LightlineObsession()
    return '%{ObsessionStatus()}'
endfunction

let g:lightline = {
\ 'enable' :{
\   'tabline': 0,
\   'statusline': 1
\ },
\ 'colorscheme': 'onedark',
\ 'separator': {
\   'left': '',
\   'right': ''
\ },
\ 'subseparator': {
\   'left': '',
\   'right': ''
\ },
\ 'mode_map': {
\   '__' : '-',
\   'n'  : 'N',
\   'no' : 'N·Operator Pending',
\   'v'  : 'V',
\   'V'  : 'V·Line',
\   '' : 'V·Block',
\   's'  : 'Select',
\   'S'  : 'S·Line',
\   '' : 'S·Block',
\   'i'  : 'I',
\   'R'  : 'R',
\   'Rv' : 'V·Replace',
\   'c'  : 'Command',
\   'cv' : 'Vim Ex',
\   'ce' : 'Ex',
\   'r'  : 'Prompt',
\   'rm' : 'More',
\   'r?' : 'Confirm',
\   '!'  : 'Shell',
\   't'  : 'Terminal'
\ },
\ 'active': {
\   'left': [ [ 'mode', 'paste' ], [ 'fugitive', 'filename' ] ],
\   'right': [ ['percent', 'lineinfo'], [ 'fileformat', 'fileencoding', 'filetype', 'filesize' ], [ 'neomake', 'obsession' ], ['tags'] ]
\ },
\ 'component_function': {
\   'readonly': 'ReadOnly',
\   'modified': 'Modified',
\   'fugitive': 'GitInfo',
\   'filename': 'Filename',
\   'filesize': 'FileSize'
\ },
\ 'component_expand': {
\   'paste': 'LightlinePaste',
\   'neomake': 'LightlineNeomake',
\   'tags': 'LightlineTags',
\   'obsession': 'LightlineObsession'
\ },
\ 'component_type': {
\   'paste': 'warning',
\   'neomake': 'error',
\ },
\ }

When I save the file I get these errors, maybe I'm oing something wrong but I'm not sure what it is to be honest :)

screen shot 2016-09-03 at 15 05 54

question

All 3 comments

Add exclamation marks for the functions you defined (LightlinePaste, LightlineNeomake...) as the error message states.

function! LightlinePaste()
...

That's embarrassing 😅, thanks @itchyny

So what is the difference? is it a syntax error in vimscript or does it do something different? _I assume the it's a syntax error_

As the error message suggests the error number, consult the help with :h E122. The exclamation marks after :function overwrite the existing functions with the same name.

Was this page helpful?
0 / 5 - 0 ratings