Fixes (#259)
* Missed in 154ba7d
* utils/change-theme: Check theme name for magic chars
This commit is contained in:
parent
9c134872fb
commit
4abf43aa99
|
@ -110,7 +110,6 @@ M.theme_switcher = function(opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
if reload_theme(final_theme) then
|
if reload_theme(final_theme) then
|
||||||
vim.g.current_nvchad_theme = final_theme
|
|
||||||
if change then
|
if change then
|
||||||
-- ask for confirmation to set as default theme
|
-- ask for confirmation to set as default theme
|
||||||
local ans = string.lower(vim.fn.input("Set " .. new_theme .. " as default theme ? [y/N] ")) == "y"
|
local ans = string.lower(vim.fn.input("Set " .. new_theme .. " as default theme ? [y/N] ")) == "y"
|
||||||
|
@ -120,11 +119,8 @@ M.theme_switcher = function(opts)
|
||||||
else
|
else
|
||||||
-- will be used in restoring nvchad theme var
|
-- will be used in restoring nvchad theme var
|
||||||
final_theme = current_theme
|
final_theme = current_theme
|
||||||
vim.g.current_nvchad_theme = final_theme
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- open a buffer and close it to reload the statusline
|
|
||||||
vim.cmd("new|bwipeout")
|
|
||||||
else
|
else
|
||||||
final_theme = current_theme
|
final_theme = current_theme
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,6 +13,9 @@ M.change_theme = function(current_theme, new_theme)
|
||||||
local file = vim.fn.stdpath("config") .. "/lua/chadrc.lua"
|
local file = vim.fn.stdpath("config") .. "/lua/chadrc.lua"
|
||||||
-- store in data variable
|
-- store in data variable
|
||||||
local data = assert(M.file("r", file))
|
local data = assert(M.file("r", file))
|
||||||
|
-- escape characters which can be parsed as magic chars
|
||||||
|
current_theme = current_theme:gsub("%p", "%%%0")
|
||||||
|
new_theme = new_theme:gsub("%p", "%%%0")
|
||||||
local find = "theme = .?" .. current_theme .. ".?"
|
local find = "theme = .?" .. current_theme .. ".?"
|
||||||
local replace = 'theme = "' .. new_theme .. '"'
|
local replace = 'theme = "' .. new_theme .. '"'
|
||||||
local content = string.gsub(data, find, replace)
|
local content = string.gsub(data, find, replace)
|
||||||
|
|
Loading…
Reference in New Issue