run darkman specific code only if darkman is available

This commit is contained in:
Antoine Vaure 2025-10-10 14:50:44 +02:00
parent f65569dc50
commit 5fbfe594d9

View file

@ -70,6 +70,7 @@ end
vim.cmd.colorscheme "catppuccin" vim.cmd.colorscheme "catppuccin"
function set_theme_according_to_darkman() function set_theme_according_to_darkman()
if vim.fn.executable("darkman") == 1 then
local obj = vim.system({ 'darkman', 'get' }, { text = true }):wait() local obj = vim.system({ 'darkman', 'get' }, { text = true }):wait()
if obj.code == 0 then if obj.code == 0 then
local theme = "light" local theme = "light"
@ -83,6 +84,7 @@ function set_theme_according_to_darkman()
opt.background = theme opt.background = theme
vim.api.nvim_exec_autocmds("ColorScheme", {}) vim.api.nvim_exec_autocmds("ColorScheme", {})
end end
end
end end
set_theme_according_to_darkman() set_theme_according_to_darkman()