Small tweaks

This commit is contained in:
2024-12-22 15:35:34 +01:00
parent 18cc8ef5ad
commit 631de5358a
3 changed files with 15 additions and 4 deletions

View File

@@ -1,5 +1,3 @@
--- @param client string
--- @param bufnr number
local on_attach = function(client, bufnr)
local function opts(desc)
if desc then

View File

@@ -6,8 +6,9 @@ local prefsFile = configDir .. "/lua/taken/prefs.lua"
local getAllThemes = function()
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")
---@diagnostic disable-next-line: param-type-mismatch
local newpath = string.gsub(dataDir, "%-", "%%-")
local themes = {}
@@ -35,10 +36,22 @@ end
local change_theme = function(old, new)
-- function from nvchad
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 new_content = file:read("*all"):gsub(added_pattern, new)
file = io.open(prefsFile, "w")
if file == nil then
vim.notify("Could not open " .. prefsFile, 4)
return
end
file:write(new_content)
file:close()
end

View File

@@ -24,7 +24,7 @@ function M.themeselector(opts)
actions.select_default:replace(function()
actions.close(prompt_bufnr)
local selection = action_state.get_selected_entry()
applytofile(selection.value, prefsFile)
applytofile(selection.value)
end)
-- action_set.shift_selection:enhance({
-- post = function()