An extension for Telescope plugin to switch colorschemes with preview. It will read all your installed themes
Using lazy.nvim
{
'andrew-george/telescope-themes',
config = function()
require('telescope').load_extension('themes')
end
}
OR
As a dependancy in telescope config file (example in lazy.nvim)
{
'nvim-telescope/telescope.nvim',
cmd = 'Telescope',
lazy = true,
dependencies = {
'andrew-george/telescope-themes',
-- other dependencies
},
config = function()
-- load extension
local telescope = require('telescope')
telescope.load_extension('themes')
end
}
:Telescope themes
or map it to a key
vim.keymap.set("n", "<leader>th", ":Telescope themes<CR>", {noremap = true, silent = true, desc = "Theme Switcher"})
The extension can receive any telescope option in addition to custom options
NOTE: All configurations should go under extensions
table in telescope config file
Example:
{
"nvim-telescope/telescope.nvim",
dependencies = {
"andrew-george/telescope-themes",
-- other dependencies
},
opts = {
extensions = {
themes = {
-- you can add regular telescope config
-- that you want to apply on this picker only
layout_config = {
horizontal = {
width = 0.8,
height = 0.7,
},
},
-- extension specific config
enable_previewer = true, -- (boolean) -> show/hide previewer window
enable_live_preview = false, -- (boolean) -> enable/disable live preview
ignore = { "default", "desert", "elflord", "habamax" },
-- (table) -> provide table of theme names to ignore
-- all builtin themes are ignored by default
persist = {
enabled = true, -- enable persisting last theme choice
-- override path to file that execute colorscheme command
path = vim.fn.stdpath("config") .. "/lua/colorscheme.lua"
}
},
},
},
}
Key | Value | Description |
---|---|---|
enable_previewer |
boolean |
Show / Hide previewer window |
enable_live_preview |
boolean |
Enable / Disable live preview |
ignore |
table of themes names |
Ignore specific themes from appearing in the list |
persist |
{ enabled: boolean, path: string} |
- Enable / Disable persisting last theme choice, - Override file path to write your colorscheme command WARNING: THIS MUST BE AN EMPTY FILE AS IT WILL BE COMPLETELY OVERWRITTEN Default file path : {root_nvim_config}/lua/current-theme.lua |
As the extension is writing the colorscheme command in your config, and neovim configs are very indvidual and unique, I wouldn't be able to predict which part to manipulate, so the extension creates a file named current-theme.lua will be generated in root of /lua directory, it contains the command responsible for persisting latest theme selection, and it's overwritten by the extension on every new selection.
Now you have to require current-theme.lua in your init.lua
- It is inspired by NvChad's theme switcher, but written to work with any configuration. Now you have to require current-theme.lua at the end of your init.lua to apply that theme on every startup.