search visual selection
This commit is contained in:
parent
6e103f4bff
commit
b286bcaa74
1 changed files with 20 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue