Add Telescope mappings to find the current word

This commit is contained in:
Oliver Davies 2024-01-07 22:21:02 +00:00
parent f465870c82
commit c700329642
2 changed files with 25 additions and 0 deletions

View file

@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), but adapt
Instead of grouping changes by tag, they are grouped by the date they are released.
## 7th January 2024
### Added
* Add Telescope keymaps to find the current word under the cursor within the open project.
## 4th January 2024
### Added

View file

@ -32,6 +32,25 @@ telescope_mapper("<leader>fh", "help_tags")
telescope_mapper("<leader>fl", "live_grep")
telescope_mapper("<leader>fo", "oldfiles")
local builtin = require "telescope.builtin"
local nmap = require("opdavies.keymap").nmap
nmap {
"<leader>fw",
function()
local word = vim.fn.expand "<cword>"
builtin.grep_string { search = word }
end,
}
nmap {
"<leader>fW",
function()
local word = vim.fn.expand "<cWORD>"
builtin.grep_string { search = word }
end,
}
telescope_mapper("<leader>gp", "grep_prompt")
telescope_mapper("<leader>ds", "lsp_document_symbols")