1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
local misc = require("core.misc")
local map = misc.map
return { "nvim-telescope/telescope.nvim",
disable = not vim.fn.has("nvim-0.9.0"),
requires = {
"nvim-lua/plenary.nvim",
{ "nvim-telescope/telescope-fzf-native.nvim",
config = function()
vim.cmd("make")
end
},
"mollerhoj/telescope-recent-files.nvim",
"nvim-telescope/telescope-ui-select.nvim"
},
function()
local telescope = require("telescope")
local actions = require("telescope.actions")
telescope.setup {
defaults = {
borderchars = {
prompt = { " ", " ", " ", " ", " ", " ", " ", " " },
results = { " ", " ", " ", " ", " ", " ", " ", " " },
preview = { " ", " ", " ", " ", " ", " ", " ", " " },
},
winblend = 0,
layout_strategy = "horizontal",
sorting_strategy = "descending",
scroll_strategy = "limit",
layout_config = {
horizontal = {
height = 20,
prompt_position = "bottom",
anchor = "N",
}
},
mappings = {
i = {
["<esc>"] = actions.close,
["<C-j>"] = actions.move_selection_next,
["<C-k>"] = actions.move_selection_previous,
["<C-u>"] = actions.preview_scrolling_up,
["<C-d>"] = actions.preview_scrolling_down,
}
}
},
extensions = {
fzf = {}
}
}
-- load in the fzf extension
telescope.load_extension("fzf")
telescope.load_extension("recent-files")
telescope.load_extension("ui-select")
-- keymaps
local telebuilt = require("telescope.builtin")
map("n", "<leader>f", function()
telescope.extensions["recent-files"].recent_files { follow = true }
end, { desc = "Find files." })
map("n", "<leader>s", telebuilt.live_grep, { desc = "Find string in project." })
map("n", "<leader>b", telebuilt.current_buffer_fuzzy_find, {
desc = "Find string in current buffer.",
})
map("n", "<leader>i", telebuilt.help_tags, {
desc = "find help tags.",
})
-- find over specific directories
map("n", "<leader>tc", function()
require("telescope.builtin").find_files {
cwd = vim.fn.stdpath("config")
}
end, { desc = "find config files" })
map("n", "<leader>tp", function()
require("telescope.builtin").find_files {
cwd = vim.fs.joinpath(vim.fn.stdpath("data"), "site/pack/deps/opt")
}
end, { desc = "find files in plugin directory" })
-- enable previewing in the default colorscheme switcher
telebuilt.colorscheme = function()
require("telescope.builtin.__internal").colorscheme { enable_preview = true }
end
end
}
|