From 2acf6dc036d44fc2b73794dc0d62b9218bc4af2a Mon Sep 17 00:00:00 2001 From: Oleksandr Bondarchuk Date: Thu, 10 Oct 2024 12:48:57 +0300 Subject: [PATCH] marks picker: add support for cwd and cwd_only options --- lua/telescope/builtin/__internal.lua | 7 +++++++ lua/telescope/builtin/init.lua | 2 ++ 2 files changed, 9 insertions(+) diff --git a/lua/telescope/builtin/__internal.lua b/lua/telescope/builtin/__internal.lua index 1687401eb0..aa38cd3c1d 100644 --- a/lua/telescope/builtin/__internal.lua +++ b/lua/telescope/builtin/__internal.lua @@ -1187,6 +1187,13 @@ internal.marks = function(opts) end marks_table = vim.fn.extend(marks_table, marks_others) + if opts.cwd_only or opts.cwd then + local cwd = opts.cwd_only and vim.loop.cwd() or opts.cwd + marks_table = vim.tbl_filter(function(row) + return buf_in_cwd(row.filename, cwd) + end, marks_table) + end + pickers .new(opts, { prompt_title = "Marks", diff --git a/lua/telescope/builtin/init.lua b/lua/telescope/builtin/init.lua index 6e27c27ab3..455b6fb8f0 100644 --- a/lua/telescope/builtin/init.lua +++ b/lua/telescope/builtin/init.lua @@ -368,6 +368,8 @@ builtin.colorscheme = require_on_exported_call("telescope.builtin.__internal").c ---@param opts table: options to pass to the picker ---@field file_encoding string: file encoding for the previewer ---@field mark_type string: filter marks by type (default: "all", options: "all"|"global"|"local") +---@field cwd string: specify a working directory to filter marks list by +---@field cwd_only boolean: if true, only show marks in the current working directory (default: false) builtin.marks = require_on_exported_call("telescope.builtin.__internal").marks --- Lists vim registers, pastes the contents of the register on ``