Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

theme does not set colors_name variable #8

Closed
jlaunay opened this issue Nov 10, 2022 · 7 comments
Closed

theme does not set colors_name variable #8

jlaunay opened this issue Nov 10, 2022 · 7 comments

Comments

@jlaunay
Copy link

jlaunay commented Nov 10, 2022

I tried with a minimal setup with only this theme (no plugin).

:colorscheme blue
:echo g:colors_name
blue
:colorscheme oh-lucy
:echo g:colors_name
E121: Undefined variable: g:colors_name

I tried removing vim.g.colors_name = 'oh-lucy' from init.lua and add it to the M.load function in util.lua and colors_name is defined.

Am I missing something to configure for this to work?

@yazeed1s
Copy link
Owner

Hey @jlaunay, I am not actually sure what you are doing, you definitely need to download the plugin using vim-plug or packer in order to use it.

@yazeed1s
Copy link
Owner

@jlaunay
Copy link
Author

jlaunay commented Nov 11, 2022

Hey @jlaunay, I am not actually sure what you are doing, you definitely need to download the plugin using vim-plug or packer in order to use it.

Hi @yazeed1s thanks for your answer and for this theme.
I'm using dein and have no problem with other themes.

In order to test with no plugin I'm using this minimal.vim config file

set rtp^=~/.local/share/nvim/dein/repos/github.com/Yazeed1s/oh-lucy.nvim/
set vif=NONE
filetype plugin indent on
syntax enable

And call with

nvim -Nu minimal.vim

Maybe I'm doing it wrong but I do not know what :/

@yazeed1s
Copy link
Owner

Hi @jlaunay, i never actually tested the plugin with dein, however the way you are calling the plugin is wrong. 'minimal' is actually my other theme, not this one. Try typing

nvim -Nu oh-lucy.nvim

and hopefully it will work. if not, let me know so i can reproduce the issue myself.

@jlaunay
Copy link
Author

jlaunay commented Nov 11, 2022

minimal.vim is not the plugin I try to load, it's the minimal vimrc file I call with nvim -u option (the content of the file is above) in order to try the theme with no plugin.

I just tried with packer and only your plugin using the following init file (it use only packer, oh-lucy into a temp dir):

-- ignore default config and plugins
vim.opt.runtimepath:remove(vim.fn.expand("~/.config/nvim"))
vim.opt.packpath:remove(vim.fn.expand("~/.local/share/nvim/site"))

-- append test directory
local test_dir = "/tmp/nvim-config"
vim.opt.runtimepath:append(vim.fn.expand(test_dir))
vim.opt.packpath:append(vim.fn.expand(test_dir))

-- install packer
local install_path = test_dir .. "/pack/packer/start/packer.nvim"
local install_plugins = false

if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
	vim.cmd("!git clone https://github.com/wbthomason/packer.nvim " .. install_path)
	vim.cmd("packadd packer.nvim")
	install_plugins = true
end

local packer = require("packer")

packer.init({
	package_root = test_dir .. "/pack",
	compile_path = test_dir .. "/plugin/packer_compiled.lua",
})

packer.startup(function()
	local use = function(args)
		if type(args) == "string" then
			local plugin = args
			args = { plugin }
		end

		args.event = "User LoadPlugins"

		packer.use(args)
	end

	-- Install Packer
	packer.use("wbthomason/packer.nvim")

	-- Plugin to test
	use("Yazeed1s/oh-lucy.nvim")

	if install_plugins then
		packer.sync()
	else
		-- load plugins at your earliest convenience
		vim.defer_fn(function()
			vim.cmd("doautocmd User LoadPlugins")
		end, 1)
	end
end)

Calling nvim -u name_of_the_init_file_above.lua and exec :colorscheme oh-lucy switch the theme, this is not the problem.
But if I try to exec :echo g:colors_name instead of oh-lucy I get E121: Undefined variable: g:colors_name.

If you try :colorscheme darkblue (or any other builtin theme) :echo g:colors_name give the current colorscheme.

In the code this variable is defined here

I'm using this variable to restore any theme change at nvim startup.

Here is my nvim version

NVIM v0.8.0
Build type: Release
LuaJIT 2.1.0-beta3
Compilé par builduser

Features: +acl +iconv +tui

You do not reproduce the issue? Is the variable defined for you?
Thanks for your help !

@tan-wei
Copy link

tan-wei commented Aug 25, 2023

I met the same issue: After I use oh-lucy, then use :colorscheme to print the name of color scheme, it will show default instead of oh-lucy, which is not the truth.

@tan-wei
Copy link

tan-wei commented Aug 25, 2023

For most of color schemes in vim/neovim, g:colors_name is set to tell us which color scheme is used. It is important when we use randomized color schemes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants