Replies: 4 comments 26 replies
-
You can keep all Personally, I choose the |
Beta Was this translation helpful? Give feedback.
-
In my case I have one colorscheme set as default (tokyonight) and the rest I lazy-load with {
"rose-pine/neovim",
name = "rose-pine",
keys = {
{ "<leader>uC", Util.telescope("colorscheme", { enable_preview = true }), desc = "Colorscheme with preview" },
},
}, I use Lazyvim and |
Beta Was this translation helpful? Give feedback.
-
Instead of setting the colorscheme in the config file, get the desired colorscheme name from either some persistent storage or some variable which you can access during start up. -- read from txt, dumb but works
local function load()
local file = io.open(vim.fn.stdpath('config') .. '/colorscheme.txt', 'r')
if file then
local name = file:read('*l')
file:close()
return name
end
end
local name = load()
if name and name ~= '' then
for _, spec in ipairs(specs) do
if spec.name == name then
spec.lazy = false
spec.priority = 100
else
spec.lazy = true
end
end
end
return specs Also if you'd like to change colorscheme mid-session, make yourself a custom command instead of the built in colorscheme command. You can do anything without having to think of how to use autocmd and such. vim.api.nvim_create_user_command('Colorpencil', function(opts)
save(opts.args) -- this function saves the value to txt
for _, spec in ipairs(specs) do
if spec.name == opts.args then
spec.config()
return
end
end
end, { nargs = 1 }) |
Beta Was this translation helpful? Give feedback.
-
I personally use Huez.nvim to manage my color schemes. Load all schemes using Lazy.nvim and persist and toggle themes using Huez(bind the toggle to a keymap). But otherwise Telescope also works pretty great! |
Beta Was this translation helpful? Give feedback.
-
Hi, I'm trying to figure out what's the best way to handle a setup with many colorschemes (let's say, 20 or more) to choose from. Right now, I found the following approaches.
Setup all of them with
lazy = false, priority = 1000
and add a clause to theconfig()
function to exit unless the colorscheme is the chosen one.I have an
user.config
module and code like:for each colorscheme.
This solution has the following pros/cons:
:colorscheme
and all of them are updated automatically via:Lazy
;Only load the chosen colorscheme and skip the others via
enabled = false
This solution has the following pros/cons:
:Lazy
and are not chosable via:colorscheme
.(Not working) Load the chosen colorscheme with
lazy = false
and lazy load others withlazy = true
I hacked together some code to get this setup, expecting to get the
pros
of the two solutions above, without any cons. However, it seems that settinglazy = true
for colorschemes is the same as setting them toenabled = false
, and they aren't chosable via:colorscheme
.Other considerations / experiments
I think the way to go would be to add some sort of
event = "ColorSchemePromptEnter"
, but I have no idea how to set this up.event = "CmdlineEnter"
is the closest I could get, but obviously it's suboptimal.Or maybe there's another way built-in into lazy.nvim that I still haven't found? Any suggestion / hint?
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions