From 45422928547f25ed36e9394c9c55e9cc0f9e1b6d Mon Sep 17 00:00:00 2001 From: Steven Arcangeli Date: Wed, 16 Mar 2022 21:03:10 -0700 Subject: [PATCH] refactor!: deprecate telescope 'theme' option Pass the theme options in directly now. For example: ```lua require('dressing').setup({ select = { telescope = require('telescope.themes').get_ivy({}) } }) ``` --- lua/dressing/config.lua | 16 ++++++++++------ lua/dressing/select/telescope.lua | 30 +++++++++++++++++++----------- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/lua/dressing/config.lua b/lua/dressing/config.lua index 6fa2741..e8e3d38 100644 --- a/lua/dressing/config.lua +++ b/lua/dressing/config.lua @@ -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 = { @@ -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 diff --git a/lua/dressing/select/telescope.lua b/lua/dressing/select/telescope.lua index bf5fe6b..3c4156b 100644 --- a/lua/dressing/select/telescope.lua +++ b/lua/dressing/select/telescope.lua @@ -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 + 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,