From 5e16fbc8eac42280ae6e18ca38098a833c5e08ba Mon Sep 17 00:00:00 2001 From: kkharji Date: Wed, 23 Nov 2022 19:26:29 +0300 Subject: feat(picker): command history filter (#2132) * feat(picker): command history filter I've recently start using command history. For sometime was a bit annoyed of unrelevant commands like edit/write and others (most likely only used once) I've considered using lua patterns, however, logical `or` isn't a thing. Additionally, passing a list of lua patterns and checking each pattern for each command history entry felt tedious. This PR introduce a new optional function to filter command history items. For example, in my configurations ~~~lua local command_history_ignore = vim.regex "edit\\|Move\\|write\\|Write\\|e\\s\\|lua\\sI(" overrides.command_history = minimal { prompt_prefix = "CMDHistory> ", filter_fn = function(item) if #item < 3 then return false else return not command_history_ignore:match_str(item) end end, } ~~~ * [docgen] Update doc/telescope.txt skip-checks: true Co-authored-by: Github Actions --- lua/telescope/builtin/init.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'lua/telescope/builtin/init.lua') diff --git a/lua/telescope/builtin/init.lua b/lua/telescope/builtin/init.lua index b912c80..4c069f0 100644 --- a/lua/telescope/builtin/init.lua +++ b/lua/telescope/builtin/init.lua @@ -271,6 +271,7 @@ builtin.oldfiles = require_on_exported_call("telescope.builtin.__internal").oldf --- - Default keymaps: --- - ``: open the command line with the text of the currently selected result populated in it ---@param opts table: options to pass to the picker +---@field filter_fn function: filter fn(cmd:string). true if the history command should be presented. builtin.command_history = require_on_exported_call("telescope.builtin.__internal").command_history --- Lists searches that were executed recently, and reruns them on `` -- cgit v1.2.3