Skip to content

Commit

Permalink
marks picker: add support for cwd and cwd_only options
Browse files Browse the repository at this point in the history
  • Loading branch information
coockoo committed Oct 10, 2024
1 parent df534c3 commit 2acf6dc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lua/telescope/builtin/__internal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions lua/telescope/builtin/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<cr>`
Expand Down

0 comments on commit 2acf6dc

Please sign in to comment.