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

Saving 'style' between neovim sessions #175

Open
fbaltor opened this issue Jul 1, 2023 · 2 comments
Open

Saving 'style' between neovim sessions #175

fbaltor opened this issue Jul 1, 2023 · 2 comments

Comments

@fbaltor
Copy link

fbaltor commented Jul 1, 2023

Hey, how could I save the current theme set by toggling between sessions? I'm really new to the Neovim lua scripting and tried to solve this with the script below, without success:

-- -- Colorscheme configurations
local get_onedark_style = function()
	if ONEDARK_STYLE == nil then
		ONEDARK_STYLE = 'dark'
	end

	if ONEDARK_STYLE == 'dark' then
		vim.o.background = 'dark'
	end

	if ONEDARK_STYLE == 'light' then
		vim.o.background = 'light'
	end

	return ONEDARK_STYLE
end

local onedark_options =  {
	style = get_onedark_style(),
    -- toggle theme style ---
    toggle_style_key = '<leader>ts', -- keybind to toggle theme style. Leave it nil to disable it, or set it to a string, for example "<leader>ts"
    toggle_style_list = {'light', 'dark'}, -- List of styles to toggle between. The possible styles are {'dark', 'darker', 'cool', 'deep', 'warm', 'warmer', 'light'}
}
require('onedark').setup(onedark_options)
require('onedark').load()

local save_onedark_style = function()
	print(ONEDARK_STYLE)
	if ONEDARK_STYLE == 'light' then
		vim.o.background = 'dark'
		ONEDARK_STYLE = 'dark'
	elseif ONEDARK_STYLE == 'dark' then
		vim.o.background = 'light'
		ONEDARK_STYLE = 'light'
	end

	vim.cmd('wsh!')
end

vim.api.nvim_create_autocmd('ColorScheme', {
  pattern = {'*'},
  callback = save_onedark_style,
})
@fbaltor
Copy link
Author

fbaltor commented Jul 1, 2023

This attempt was a implementation of the following idea:
Screenshot from 2023-06-28 21-19-23

@fbaltor
Copy link
Author

fbaltor commented Aug 12, 2023

Any news on this?

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

1 participant