Lightline.vim: MacVim display issue when reloading .vimrc

Created on 17 May 2015  路  10Comments  路  Source: itchyny/lightline.vim

Hi,
I'm getting this issue on MacVim which should be resolved by using set t_Co=256 . This only happens when I source the vimrc automatically after changing it. Normally starting MacVim displays lightline correctly!

Any ideas why this is happening or what I should investigate?

configuration

Most helpful comment

It was not solved by changing to syntax enable but it is indeed not a lighten issue! I did some more digging around and found that Powerline kind of has the same issue just much more apparent on Stackoverflow.

You should always be using the nested flag for autocmd when sourcing your vimrc file! Using:

augroup reload_vimrc " {
    autocmd!
    autocmd BufWritePost $MYVIMRC nested source $MYVIMRC
augroup END " }

fixed this.

All 10 comments

Would you please paste your vimrc here?

Sure thing! I also noticed this only happens when reloading the .vimrc via autocmd. If I :source $MYVIMRC by hand in commandmode everything is fine.

set nocompatible

" General
set number
set linebreak
set showbreak=+++
set textwidth=100
set showmatch
set visualbell

set hlsearch
set smartcase
set ignorecase
set incsearch

set autoindent
set shiftwidth=4
set smartindent
set smarttab
set softtabstop=4

" Advanced
set ruler

set undolevels=1000
set backspace=indent,eol,start


" Generated by VimConfig.com

syntax on

filetype plugin indent on

call plug#begin('~/.vim/plugged')

Plug 'itchyny/lightline.vim'
Plug 'tomasr/molokai'

call plug#end()

set encoding=utf-8
scriptencoding utf-8
set laststatus=2

let g:molokai_original = 1 
colorscheme molokai

augroup reload_vimrc " {
    autocmd!
    autocmd BufWritePost $MYVIMRC source $MYVIMRC
augroup END " }

let g:lightline = {
      \ 'component': {
      \   'readonly': '%{&readonly?"x":""}',
      \ },
      \ 'separator': { 'left': '', 'right': '' },
      \ 'subseparator': { 'left': '|', 'right': '|' }
      \ }

set guioptions-=T
set guioptions-=r

What happens when you move the two commands syntax on and filetype plugin indent on at the end of your vimrc?

Issue persists.

I can switch between it breaking and displaying correctly by saving my vimrc (it breaks) and then executing :source $MYVIMRC (changes to showing up fine) indefinitely..

You should use syntax enable instead of syntax on.
syntax on resets current highlight config.

Thank you!

So this looks to be an issue with autocmd since it's independent from how I source (using $MYVIMRC or "%").

This problem is solved? I think it is not lightline issue.

It was not solved by changing to syntax enable but it is indeed not a lighten issue! I did some more digging around and found that Powerline kind of has the same issue just much more apparent on Stackoverflow.

You should always be using the nested flag for autocmd when sourcing your vimrc file! Using:

augroup reload_vimrc " {
    autocmd!
    autocmd BufWritePost $MYVIMRC nested source $MYVIMRC
augroup END " }

fixed this.

Oh, I get it.

Hmm looks weird but that would be the solution.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

codepushr picture codepushr  路  3Comments

linus345 picture linus345  路  3Comments

Char-Aznable picture Char-Aznable  路  4Comments

ahmedelgabri picture ahmedelgabri  路  3Comments

JIAKanghao picture JIAKanghao  路  4Comments