famiu / feline.nvim

A minimal, stylish and customizable statusline for Neovim written in Lua
GNU General Public License v3.0
1.04k stars 55 forks source link

Question: Background color of statusline does not change. #288

Closed MysteryMage closed 2 years ago

MysteryMage commented 2 years ago

Nvim Version

NVIM v0.7.2 Build type: RelWithDebInfo LuaJIT 2.1.0-beta3 Compiled by runneradmin@fv-az276-503

Features: -acl +iconv +tui See ":help feature-compile"

system vimrc file: "$VIM\sysinit.vim" fall-back for $VIM: "C:/Program Files/nvim/share/nvim"

Run :checkhealth for more info


Feline Version: release version


The Problem:

I have recently tried to switch to feline from lualine, and it's great. But I have a problem with the background color of the statusbar, it's always the same doesn't matter if I change the color table or even if I use one of the example configs. I have tried to disable almost all my config excpet for feline but still no change. This problem occured for me on multiple machines one windows and one mac. Im not sure if the problem is with my setup of if it's a feline bug.

I have tried using iTerm2 as well as Windows Terminal and both yielded the same results


Config:

init.vim

" source ~\Appdata\Local\nvim\modules\basic-settings.vim
" source ~\Appdata\Local\nvim\modules\mappings.vim
" source ~\Appdata\Local\nvim\modules\set-vars.vim
" source ~\Appdata\Local\nvim\modules\plugins.vim

set termguicolors

call plug#begin('~/AppData/Local/nvim/plugged')

Plug 'feline-nvim/feline.nvim'
Plug 'kyazdani42/nvim-web-devicons'

call plug#end()

" lua require("CatppuccinConfig")
" lua require("lsp")
" lua require("CmpConfig")
" lua require("Treesitter")
" lua require("CommenterConfig")
" lua require("TelescopeConfig")
" lua require("ColorizerConfig")
" lua require("NvimTreeConfig")
" lua require("GitsignsConfig")
lua require("FelineConfig")

"Color Scheme
" let g:catppuccin_flavour = "mocha"
colorscheme elflord
" set background=dark

" hi Normal guibg=NONE ctermbg=NONE
" highlight NvimTreeRootFolder guifg=White

Feline config

NOTE: this config is one of the example configs, my current config wont work because it requires the catppuccin plugin

if not pcall(require, "feline") then
  return
end

local colors = {
    bg = '#282c34',
    fg = '#abb2bf',
    yellow = '#e0af68',
    cyan = '#56b6c2',
    darkblue = '#081633',
    green = '#98c379',
    orange = '#d19a66',
    violet = '#a9a1e1',
    magenta = '#c678dd',
    blue = '#61afef',
    red = '#e86671'
}

local vi_mode_colors = {
    NORMAL = colors.green,
    INSERT = colors.red,
    VISUAL = colors.magenta,
    OP = colors.green,
    BLOCK = colors.blue,
    REPLACE = colors.violet,
    ['V-REPLACE'] = colors.violet,
    ENTER = colors.cyan,
    MORE = colors.cyan,
    SELECT = colors.orange,
    COMMAND = colors.green,
    SHELL = colors.green,
    TERM = colors.green,
    NONE = colors.yellow
}

local function file_osinfo()
    local os = vim.bo.fileformat:upper()
    local icon
    if os == 'UNIX' then
        icon = ' '
    elseif os == 'MAC' then
        icon = ' '
    else
        icon = ' '
    end
    return icon .. os
end

-- local lsp = require 'feline.providers.lsp'
local vi_mode_utils = require 'feline.providers.vi_mode'

-- local lsp_get_diag = function(str)
--   local count = vim.lsp.diagnostic.get_count(0, str)
--   return (count > 0) and ' '..count..' ' or ''
-- end

-- LuaFormatter off

local comps = {
    vi_mode = {
        left = {
            provider = function()
              return '  ' .. vi_mode_utils.get_vim_mode()
            end,
            hl = function()
                local val = {
                    name = vi_mode_utils.get_mode_highlight_name(),
                    fg = vi_mode_utils.get_mode_color(),
                    -- fg = colors.bg
                }
                return val
            end,
            right_sep = ' '
        },
        right = {
            -- provider = '▊',
            provider = '' ,
            hl = function()
                local val = {
                    name = vi_mode_utils.get_mode_highlight_name(),
                    fg = vi_mode_utils.get_mode_color()
                }
                return val
            end,
            left_sep = ' ',
            right_sep = ' '
        }
    },
    file = {
        info = {
            provider = {
              name = 'file_info',
              opts = {
                type = 'relative-short',
                file_readonly_icon = '  ',
                -- file_readonly_icon = '  ',
                -- file_readonly_icon = '  ',
                -- file_readonly_icon = '  ',
                -- file_modified_icon = '',
                file_modified_icon = '',
                -- file_modified_icon = 'ﱐ',
                -- file_modified_icon = '',
                -- file_modified_icon = '',
                -- file_modified_icon = '',
              }
            },
            hl = {
                fg = colors.blue,
                style = 'bold'
            }
        },
        encoding = {
            provider = 'file_encoding',
            left_sep = ' ',
            hl = {
                fg = colors.violet,
                style = 'bold'
            }
        },
        type = {
            provider = 'file_type'
        },
        os = {
            provider = file_osinfo,
            left_sep = ' ',
            hl = {
                fg = colors.violet,
                style = 'bold'
            }
        },
        position = {
            provider = 'position',
            left_sep = ' ',
            hl = {
                fg = colors.cyan,
                -- style = 'bold'
            }
        },
    },
    left_end = {
        provider = function() return '' end,
        hl = {
            fg = colors.bg,
            bg = colors.blue,
        }
    },
    line_percentage = {
        provider = 'line_percentage',
        left_sep = ' ',
        hl = {
            style = 'bold'
        }
    },
    scroll_bar = {
        provider = 'scroll_bar',
        left_sep = ' ',
        hl = {
            fg = colors.blue,
            style = 'bold'
        }
    },
    -- diagnos = {
    --     err = {
    --         -- provider = 'diagnostic_errors',
    --         provider = function()
    --             return '' .. lsp_get_diag("Error")
    --         end,
    --         -- left_sep = ' ',
    --         enabled = function() return lsp.diagnostics_exist('Error') end,
    --         hl = {
    --             fg = colors.red
    --         }
    --     },
    --     warn = {
    --         -- provider = 'diagnostic_warnings',
    --         provider = function()
    --             return '' ..  lsp_get_diag("Warning")
    --         end,
    --         -- left_sep = ' ',
    --         enabled = function() return lsp.diagnostics_exist('Warning') end,
    --         hl = {
    --             fg = colors.yellow
    --         }
    --     },
    --     info = {
    --         -- provider = 'diagnostic_info',
    --         provider = function()
    --             return '' .. lsp_get_diag("Information")
    --         end,
    --         -- left_sep = ' ',
    --         enabled = function() return lsp.diagnostics_exist('Information') end,
    --         hl = {
    --             fg = colors.blue
    --         }
    --     },
    --     hint = {
    --         -- provider = 'diagnostic_hints',
    --         provider = function()
    --             return '' .. lsp_get_diag("Hint")
    --         end,
    --         -- left_sep = ' ',
    --         enabled = function() return lsp.diagnostics_exist('Hint') end,
    --         hl = {
    --             fg = colors.cyan
    --         }
    --     },
    -- },
    -- lsp = {
    --     name = {
    --         provider = 'lsp_client_names',
    --         -- left_sep = ' ',
    --         right_sep = ' ',
    --         -- icon = '  ',
    --         icon = '慎',
    --         hl = {
    --             fg = colors.yellow
    --         }
    --     }
    -- },
    git = {
        branch = {
            provider = 'git_branch',
            icon = ' ',
            -- icon = ' ',
            left_sep = ' ',
            hl = {
                fg = colors.violet,
                style = 'bold'
            },
        },
        add = {
            provider = 'git_diff_added',
            hl = {
                fg = colors.green
            }
        },
        change = {
            provider = 'git_diff_changed',
            hl = {
                fg = colors.orange
            }
        },
        remove = {
            provider = 'git_diff_removed',
            hl = {
                fg = colors.red
            }
        }
    }
}

local components = {
  active = {},
  inactive = {},
}

table.insert(components.active, {})
table.insert(components.active, {})
table.insert(components.active, {})
table.insert(components.inactive, {})
table.insert(components.inactive, {})
table.insert(components.inactive, {})

table.insert(components.active[1], comps.vi_mode.left)
table.insert(components.active[1], comps.file.info)
table.insert(components.active[1], comps.git.branch)
table.insert(components.active[1], comps.git.add)
table.insert(components.active[1], comps.git.change)
table.insert(components.active[1], comps.git.remove)
table.insert(components.inactive[1], comps.vi_mode.left)
table.insert(components.inactive[1], comps.file.info)
-- table.insert(components.active[3], comps.diagnos.err)
-- table.insert(components.active[3], comps.diagnos.warn)
-- table.insert(components.active[3], comps.diagnos.hint)
-- table.insert(components.active[3], comps.diagnos.info)
-- table.insert(components.active[3], comps.lsp.name)
table.insert(components.active[3], comps.file.os)
table.insert(components.active[3], comps.file.position)
table.insert(components.active[3], comps.line_percentage)
table.insert(components.active[3], comps.scroll_bar)
table.insert(components.active[3], comps.vi_mode.right)

require'feline'.setup {
    colors = { bg = colors.bg, fg = colors.fg },
    components = components,
    vi_mode_colors = vi_mode_colors,
    force_inactive = {
        filetypes = {
            'packer',
            'NvimTree',
            'fugitive',
            'fugitiveblame'
        },
        buftypes = {'terminal'},
        bufnames = {}
    }
}

Image of the bar with config above:

image

If it matters here is my own feline config:

local catppuccin = require('catppuccin.core.palettes').get_palette()
local colors = {
    bg = catppuccin.mantle,
    fg = catppuccin.text,
    rosewater = catppuccin.rosewater,
    flamingo = catppuccin.flamingo,
    pink = catppuccin.pink,
    mauve = catppuccin.mauve,
    red = catppuccin.red,
    maroon = catppuccin.maroon,
    peach = catppuccin.peach,
    yellow = catppuccin.yellow,
    green = catppuccin.green,
    teal = catppuccin.teal,
    sky = catppuccin.sky,
    sapphire = catppuccin.sapphire,
    blue = catppuccin.blue,
    lavender = catppuccin.lavender,
}

local vi_mode_colors = {
    ['NORMAL'] = colors.maroon,
    ['INSERT'] = colors.sky,
    ['VISUAL'] = colors.sapphire,
    ['OP'] = colors.maroon,
    ['BLOCK'] = colors.sky,
    ['REPLACE'] = colors.flamingo,
    ['V-REPLACE'] = colors.flamingo,
    ['ENTER'] = colors.lavender,
    ['MORE'] = colors.lavender,
    ['SELECT'] = colors.peach,
    ['COMMAND'] = colors.mauve,
    ['SHELL'] = colors.maroon,
    ['TERM'] = colors.sky,
    ['NONE'] = colors.yellow
}

local lsp = require('feline.providers.lsp')
local vi_mode_utils = require('feline.providers.vi_mode')
local cursor = require('feline.providers.cursor')

local components = {
    active = {{}, {}, {}},
    inactive = {{}, {}}
}

-- Vim Mode
table.insert(components.active[1], {
    provider = function()
        return ' ' .. vi_mode_utils.get_vim_mode().. ' '
    end,
    hl = function()
        local val = {}

        val.fg = vi_mode_utils.get_mode_color()
        val.style = 'bold'

        return val
    end,
    right_sep = ' '
})

-- Git Branch
table.insert(components.active[1], {
    provider = 'git_branch',
    icon = ' ',
    hl = {
        fg = colors.peach,
    },
    left_sep = ' ',
})

-- File
table.insert(components.active[1], {
    provider = {
        name = 'file_info',
        opts = {
            type = 'short',
            file_readonly_icon = '',
            file_modified_icon = '',
        }
    },
    hl = {
        fg = colors.lavender,
    },
    left_sep = ' ',
})

-- Lsp Error
table.insert(components.active[3], {
    provider = 'diagnostic_errors',
    enabled = function() return lsp.diagnostics_exist('Error') end,
    hl = {
        fg = colors.red,
    },
    -- left_sep = ' ',
})

-- Lsp Warning
table.insert(components.active[3], {
    provider = 'diagnostic_warnings',
    enabled = function() return lsp.diagnostics_exist('Warn') end,
    hl = {
        fg = colors.yellow,
    },
    -- left_sep = ' ',
})

-- Lsp Info
table.insert(components.active[3], {
    provider = 'diagnostic_info',
    enabled = function() return lsp.diagnostics_exist('Info') end,
    hl = {
        fg = colors.green,
    },
    -- left_sep = ' ',
})

-- Lsp Server Name
table.insert(components.active[3], {
    provider = 'lsp_client_names',
    icon = ' ',
    hl = {
        fg = colors.yellow,
    },
    right_sep = ' ',
    left_sep = '  ',
})

table.insert(components.active[3], {
    provider = 'line_percentage',
    hl = {
        fg = colors.blue,
    },
    right_sep = ' ',
})

-- Location
table.insert(components.active[3], {
    provider = {
        name = 'position',
    },
    hl = function()
        local val = {}

        val.fg = vi_mode_utils.get_mode_color()

        return val
    end,
    right_sep = ' ',
})

table.insert(components.inactive[1], {
    provider = {
        name = 'file_info',
        opts = {
            type = 'short',
            file_readonly_icon = '',
            file_modified_icon = '',
        }
    },
    hl = {
        fg = colors.lavender,
    },
    left_sep = ' ',
})

table.insert(components.inactive[2], {
    provider = {
        name = 'position',
    },
    hl = function()
        local val = {}

        val.fg = vi_mode_utils.get_mode_color()

        return val
    end,
    right_sep = ' ',
})

require('feline').setup({
    default_bg = colors.bg,
    components = components,
    vi_mode_colors = vi_mode_colors,
})
famiu commented 2 years ago

Changing the color table does not reinitialize Feline's config, you need to use require('feline').use_theme with the new colors table

MysteryMage commented 2 years ago

I see, it now works thank you very much for the help and the quick reply.