Open zaixi opened 1 year ago
local function getVisualSelection()
vim.cmd('noau normal! "vy"')
local text = vim.fn.getreg("v")
vim.fn.setreg("v", {})
text = string.gsub(text, "\n", "")
if #text > 0 then
return text
else
return ""
end
end
v = {
["<leader>ff"] = {
function()
require("telescope.builtin").find_files({
default_text = getVisualSelection(),
})
end,
"find files",
},
["<leader>ft"] = {
function()
require("telescope.builtin").live_grep({
default_text = getVisualSelection(),
only_sort_text = true,
additional_args = function()
return { "--pcre2" }
end,
})
end,
"Find Text",
},
},
use default_text
Description
Use to enter V-BLOCK mode, use grep_string to search after selecting text, the search result is not the selected text
Neovim version
Operating system and version
Ubuntu 20.04.2 LTS \n \l
Telescope version / branch / rev
master
checkhealth telescope
Steps to reproduce
Expected behavior
No response
Actual behavior
Minimal config