mirror of
https://github.com/harivansh-afk/nix.git
synced 2026-04-15 09:01:16 +00:00
nvim theme
This commit is contained in:
parent
67128fe09b
commit
ac7a2c4811
3 changed files with 20 additions and 4 deletions
|
|
@ -10,6 +10,7 @@ return {
|
|||
"nvim-lualine/lualine.nvim",
|
||||
dependencies = { "nvim-tree/nvim-web-devicons" },
|
||||
config = function()
|
||||
local theme_status = function() return require("theme").statusline_label() end
|
||||
local theme = {
|
||||
normal = {
|
||||
a = { gui = "bold" },
|
||||
|
|
@ -37,7 +38,7 @@ return {
|
|||
lualine_c = { { "filename", path = 0 } },
|
||||
lualine_x = { "diagnostics" },
|
||||
lualine_y = { "filetype" },
|
||||
lualine_z = { "progress" },
|
||||
lualine_z = { theme_status, "progress" },
|
||||
},
|
||||
}
|
||||
end,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
local M = {}
|
||||
|
||||
local theme_state_file = vim.fn.stdpath "state" .. "/theme/current"
|
||||
local xdg_state_home = vim.env.XDG_STATE_HOME or (vim.env.HOME .. "/.local/state")
|
||||
local theme_state_file = xdg_state_home .. "/theme/current"
|
||||
local active_schemes = {
|
||||
cozybox = true,
|
||||
["cozybox-light"] = true,
|
||||
|
|
@ -50,6 +51,16 @@ local function colorscheme_for_mode(mode)
|
|||
return "cozybox"
|
||||
end
|
||||
|
||||
function M.statusline_label()
|
||||
local mode = vim.g.cozybox_theme_mode or read_mode()
|
||||
local scheme = vim.g.colors_name or colorscheme_for_mode(mode)
|
||||
local expected_scheme = colorscheme_for_mode(mode)
|
||||
|
||||
if scheme == expected_scheme then return "theme:" .. mode end
|
||||
|
||||
return ("theme:%s/%s"):format(mode, scheme)
|
||||
end
|
||||
|
||||
function M.apply(mode)
|
||||
local next_mode = mode or read_mode()
|
||||
local next_scheme = colorscheme_for_mode(next_mode)
|
||||
|
|
@ -60,7 +71,11 @@ function M.apply(mode)
|
|||
|
||||
vim.g.cozybox_theme_mode = next_mode
|
||||
apply_cozybox_overrides()
|
||||
vim.schedule(function() pcall(vim.cmd, "redraw!") end)
|
||||
vim.schedule(function()
|
||||
local ok, lualine = pcall(require, "lualine")
|
||||
if ok then pcall(lualine.refresh, { place = { "statusline" } }) end
|
||||
pcall(vim.cmd, "redraw!")
|
||||
end)
|
||||
end
|
||||
|
||||
function M.setup()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue