From b89f380dd55066bd522eb8b31b8c15218902d386 Mon Sep 17 00:00:00 2001 From: duma799 Date: Thu, 12 Feb 2026 01:10:48 +0400 Subject: [PATCH] Move Telescope setup() to main spec, make search function local --- nvim/lua/plugins/telescope.lua | 73 ++++++++++++++++------------------ 1 file changed, 35 insertions(+), 38 deletions(-) diff --git a/nvim/lua/plugins/telescope.lua b/nvim/lua/plugins/telescope.lua index d64e673..c10da49 100755 --- a/nvim/lua/plugins/telescope.lua +++ b/nvim/lua/plugins/telescope.lua @@ -3,37 +3,6 @@ return { "nvim-telescope/telescope.nvim", tag = "0.1.8", dependencies = { "nvim-lua/plenary.nvim" }, - config = function() - local builtin = require("telescope.builtin") - vim.keymap.set("n", "", builtin.find_files, {}) - vim.keymap.set("n", "", builtin.live_grep, {}) - - -- Function for searching and scoping into a directory - function search_and_scope_into_directory() - builtin.find_files({ - prompt_title = "Search Directories", - find_command = {"fd", "--type", "d", "--hidden", "--follow"}, - attach_mappings = function(prompt_bufnr, map) - local actions = require("telescope.actions") - actions.select_default:replace(function() - local selection = require("telescope.actions.state").get_selected_entry() - local selected_dir = selection.path - - -- Change the current working directory to the selected directory - vim.cmd("cd " .. selected_dir) - actions.close(prompt_bufnr) - end) - return true - end, - }) - end - - -- Keybinding to trigger directory search and scoping - vim.keymap.set("n", "", search_and_scope_into_directory) - end - }, - { - "nvim-telescope/telescope-ui-select.nvim", config = function() require("telescope").setup({ extensions = { @@ -47,13 +16,13 @@ return { }, vimgrep_arguments = { "rg", - "--follow", - "--hidden", - "--no-heading", + "--follow", + "--hidden", + "--no-heading", "--with-filename", "--line-number", - "--column", - "--smart-case", + "--column", + "--smart-case", "--glob=!**/.git/*", "--glob=!**/.idea/*", "--glob=!**/.vscode/*", @@ -63,7 +32,6 @@ return { "--glob=!**/package-lock.json", }, }, - pickers = { find_files = { hidden = true, @@ -82,8 +50,37 @@ return { }, }, }) + + local builtin = require("telescope.builtin") + vim.keymap.set("n", "", builtin.find_files, {}) + vim.keymap.set("n", "", builtin.live_grep, {}) + + local function search_and_scope_into_directory() + builtin.find_files({ + prompt_title = "Search Directories", + find_command = {"fd", "--type", "d", "--hidden", "--follow"}, + attach_mappings = function(prompt_bufnr, map) + local actions = require("telescope.actions") + actions.select_default:replace(function() + local selection = require("telescope.actions.state").get_selected_entry() + local selected_dir = selection.path + vim.cmd("cd " .. selected_dir) + actions.close(prompt_bufnr) + end) + return true + end, + }) + end + + -- Expose globally for alpha.lua dashboard button + _G.search_and_scope_into_directory = search_and_scope_into_directory + vim.keymap.set("n", "", search_and_scope_into_directory) + end + }, + { + "nvim-telescope/telescope-ui-select.nvim", + config = function() require("telescope").load_extension("ui-select") end, }, } -