search visual selection

This commit is contained in:
Andy Teijelo 2023-06-09 08:10:32 -04:00
parent 6e103f4bff
commit b286bcaa74

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