0

When using the live_grep picker in telescope, I would like to be able to map a key to open the current search terms in CtrlSF so I can do a mass search and replace.

How can I pass the search terms to another function?

romainl
  • 186,200
  • 21
  • 280
  • 313
synic
  • 26,359
  • 20
  • 111
  • 149
  • I do not think it is possible, unless there is some variable for last search in telescope. – jdhao Oct 25 '22 at 02:43

1 Answers1

1

Not sure if this apply to your problem but I've got the prompt value using this snippet (taken from https://github.com/nvim-telescope/telescope.nvim/issues/2016#issue-1276097274):

        local current_picker = require('telescope.actions.state').get_current_picker(prompt_bufnr)
        local prompt = current_picker:_get_prompt()
        print(prompt)

Context

In case it helps here's my whole function

    local vim_edit_prompt = function(prompt_bufnr)
        local current_picker = require('telescope.actions.state').get_current_picker(prompt_bufnr)
        local prompt = current_picker:_get_prompt()
        local cwd = current_picker.cwd
        actions.close(prompt_bufnr)
        vim.api.nvim_exec(':edit ' .. cwd .. '/' .. prompt, false)
        return true
    end

mmngreco
  • 516
  • 5
  • 14