tamton-aquib / staline.nvim

A modern lightweight statusline and bufferline plugin for neovim in lua.
MIT License
380 stars 17 forks source link

Highlight groups do not activate on start #61

Open ghost opened 8 months ago

ghost commented 8 months ago

Problem: The statusbar uses nvim default statusbar highlight colours on start and only uses defined colors when a editable buffer is opened

Possible Explanation: The get_statusline() function in the staline.nvim file contains an if statement at the beginning which might be barring the colours to set up on non editable buffers like the dashboard, netrw or help

Possible Solution: Move the call_highlights() function call above the if statement in the function

M.get_statusline = function(status)
local mode = vim.api.nvim_get_mode()['mode']
local fgColor = status and conf.mode_colors[mode] or t.inactive_color
local bgColor = status and t.bg or t.inactive_bgcolor

call_highlights(fgColor, bgColor)

if conf.special_table[vim.bo.ft] ~= nil then
local special = conf.special_table[vim.bo.ft]
return "%#Staline#%=" .. special[2] .. special[1] .. "%="
end

M.sections = {}

local modeIcon = conf.mode_icons[mode] or "󰋜 "

local f_name = t.full_path and '%F' or '%t'
-- TODO: original color of icon
local f_icon = util.get_file_icon(vim.fn.expand('%:t'), vim.fn.expand('%:e'))
local edited = vim.bo.mod and t.mod_symbol or ""
-- TODO: need to support b, or mb?
local size = ("%.1f"):format(vim.fn.getfsize(vim.api.nvim_buf_get_name(0))/1024)

.
.
.
end

Solution solves problem: Yes

Side effects: Unknown

ghost commented 8 months ago

With solution image image

Without solution image image

tamton-aquib commented 8 months ago

Thank you for the detailed explanation. I'll look this weekend 👍🏻

tamton-aquib commented 8 months ago

Although I feel like its a colorscheme loading issue. If your using lazy.nvim (package manager) check with event="Colorscheme" or priority

ghost commented 8 months ago

@tamton-aquib Yeah sure! Take your time...

I am fairly certain it isnt... I have tried calling the functions manually... event Colorscheme doesnt work and my colorscheme (navarasu/onedark) is already set to priority 1000 which is the highest in my config..

Cheers! :)