Files
dotfiles/nvim/lua/plugins/telescope.lua
T
2026-09-25 20:54:28 +08:00

53 lines
1.9 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- =============================================================================
-- telescope.lua — 模糊搜索
-- =============================================================================
return {
{
"nvim-telescope/telescope.nvim",
branch = "master", -- 0.1.x 没适配新 treesitter main 分支 API(ft_to_lang 已移除)
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-telescope/telescope-ui-select.nvim",
{
"nvim-telescope/telescope-fzf-native.nvim",
build = "make",
cond = function() return vim.fn.executable("make") == 1 end,
},
},
cmd = "Telescope",
keys = {
{ "<leader>ff", "<cmd>Telescope find_files<cr>", desc = "查找文件" },
{ "<leader>fg", "<cmd>Telescope live_grep<cr>", desc = "全局搜索" },
{ "<leader>fb", "<cmd>Telescope buffers<cr>", desc = "切换缓冲区" },
{ "<leader>fh", "<cmd>Telescope help_tags<cr>", desc = "帮助文档" },
{ "<leader>fk", "<cmd>Telescope keymaps<cr>", desc = "查找键位" },
{ "<leader>fr", "<cmd>Telescope oldfiles<cr>", desc = "最近文件" },
{ "<leader>fc", "<cmd>Telescope current_buffer_fuzzy_find<cr>", desc = "当前文件搜索" },
{ "<leader>fd", "<cmd>Telescope diagnostics<cr>", desc = "诊断信息" },
},
opts = {
defaults = {
prompt_prefix = " > ",
selection_caret = " > ",
layout_strategy = "flex",
file_ignore_patterns = {
"node_modules", ".git/", "dist/", "build/", "%.lock",
},
},
},
config = function(_, opts)
local telescope = require("telescope")
opts.extensions = {
["ui-select"] = {
require("telescope.themes").get_dropdown({}),
},
}
telescope.setup(opts)
pcall(telescope.load_extension, "ui-select")
pcall(telescope.load_extension, "fzf")
end,
},
}