Skip to content

Commit

Permalink
chore: fix theme switcher
Browse files Browse the repository at this point in the history
  • Loading branch information
budchirp committed Sep 17, 2023
1 parent ecb147e commit 234de14
Showing 1 changed file with 35 additions and 11 deletions.
46 changes: 35 additions & 11 deletions lua/telescope/_extensions/theme_switcher.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,44 @@ local theme_switcher = function()
results = base46_utils.get_themes(),
}),
sorter = conf.generic_sorter(),
attach_mappings = function(prompt_bufnr, _)
vim.api.nvim_create_autocmd('TextChangedI', {
buffer = prompt_bufnr,
callback = function()
if action_state.get_selected_entry() then
base46.change_theme(action_state.get_selected_entry()[1], false)
end
end,
})
attach_mappings = function(prompt_bufnr, map)
vim.schedule(function()
vim.api.nvim_create_autocmd('TextChangedI', {
buffer = prompt_bufnr,
callback = function()
if action_state.get_selected_entry() then
base46.change_theme(action_state.get_selected_entry()[1], false)
end
end,
})
end)

actions.select_default:replace(function()
actions.close(prompt_bufnr)
if action_state.get_selected_entry() then
actions.close(prompt_bufnr)

base46.change_theme(action_state.get_selected_entry()[1], true)
end
end)

map('i', '<C-n>', function()
actions.move_selection_next(prompt_bufnr)
base46.change_theme(action_state.get_selected_entry()[1], false)
end)

map('i', '<Down>', function()
actions.move_selection_next(prompt_bufnr)
base46.change_theme(action_state.get_selected_entry()[1], false)
end)

map('i', '<C-p>', function()
actions.move_selection_previous(prompt_bufnr)
base46.change_theme(action_state.get_selected_entry()[1], false)
end)

base46.change_theme(action_state.get_selected_entry()[1], true)
map('i', '<Up>', function()
actions.move_selection_previous(prompt_bufnr)
base46.change_theme(action_state.get_selected_entry()[1], false)
end)

return true
Expand Down

0 comments on commit 234de14

Please sign in to comment.