Lightline not working after sourcing $MYVIMRC
mosheavni opened this issue · 4 comments
So this is not a real issue, it's just a weird behaviour I want to figure out.
The plugin works right of the bat, but when I'm :so $MYVIMRC
, the status line looks bad, and to restore it, I use the below function s:set_lightline_colorscheme
(I noticed call lightline#update()
is sufficient to fix this)
Here is my full non-truncated configuration:
let g:lightline = {
\ 'colorscheme': 'tokyonight',
\ 'separator': { 'left': "\ue0b0", 'right': "\ue0b2" },
\ 'subseparator': { 'left': "\ue0b1", 'right': "\ue0b3" },
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'readonly', 'filename', 'modified', 'cocstatus' ],
\ [ 'unpushed_unpulled', 'gitstatus' ]
\ ],
\ 'right': [ [ 'virtualenv', 'filetype', 'line', 'column', 'gitbranch' ] ]
\ },
\ 'inactive': {
\ 'left': [ [ 'readonly', 'filename', 'modified' ] ],
\ 'right': [ [ 'filetypelogo', 'gitbranch' ] ]
\ },
\ 'tabline': {
\ 'left': [ ['buffers'] ],
\ 'right': [ ['close'] ]
\ },
\ 'component_function': {
\ 'gitbranch': 'FugitiveHead',
\ 'gitstatus': 'GitStatus',
\ 'unpushed_unpulled': 'Unpushed_Unpulled',
\ 'filetype': 'LightlineDevIconsFiletype',
\ 'fileformat': 'LightlineDevIconsFileformat',
\ 'filetypelogo': 'WebDevIconsGetFileTypeSymbol',
\ 'cocstatus': 'coc#status',
\ 'virtualenv': 'CheckVirtualEnv',
\ },
\ 'component_expand': {
\ 'buffers': 'lightline#bufferline#buffers'
\ },
\ 'component_type': {
\ 'buffers': 'tabsel'
\ },
\ 'component_raw': {'buffers': 1}
\ }
function! LightlineDevIconsFiletype()
return winwidth(0) > 70 ? (strlen(&filetype) ? WebDevIconsGetFileTypeSymbol() . ' ' .&filetype : 'no ft') : WebDevIconsGetFileTypeSymbol()
endfunction
function! LightlineDevIconsFileformat()
return winwidth(0) > 70 ? (WebDevIconsGetFileFormatSymbol() . ' ' . &fileformat) : WebDevIconsGetFileFormatSymbol()
endfunction
function CheckVirtualEnv() abort
let virtualenv = $VIRTUAL_ENV
if empty(virtualenv)
return ''
endif
return printf('(%s)',split(virtualenv, '/')[-1])
endfunction
function! s:set_lightline_colorscheme(name) abort
let g:lightline.colorscheme = a:name
call lightline#init()
call lightline#colorscheme()
call lightline#update()
endfunction
function! s:lightline_colorschemes(...) abort
return join(map(
\ globpath(&rtp,'autoload/lightline/colorscheme/*.vim',1,1),
\ "fnamemodify(v:val,':t:r')"),
\ "\n")
endfunction
command! -nargs=1 -complete=custom,s:lightline_colorschemes LightlineColorscheme
\ call s:set_lightline_colorscheme(<q-args>)
let g:lightline#bufferline#show_number=1
let g:lightline#bufferline#enable_devicons=1
let g:lightline#bufferline#filename_modifier = ':.'
let g:lightline#bufferline#margin_left=1
let g:lightline#bufferline#margin_right=1
let g:lightline#bufferline#clickable=1
Any ideas why?
This looks like because you set
statusline
option here.
I love how you went the extra mile and checked my configurations :))
This is my ~/.config/nvim/init.vim
:
set runtimepath^=~/.vim runtimepath+=~/.vim/after
let &packpath = &runtimepath
source ~/.vimrc
source ~/.vimrcplugins
I commented out the section you mentioned, still same behaviour
Try :verbose set statusline
to see where the option is set.
Try
:verbose set statusline
to see where the option is set.
Amazing. Learned a new thing!
it was because of this:
https://github.com/mosheavni/dotfiles/blob/b6db412dcb99b8f6d2b9056524e02325ef1d7066/.vimrcplugins#L212
I missed the help file of coc-nvim saying how to integrate it with lightline.vim.
After this:
https://github.com/mosheavni/dotfiles/blob/22a14f4519f49b45dc1001092b59a152208dc633/.vimrcplugins#L318
It's working right :)
Thank you for your quick help (: