diff options
| author | Aotrix <[email protected]> | 2026-04-22 14:18:39 +0200 |
|---|---|---|
| committer | Aotrix <[email protected]> | 2026-04-22 14:18:39 +0200 |
| commit | 064afe86639a64e7b64158911c195688906c0708 (patch) | |
| tree | aeda611f9ee83b80b7c6b00b3da583698f382bf6 /lua | |
| parent | 90bd313a5e4087dc97f9a29f17d5a9d54440412b (diff) | |
Change Telescope grep behaviour
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/aotrix/multigrep.lua | 53 | ||||
| -rw-r--r-- | lua/aotrix/plugins/telescope.lua | 4 | ||||
| -rw-r--r-- | lua/aotrix/remap.lua | 1 |
3 files changed, 3 insertions, 55 deletions
diff --git a/lua/aotrix/multigrep.lua b/lua/aotrix/multigrep.lua deleted file mode 100644 index 749102e..0000000 --- a/lua/aotrix/multigrep.lua +++ /dev/null @@ -1,53 +0,0 @@ -local pickers = require "telescope.pickers" -local finders = require "telescope.finders" -local make_entry = require "telescope.make_entry" -local conf = require "telescope.config".values - -local M = {} - -local live_multigrep = function(opts) - opts = opts or {} - opts.cwd = opts.cwd or vim.uv.cwd() - - local finder = finders.new_async_job { - command_generator = function(prompt) - if not prompt or prompt == "" then - return nil - end - - local pieces = vim.split(prompt, " ") - local args = { "rg" } - if pieces[1] then - table.insert(args, "-e") - table.insert(args, pieces[1]) - end - - if pieces[2] then - table.insert(args, "-g") - table.insert(args, pieces[2]) - end - - ---@diagnostic disable-next-line: deprecated - return vim.tbl_flatten { - args, - { "--color=never", "--no-heading", "--with-filename", "--line-number", "--column", "--smart-case" }, - } - end, - entry_maker = make_entry.gen_from_vimgrep(opts), - cwd = opts.cwd, - } - - pickers.new(opts, { - debounce = 100, - prompt_title = "Multi Grep", - finder = finder, - previewer = conf.grep_previewer(opts), - sorter = require("telescope.sorters").empty(), - }):find() -end - -M.setup = function() - vim.keymap.set("n", "<leader>pg", live_multigrep) -end - -return M diff --git a/lua/aotrix/plugins/telescope.lua b/lua/aotrix/plugins/telescope.lua index 4435b07..efd320b 100644 --- a/lua/aotrix/plugins/telescope.lua +++ b/lua/aotrix/plugins/telescope.lua @@ -51,8 +51,8 @@ return { function() require("telescope.builtin").find_files() end) - - require('aotrix.multigrep').setup() + vim.keymap.set("n", "<leader>pg", require("telescope").extensions + .live_grep_args.live_grep_args, {noremap = true}) vim.keymap.del("n", "gri") vim.keymap.del("n", "grr") diff --git a/lua/aotrix/remap.lua b/lua/aotrix/remap.lua index 579395d..9d3fee4 100644 --- a/lua/aotrix/remap.lua +++ b/lua/aotrix/remap.lua @@ -16,3 +16,4 @@ vim.keymap.set("n", "<leader>Y", [["+Y]]) -- Remove <C-c> because it is not fast enough vim.keymap.set({"n", "i", "v"}, '<C-c>', '<nop>') +vim.keymap.del("n", "grx") |
