diff --git a/init.lua b/init.lua index 90e718f..33a4ed5 100644 --- a/init.lua +++ b/init.lua @@ -70,18 +70,20 @@ end vim.cmd.colorscheme "catppuccin" function set_theme_according_to_darkman() - local obj = vim.system({ 'darkman', 'get' }, { text = true }):wait() - if obj.code == 0 then - local theme = "light" - if obj.stdout == "dark\n" then - theme = "dark" - end - if obj.stdout == "light\n" then - theme = "light" - end + if vim.fn.executable("darkman") == 1 then + local obj = vim.system({ 'darkman', 'get' }, { text = true }):wait() + if obj.code == 0 then + local theme = "light" + if obj.stdout == "dark\n" then + theme = "dark" + end + if obj.stdout == "light\n" then + theme = "light" + end - opt.background = theme - vim.api.nvim_exec_autocmds("ColorScheme", {}) + opt.background = theme + vim.api.nvim_exec_autocmds("ColorScheme", {}) + end end end