nvim-lualine / lualine.nvim

A blazing fast and easy to configure neovim statusline plugin written in pure lua.
MIT License
6.14k stars 465 forks source link

Bug: Switching windows requires sourcing vimrc again #331

Closed prdanelli closed 3 years ago

prdanelli commented 3 years ago

Self Checks

How to reproduce the problem

Inside of a .vim config file:

lua << EOF
-------------------------------------------------------------------------------
-- LuaLine
-------------------------------------------------------------------------------
require'lualine'.setup({
    options = {
        lower = true,
        icons_enabled = true,
        theme = 'auto',
        component_separators = { '\\', '/' },
        section_separators = { '', '' },
        disabled_filetypes = {}
    },
    sections = {
        lualine_a = { { 'mode', lower = false } },
        lualine_b = { 'branch' },
        lualine_c = { require'lsp-status'.status },
        lualine_x = { 'filename', 'encoding', 'filetype' },
        lualine_y = { 'progress' },
        lualine_z = { 'location' }
    },
    inactive_sections = {
        lualine_a = {},
        lualine_b = {},
        lualine_c = { 'filename' },
        lualine_x = { 'location' },
        lualine_y = {},
        lualine_z = {}
    },
    tabline = {},
    extensions = {}
})
EOF

Switch to another window (alt tab), then switch back to nvim and the default theme will be shown and you will need to source ~/.vimrc.

Minimal config to reproduce the issue

Config ```" left-sep  " right-sep  """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Nvim Configuration """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" let g:python_host_prog = '/usr/bin/python' let g:python3_host_prog = '/usr/bin/python3' let g:ruby_host_prog = '/home/paul/.rvm/rubies/ruby-2.7.3/bin/ruby' """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " General """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" set nocompatible set ttyfast set encoding=UTF-8 set fileencoding=utf-8 syntax on filetype on filetype indent on filetype plugin on set regexpengine=1 set synmaxcol=200 set updatetime=300 set timeoutlen=500 set shell=bash set ruler """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Look / Colours """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" set termguicolors set background=dark lua << EOF ------------------------------------------------------------------------------- -- set colorscheme nightfox ------------------------------------------------------------------------------- local nightfox = require('nightfox') nightfox.setup({ fox = "nordfox", -- change the colorscheme to use nordfox styles = { comments = "italic", -- change style of comments to be italic keywords = "bold", -- change style of keywords to be bold functions = "italic,bold" -- styles can be a comma separated list }, colors = { red = "#FF000", -- Override the red color for MAX POWER bg_alt = "#000000", }, hlgroups = { TSPunctDelimiter = { fg = "#BF616A" }, -- Override a highlight group with the color red LspCodeLens = { bg = "#000000", style = "italic" }, } }) nightfox.load() EOF lua << EOF ------------------------------------------------------------------------------- -- LuaLine ------------------------------------------------------------------------------- require'lualine'.setup({ options = { lower = true, icons_enabled = true, theme = 'auto', component_separators = { '\\', '/' }, section_separators = { '', '' }, disabled_filetypes = {} }, sections = { lualine_a = { { 'mode', lower = false } }, lualine_b = { 'branch' }, lualine_c = { require'lsp-status'.status }, lualine_x = { 'filename', 'encoding', 'filetype' }, lualine_y = { 'progress' }, lualine_z = { 'location' } }, inactive_sections = { lualine_a = {}, lualine_b = {}, lualine_c = { 'filename' }, lualine_x = { 'location' }, lualine_y = {}, lualine_z = {} }, tabline = {}, extensions = {} }) EOF " Character line limits set colorcolumn=80,120 " Highlight the current line set cursorline " Show status line always set laststatus=2 " Treat .es6 as .js au BufNewFile,BufRead *.es6 set filetype=javascript au BufNewFile,BufRead *.rasi set filetype=css " Code folding set nofoldenable set foldmethod=expr set foldexpr=nvim_treesitter#foldexpr() set fillchars=fold:- " Keep all folds open when a file is opened augroup OpenAllFoldsOnFileOpen autocmd! autocmd BufRead * normal zR augroup END """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Behaviour """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" set conceallevel=0 " Tab / space behaviour set tabstop=2 set smarttab set expandtab " Don't show -- INSERT-- set noshowmode " Search recurively set path+=** " Menu autocomplete set wildmenu set wildmode=longest:full,full " How should backspace be used set backspace=indent,eol,start " Enable mouse selection set mouse=niv " Word wrap but don't cut words set linebreak " Enable Hidden Buffers - means you can switch between buffers without saving set hidden " Use System Clipboard set clipboard=unnamedplus " Indentation set smartindent set autoindent " Don't pass messages to |ins-completion-menu|. set shortmess+=c " Turn line numbers on by default, and set relative set number set relativenumber " Always show gutter so Gitgutter doesn't jump set signcolumn=yes " Line number width set numberwidth=3 " Highlight search terms set hlsearch " Highlight terms as search is typed set incsearch set nobackup set nowritebackup " Swap / Persistent directories set swapfile set backupdir=.backup/,~/.vim/.backup,/tmp/ set directory=.swp/,~/.vim/.vim/.swapfiles/,/tmp/ set undodir=.undo/,~/.vim/.undo/,/tmp/ set undofile " Set universal ignore set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.idea/*,*/.DS_Store,*/vendor/**/*,*/.cache,*/node_modules/**/*,*/docker/**/* """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Plugins """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" lua << EOF ------------------------------------------------------------------------------- -- Tree Sitter ------------------------------------------------------------------------------- require'nvim-treesitter.configs'.setup({ ensure_installed = "maintained", ignore_install = {}, highlight = { enable = true, disable = { "c", "rust" }, additional_vim_regex_highlighting = true, } }) require("bufferline").setup{} EOF lua << EOF ------------------------------------------------------------------------------- -- LSP Install ------------------------------------------------------------------------------- require'lspinstall'.setup() -- important local function setup_servers() require'lspinstall'.setup() local servers = require'lspinstall'.installed_servers() for _, server in pairs(servers) do require'lspconfig'[server].setup{} end end setup_servers() -- Automatically reload after `:LspInstall ` so we don't have to restart neovim require'lspinstall'.post_install_hook = function () setup_servers() -- reload installed servers vim.cmd("bufdo e") -- this triggers the FileType autocmd that starts the server end EOF " Vim Sneak let g:sneak#label = 1 " FZF let g:fzf_tags_command = 'ctags -R' let g:fzf_layout = { 'up' :'~90%', 'window': { 'width': 0.95, 'height': 0.9 } } let g:fzf_colors = { \ 'fg': ['fg', 'Normal'], \ 'bg': ['bg', 'Normal'], \ 'hl': ['fg', 'Comment'], \ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'], \ 'bg+': ['bg', 'CursorLine', 'CursorColumn'], \ 'hl+': ['fg', 'Statement'], \ 'info': ['fg', 'PreProc'], \ 'border': ['fg', 'Boolean'], \ 'prompt': ['fg', 'Conditional'], \ 'pointer': ['fg', 'Exception'], \ 'marker': ['fg', 'Keyword'], \ 'spinner': ['fg', 'Label'], \ 'header': ['fg', 'Comment'] } let $FZF_DEFAULT_OPTS = '--layout=reverse --inline-info' let $FZF_DEFAULT_COMMAND="rg --files --hidden --glob '!.git/**'" " Coc Explorer - file browser let g:coc_explorer_global_presets = { \ '.vim': { \ 'root-uri': '~/.vim', \ }, \ 'cocConfig': { \ 'root-uri': '~/.config/coc', \ }, \ 'tab': { \ 'position': 'tab', \ 'quit-on-open': v:true, \ }, \ 'simplify': { \ 'file-child-template': '[selection | clip | 1] [indent][icon | 1] [filename omitCenter 1]' \ } \ } " ALE let g:ale_lint_on_text_changed = 0 let g:ale_lint_on_enter = 0 let g:ale_lint_on_save = 1 let b:ale_linters = { 'ruby': ['solargraph'] } let g:airline#extensions#ale#enabled = 1 let g:ale_sign_error = '✖✖' let g:ale_sign_warning = '--' highlight ALEError guibg=#343d46 guifg=#EBCB8B highlight ALEWarning guibg=#343d46 guifg=#BF616A set completeopt+=noinsert " Startify let g:startify_custom_header =[] let g:startify_change_to_dir=0 function! s:gitModified() let files = systemlist('git ls-files -m 2>/dev/null') return map(files, "{'line': v:val, 'path': v:val}") endfunction let g:startify_bookmarks = ['~/.vim/config.vim', '~/.vim/plugins.vim', '~/.vim/keymap.vim'] let g:startify_enable_special = 0 let g:startify_lists = [ \ { 'type': 'bookmarks', 'header': [' Bookmarks'] }, \ { 'type': 'files', 'header': [' Recent'] }, \ { 'type': 'dir', 'header': [' Current Directory '. getcwd()] }, \ { 'type': 'sessions', 'header': [' Sessions'] }, \ { 'type': function('s:gitModified'), 'header': [' Modified'] }, \ { 'type': 'commands', 'header': [' Commands'] }, \ ] " Highlight Yank let g:highlightedyank_highlight_duration = 250 highlight HighlightedyankRegion cterm=reverse gui=reverse ```
shadmansaleh commented 3 years ago

Can you reproduce this on shadmansaleh/lualine.nvim ?

prdanelli commented 3 years ago

Hello, yes it seems to have the same issue in both.

prdanelli commented 3 years ago

I've reduced my vimrc to the following:

call plug#begin()
Plug 'hoob3rt/lualine.nvim'
call plug#end()

lua << EOF
require'lualine'.setup{}
EOF

And the issue seems to be the same, when manually source the vimrc it works, but switching to another application, with alt tab or clicking, it seems to revert to something. I've attached a screenshot.

After sourcing: image

After sourcing: image

As a side note, the status bar that is being shown is there when Lualine is disabled, so it might be an nvim default?

image

shadmansaleh commented 3 years ago

@parelkobra did you try https://github.com/shadmansaleh/lualine.nvim ? I don't think this issue can occur there . Because it doesn't relay on autocommands to switch between inactive and active status.

Also the second screenshot I'm pretty sure you have airline installed that's why you're getting it . Uninstall that plugin before installing lualine.

If you still get the issue . Use https://gist.github.com/shadmansaleh/3aca29632e9a77a632705b62617c9dac and try reproducing the issue in an isolated environment with my fork.

prdanelli commented 3 years ago

I think i worked out the issue. I had used packer in the past to test it out and it had a bunch of plugins in it getting autoloaded.

Sorry for the time i've wasted. Thank you for work on this plugin.