如果在启动时应用特定的颜色方案,我想为插件设置特定的配置。
If vim.cmd("colorscheme") == "oxocarbon" then
print("this is oxocarbon")
else
print("this isn't oxocarbon")
end
每次我打开 neovim 都会加载 oxocarbon 主题,但返回的结果是“这不是 oxocarbon”。
require('lazy').setup({
{ import = "plugins.core" } -- oxocarbon get installed and loaded
})
require("macros") -- the if statement
在
VimEnter
之后,当我输入命令:lua vim.cmd("colorscheme")
(或简单地:colorscheme
)时,它返回“oxocarbon”(这是在VimEnter
期间加载的配置主题)
只是为了给您一个想法,这就是我设置颜色的方法:
local colorscheme = "tokyonight"
-- vim.notify("Selected colorscheme: " .. colorscheme) -- Debugging message
-- local colorscheme = "tokyonight"
local status_ok, _ = pcall(vim.cmd, "colorscheme " .. colorscheme)
if not status_ok then
vim.notify("colorscheme " .. colorscheme .. " not found!")
return
end