nvim-lualine / lualine.nvim

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

Need help with supporting lualine in a custom theme i built #1272

Closed 0xhoussam closed 3 weeks ago

0xhoussam commented 4 weeks ago

my colorscheme directory structure

 .
├──  colors
│  └──  fleet.lua
├──  LICENSE
├──  lua
│  ├──  fleet
│  │  ├──  groups.lua
│  │  ├──  init.lua
│  │  └──  palette.lua
│  └──  lualine
│     └──  themes
│        └──  fleet.lua
└──  README.md

the content of lua/lualine/themes/fleet.lua

local palette = require("lua.fleet.palette").palette
local fleet = {}

fleet.normal = {
    a = { fg = palette.background, bg = palette.blue, gui = "bold" },
    b = { fg = palette.blue, bg = "NONE" },
    c = { fg = palette.light, bg = "NONE" },
}

fleet.visual = {
    a = { fg = palette.background, bg = palette.yellow, gui = "bold" },
    b = { fg = palette.yellow, "NONE" },
}

fleet.inactive = {
    a = { fg = palette.light, bg = palette.background, gui = "bold" },
    b = { fg = palette.dark_gray, bg = "NONE" },
    c = { fg = palette.dark_gray, bg = "NONE" },
}

fleet.replace = {
    a = { fg = palette.background, bg = palette.red, gui = "bold" },
    b = { fg = palette.red, bg = "NONE" },
    c = { fg = palette.fg, bg = "NONE" },
}

fleet.insert = {
    a = { fg = palette.background, bg = palette.green, gui = "bold" },
    b = { fg = palette.green, bg = "NONE" },
    c = { fg = palette.light, bg = "NONE" },
}

fleet.terminal = {
    a = { fg = palette.bg, bg = palette.green, gui = "bold" },
    b = { fg = palette.fg, bg = "NONE" },
    c = { fg = palette.fg, bg = "NONE" },
}

fleet.command = {
    a = { fg = palette.bg, bg = palette.pink, gui = "bold" },
    b = { fg = palette.pink, bg = "NONE" },
    c = { fg = palette.light, bg = "NONE" },
}

return fleet

lualine config

config = {
  ...
  options = {
  ...
  theme = 'fleet'
  }
}

and this is the warning i got Theme `fleet` not found, falling back to `auto`. Check if spelling is right.

but oddly enough when i open my colorscheme directory to edit it the theme is applied with no errors

shadmansaleh commented 3 weeks ago

Are you doing some sort of lazy loading? In that case is your colorscheme loaded before lualines setup is called?

0xhoussam commented 3 weeks ago

i am using lazy in my config this is how am importing the colorscheme

    {
        dir = "~/projects/fleet",
        dev = true,
        lazy = false,
        priority = 1000,
    },

and with some print debuging i can confirm that the colorscheme is loaded before the lualine

shadmansaleh commented 3 weeks ago

https://github.com/0xhoussam/fleet.nvim/blob/f654d813afd133a2c9b37a3c64f51d8322216ccf/lua/lualine/themes/fleet.lua#L1

it should be

local palette = require("fleet.palette").palette

You are using require wrong.