Updated theme switchers
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
local oldstring = 'M.colorscheme = .*"'
|
||||
local configDir = vim.fn.stdpath("config")
|
||||
local prefsFile = configDir .. "/lua/taken/prefs.lua"
|
||||
|
||||
--- themes
|
||||
--- @return table
|
||||
local getAllThemes = function()
|
||||
vim.api.nvim_exec_autocmds("User", { pattern = "ThemeSwitcher", modeline = false })
|
||||
|
||||
@@ -26,7 +30,10 @@ local getAllThemes = function()
|
||||
return themes
|
||||
end
|
||||
|
||||
local change_theme = function(old, new, prefsFile)
|
||||
--- change theme
|
||||
--- @param old string
|
||||
--- @param new string
|
||||
local change_theme = function(old, new)
|
||||
-- function from nvchad
|
||||
local file = io.open(prefsFile, "r")
|
||||
local added_pattern = string.gsub(old, "-", "%%-")
|
||||
@@ -37,7 +44,9 @@ local change_theme = function(old, new, prefsFile)
|
||||
file:close()
|
||||
end
|
||||
|
||||
local applytofile = function(choice, prefsFile)
|
||||
--- applytofile
|
||||
--- @param choice string
|
||||
local applytofile = function(choice)
|
||||
if choice == nil then
|
||||
vim.notify("No theme selected!", 4)
|
||||
return
|
||||
@@ -45,7 +54,7 @@ local applytofile = function(choice, prefsFile)
|
||||
|
||||
vim.cmd("colorscheme " .. choice)
|
||||
local newstring = 'M.colorscheme = "' .. choice .. '"'
|
||||
change_theme(oldstring, newstring, prefsFile)
|
||||
change_theme(oldstring, newstring)
|
||||
|
||||
local cursorcolumncolor = vim.fn.synIDattr(vim.fn.hlID("CursorColumn"), "bg")
|
||||
if cursorcolumncolor ~= "" then
|
||||
|
||||
Reference in New Issue
Block a user