3 Commits

Author SHA1 Message Date
Miguel Palhas ed7889c204 wip 2026-02-16 16:14:26 +00:00
Miguel Palhas 8c51fe7d9b Merge branch 'main' into darkman 2026-02-16 16:09:21 +00:00
Miguel Palhas 9345419fad wip 2026-02-16 16:08:04 +00:00
4 changed files with 82 additions and 1 deletions
+6
View File
@@ -35,3 +35,9 @@ require "nvchad.autocmds"
vim.schedule(function()
require "mappings"
end)
-- Start theme sync with system (darkman)
vim.schedule(function()
local theme_sync = require "theme-sync"
theme_sync.watch()
end)
+14 -1
View File
@@ -2,6 +2,19 @@
-- https://github.com/NvChad/ui/blob/v2.5/lua/nvconfig.lua
-- Please read that file to know all available options :(
-- Get system theme from darkman
local function get_system_theme()
local handle = io.popen("darkman get 2>/dev/null")
if handle then
local result = handle:read("*a")
handle:close()
if result and result:match("light") then
return "github_light" -- or any other light theme you prefer
end
end
return "onenord" -- default dark theme
end
---@type ChadrcConfig
local M = {
ui = {
@@ -10,7 +23,7 @@ local M = {
},
},
base46 = {
theme = "onenord",
theme = get_system_theme(),
},
nvdash = {
+6
View File
@@ -21,3 +21,9 @@ vim.g.neovide_scroll_animation_length = 0.15
vim.g.neovide_cursor_animation_length = 0.11
vim.o.swapfile = false
-- Command to manually sync theme with system
vim.api.nvim_create_user_command("ThemeSync", function()
require("theme-sync").sync()
vim.notify("Theme synced with system", vim.log.levels.INFO)
end, { desc = "Sync theme with system (darkman)" })
+56
View File
@@ -0,0 +1,56 @@
-- Sync Neovim theme with system (darkman)
local M = {}
-- Theme mappings
M.themes = {
light = "github_light", -- Change to your preferred light theme
dark = "onenord", -- Change to your preferred dark theme
}
-- Get current system theme from darkman
function M.get_system_mode()
local handle = io.popen("darkman get 2>/dev/null")
if handle then
local result = handle:read("*a")
handle:close()
if result and result:match("light") then
return "light"
end
end
return "dark"
end
-- Apply theme based on mode
function M.apply_theme(mode)
local theme = M.themes[mode] or M.themes.dark
-- Update the theme using NvChad's base46
local current = vim.g.nvchad_theme or theme
require("nvchad.utils").replace_word('theme = "' .. current .. '"', 'theme = "' .. theme .. '"')
require("base46").load_all_highlights()
vim.g.nvchad_theme = theme
end
-- Sync with system theme
function M.sync()
local mode = M.get_system_mode()
M.apply_theme(mode)
end
-- Watch for theme changes (checks periodically)
function M.watch()
local timer = vim.loop.new_timer()
local last_mode = M.get_system_mode()
timer:start(0, 5000, vim.schedule_wrap(function()
local current_mode = M.get_system_mode()
if current_mode ~= last_mode then
M.apply_theme(current_mode)
last_mode = current_mode
end
end))
end
return M