summaryrefslogtreecommitdiff
path: root/lua/lvim/core/theme.lua
diff options
context:
space:
mode:
authorCPea <[email protected]>2022-10-09 05:50:25 +0700
committerGitHub <[email protected]>2022-10-08 22:50:25 +0000
commit8763ed28782a6196d2594016b44dcc9d1aa1b5c6 (patch)
tree656ac137e038f2d37f3a19d35b2fbe03136cca3e /lua/lvim/core/theme.lua
parent5699a5e5573b0766a37b7f115bc49efd52a00822 (diff)
feat: warn user when setting un-installed colorscheme (#2982)
Diffstat (limited to 'lua/lvim/core/theme.lua')
-rw-r--r--lua/lvim/core/theme.lua18
1 files changed, 13 insertions, 5 deletions
diff --git a/lua/lvim/core/theme.lua b/lua/lvim/core/theme.lua
index 394963a0..0f960d3d 100644
--- a/lua/lvim/core/theme.lua
+++ b/lua/lvim/core/theme.lua
@@ -1,3 +1,5 @@
+local Log = require "lvim.core.log"
+
local M = {}
M.config = function()
@@ -85,20 +87,26 @@ end
M.setup = function()
-- avoid running in headless mode since it's harder to detect failures
if #vim.api.nvim_list_uis() == 0 then
- local Log = require "lvim.core.log"
Log:debug "headless mode detected, skipping running setup for lualine"
return
end
local status_ok, theme = pcall(require, "tokyonight")
- if not status_ok then
- return
+ if status_ok and theme then
+ theme.setup(lvim.builtin.theme.options)
end
- theme.setup(lvim.builtin.theme.options)
+ -- ref: https://github.com/neovim/neovim/issues/18201#issuecomment-1104754564
+ local colors = vim.api.nvim_get_runtime_file(("colors/%s.*"):format(lvim.colorscheme), false)
+ if #colors == 0 then
+ Log:warn(string.format("Could not find '%s' colorscheme", lvim.colorscheme))
+ lvim.colorscheme = "tokyonight"
+ end
- require("lvim.core.lualine").setup()
+ vim.g.colors_name = lvim.colorscheme
+ vim.cmd("colorscheme " .. lvim.colorscheme)
+ require("lvim.core.lualine").setup()
require("lvim.core.lir").icon_setup()
end