Skip to content

Commit

Permalink
refactor!: deprecate telescope 'theme' option
Browse files Browse the repository at this point in the history
Pass the theme options in directly now. For example:
```lua
require('dressing').setup({
  select = {
    telescope = require('telescope.themes').get_ivy({})
  }
})
```
  • Loading branch information
stevearc committed Mar 17, 2022
1 parent c9e7f4f commit 4542292
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 17 deletions.
16 changes: 10 additions & 6 deletions lua/dressing/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,9 @@ local default_config = {
backend = { "telescope", "fzf_lua", "fzf", "builtin", "nui" },

-- Options for telescope selector
telescope = {
-- can be 'dropdown', 'cursor', or 'ivy'
-- or you can use a configuration directly:
-- theme = require('telescope.themes').get_ivy({...})
theme = "dropdown",
},
-- These are passed into the telescope picker directly. Can be used like:
-- telescope = require('telescope.themes').get_ivy({...})
telescope = nil,

-- Options for fzf selector
fzf = {
Expand Down Expand Up @@ -135,6 +132,13 @@ M.update = function(opts)
)
end

if newconf.select.telescope and newconf.select.telescope.theme then
vim.notify(
"Deprecated: dressing.select.telescope.theme is deprecated. Pass in telescope options directly (:help dressing)",
vim.log.levels.WARN
)
end

for k, v in pairs(newconf) do
M[k] = v
end
Expand Down
30 changes: 19 additions & 11 deletions lua/dressing/select/telescope.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,27 @@ M.select = function(config, items, opts, on_choice)
}
end

local theme
local ttype = type(config.theme)
if ttype == "string" then
theme = themes[string.format("get_%s", config.theme)]
elseif ttype == "function" then
theme = config.theme
else
theme = function(s)
return vim.tbl_extend("keep", s, config.theme or {})
local picker_opts = config

if picker_opts == nil then
-- Default to the dropdown theme if no options supplied

This comment has been minimized.

Copy link
@kkharji

kkharji Mar 19, 2022

Contributor

NICE 👌

picker_opts = themes.get_dropdown()
elseif config.theme then
-- Backwards compatibility for the `theme` option
local theme
local ttype = type(config.theme)
if ttype == "string" then
theme = themes[string.format("get_%s", config.theme)]
elseif ttype == "function" then
theme = config.theme
else
theme = function(s)
return vim.tbl_extend("keep", s, config.theme or {})
end
end
end

local picker_opts = vim.tbl_extend("keep", config, theme({}))
picker_opts = vim.tbl_extend("keep", config, theme({}))
end

pickers.new(picker_opts, {
prompt_title = opts.prompt,
Expand Down

0 comments on commit 4542292

Please sign in to comment.