Small tweaks
This commit is contained in:
@@ -1,5 +1,3 @@
|
|||||||
--- @param client string
|
|
||||||
--- @param bufnr number
|
|
||||||
local on_attach = function(client, bufnr)
|
local on_attach = function(client, bufnr)
|
||||||
local function opts(desc)
|
local function opts(desc)
|
||||||
if desc then
|
if desc then
|
||||||
|
|||||||
@@ -6,8 +6,9 @@ local prefsFile = configDir .. "/lua/taken/prefs.lua"
|
|||||||
local getAllThemes = function()
|
local getAllThemes = function()
|
||||||
vim.api.nvim_exec_autocmds("User", { pattern = "ThemeSwitcher", modeline = false })
|
vim.api.nvim_exec_autocmds("User", { pattern = "ThemeSwitcher", modeline = false })
|
||||||
|
|
||||||
local colors = vim.fn.globpath(vim.o.rtp, "colors/*", 1, 1)
|
local colors = vim.fn.globpath(vim.o.rtp, "colors/*", true, 1)
|
||||||
local dataDir = vim.fn.stdpath("data")
|
local dataDir = vim.fn.stdpath("data")
|
||||||
|
---@diagnostic disable-next-line: param-type-mismatch
|
||||||
local newpath = string.gsub(dataDir, "%-", "%%-")
|
local newpath = string.gsub(dataDir, "%-", "%%-")
|
||||||
local themes = {}
|
local themes = {}
|
||||||
|
|
||||||
@@ -35,10 +36,22 @@ end
|
|||||||
local change_theme = function(old, new)
|
local change_theme = function(old, new)
|
||||||
-- function from nvchad
|
-- function from nvchad
|
||||||
local file = io.open(prefsFile, "r")
|
local file = io.open(prefsFile, "r")
|
||||||
|
|
||||||
|
if file == nil then
|
||||||
|
vim.notify("Could not open " .. prefsFile, 4)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local added_pattern = string.gsub(old, "-", "%%-")
|
local added_pattern = string.gsub(old, "-", "%%-")
|
||||||
local new_content = file:read("*all"):gsub(added_pattern, new)
|
local new_content = file:read("*all"):gsub(added_pattern, new)
|
||||||
|
|
||||||
file = io.open(prefsFile, "w")
|
file = io.open(prefsFile, "w")
|
||||||
|
|
||||||
|
if file == nil then
|
||||||
|
vim.notify("Could not open " .. prefsFile, 4)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
file:write(new_content)
|
file:write(new_content)
|
||||||
file:close()
|
file:close()
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ function M.themeselector(opts)
|
|||||||
actions.select_default:replace(function()
|
actions.select_default:replace(function()
|
||||||
actions.close(prompt_bufnr)
|
actions.close(prompt_bufnr)
|
||||||
local selection = action_state.get_selected_entry()
|
local selection = action_state.get_selected_entry()
|
||||||
applytofile(selection.value, prefsFile)
|
applytofile(selection.value)
|
||||||
end)
|
end)
|
||||||
-- action_set.shift_selection:enhance({
|
-- action_set.shift_selection:enhance({
|
||||||
-- post = function()
|
-- post = function()
|
||||||
|
|||||||
Reference in New Issue
Block a user