From 77cab9ad6321adf4394f442324cf61fa6e4851ef Mon Sep 17 00:00:00 2001 From: Chris Grieser <73286100+chrisgrieser@users.noreply.github.com> Date: Sat, 15 Jun 2024 15:29:34 +0200 Subject: [PATCH] feat(builtin.colorscheme): add option `ignore_builtins` (#3155) --- doc/telescope.txt | 10 ++++++---- lua/telescope/builtin/__internal.lua | 13 +++++++++++++ lua/telescope/builtin/init.lua | 1 + 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/doc/telescope.txt b/doc/telescope.txt index 7d3713b..f968ac0 100644 --- a/doc/telescope.txt +++ b/doc/telescope.txt @@ -1478,10 +1478,12 @@ builtin.colorscheme({opts}) *telescope.builtin.colorscheme()* {opts} (table) options to pass to the picker Options: ~ - {colors} (table) a list of additional colorschemes to - explicitly make available to telescope - (default: {}) - {enable_preview} (boolean) if true, will preview the selected color + {colors} (table) a list of additional colorschemes to + explicitly make available to telescope + (default: {}) + {enable_preview} (boolean) if true, will preview the selected color + {ignore_builtins} (boolean) if true, builtin colorschemes are not + listed builtin.marks({opts}) *telescope.builtin.marks()* diff --git a/lua/telescope/builtin/__internal.lua b/lua/telescope/builtin/__internal.lua index 50a764d..5972244 100644 --- a/lua/telescope/builtin/__internal.lua +++ b/lua/telescope/builtin/__internal.lua @@ -993,6 +993,19 @@ internal.colorscheme = function(opts) end, vim.fn.getcompletion("", "color")) ) + if opts.ignore_builtins then + -- stylua: ignore + local builtins = { + "blue", "darkblue", "default", "delek", "desert", "elflord", "evening", + "habamax", "industry", "koehler", "lunaperche", "morning", "murphy", + "pablo", "peachpuff", "quiet", "retrobox", "ron", "shine", "slate", + "sorbet", "torte", "vim", "wildcharm", "zaibatsu", "zellner", + } + colors = vim.tbl_filter(function(color) + return not vim.tbl_contains(builtins, color) + end, colors) + end + local previewer if opts.enable_preview then -- define previewer diff --git a/lua/telescope/builtin/init.lua b/lua/telescope/builtin/init.lua index 031eff1..fd78c7e 100644 --- a/lua/telescope/builtin/init.lua +++ b/lua/telescope/builtin/init.lua @@ -357,6 +357,7 @@ builtin.buffers = require_on_exported_call("telescope.builtin.__internal").buffe ---@param opts table: options to pass to the picker ---@field colors table: a list of additional colorschemes to explicitly make available to telescope (default: {}) ---@field enable_preview boolean: if true, will preview the selected color +---@field ignore_builtins boolean: if true, builtin colorschemes are not listed builtin.colorscheme = require_on_exported_call("telescope.builtin.__internal").colorscheme --- Lists vim marks and their value, jumps to the mark on ``