From c700329642184315bbdc06726bd8ae958f7144d7 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Sun, 7 Jan 2024 22:21:02 +0000 Subject: [PATCH] Add Telescope mappings to find the current word --- CHANGELOG.md | 6 ++++++ .../lua/opdavies/telescope/mappings.lua | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 85320dc7..3cd5fe6f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/config/neovim/lua/opdavies/telescope/mappings.lua b/config/neovim/lua/opdavies/telescope/mappings.lua index 74e2d126..7daf8761 100644 --- a/config/neovim/lua/opdavies/telescope/mappings.lua +++ b/config/neovim/lua/opdavies/telescope/mappings.lua @@ -32,6 +32,25 @@ telescope_mapper("fh", "help_tags") telescope_mapper("fl", "live_grep") telescope_mapper("fo", "oldfiles") +local builtin = require "telescope.builtin" +local nmap = require("opdavies.keymap").nmap + +nmap { + "fw", + function() + local word = vim.fn.expand "" + builtin.grep_string { search = word } + end, +} + +nmap { + "fW", + function() + local word = vim.fn.expand "" + builtin.grep_string { search = word } + end, +} + telescope_mapper("gp", "grep_prompt") telescope_mapper("ds", "lsp_document_symbols")