Neovim - 条件配色方案

问题描述 投票:0回答:1

目标

如果在启动时应用特定的颜色方案,我想为插件设置特定的配置。

我尝试了什么

If vim.cmd("colorscheme") == "oxocarbon" then
    print("this is oxocarbon")
else
    print("this isn't oxocarbon")
end

问题

每次我打开 neovim 都会加载 oxocarbon 主题,但返回的结果是“这不是 oxocarbon”。

最小配置 - init.lua

require('lazy').setup({
{ import = "plugins.core" } -- oxocarbon get installed and loaded
})
require("macros") -- the if statement 

注意

VimEnter
之后,当我输入命令
:lua vim.cmd("colorscheme")
(或简单地
:colorscheme
)时,它返回“oxocarbon”(这是在
VimEnter
期间加载的配置主题)

vim lua neovim
1个回答
0
投票

只是为了给您一个想法,这就是我设置颜色的方法:

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
© www.soinside.com 2019 - 2024. All rights reserved.