mirror of
https://github.com/duma799/hyprduma-config.git
synced 2026-05-14 06:31:00 +00:00
Move Telescope setup() to main spec, make search function local
This commit is contained in:
@@ -3,37 +3,6 @@ return {
|
|||||||
"nvim-telescope/telescope.nvim",
|
"nvim-telescope/telescope.nvim",
|
||||||
tag = "0.1.8",
|
tag = "0.1.8",
|
||||||
dependencies = { "nvim-lua/plenary.nvim" },
|
dependencies = { "nvim-lua/plenary.nvim" },
|
||||||
config = function()
|
|
||||||
local builtin = require("telescope.builtin")
|
|
||||||
vim.keymap.set("n", "<C-p>", builtin.find_files, {})
|
|
||||||
vim.keymap.set("n", "<A-f>", 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", "<A-d>", search_and_scope_into_directory)
|
|
||||||
end
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"nvim-telescope/telescope-ui-select.nvim",
|
|
||||||
config = function()
|
config = function()
|
||||||
require("telescope").setup({
|
require("telescope").setup({
|
||||||
extensions = {
|
extensions = {
|
||||||
@@ -63,7 +32,6 @@ return {
|
|||||||
"--glob=!**/package-lock.json",
|
"--glob=!**/package-lock.json",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
pickers = {
|
pickers = {
|
||||||
find_files = {
|
find_files = {
|
||||||
hidden = true,
|
hidden = true,
|
||||||
@@ -82,8 +50,37 @@ return {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
local builtin = require("telescope.builtin")
|
||||||
|
vim.keymap.set("n", "<C-p>", builtin.find_files, {})
|
||||||
|
vim.keymap.set("n", "<A-f>", 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", "<A-d>", search_and_scope_into_directory)
|
||||||
|
end
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"nvim-telescope/telescope-ui-select.nvim",
|
||||||
|
config = function()
|
||||||
require("telescope").load_extension("ui-select")
|
require("telescope").load_extension("ui-select")
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user