search visual selection

lazyvim
Andy Teijelo 2023-06-09 08:10:32 -04:00
parent 6e103f4bff
commit b286bcaa74
1 changed files with 20 additions and 0 deletions

View File

@ -163,6 +163,26 @@ keymap("i", "<Down>", "<Nop>", opts)
-- end
--
-- keymap("n", "<leader>n", clean_screen, opts)
function vim.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
keymap('v', '<space>sw', function()
local tb = require('telescope.builtin')
local text = vim.getVisualSelection()
tb.live_grep({ default_text = text })
end, opts)
--
-- local function otherkeymaps()
-- local ok