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
|
local actions = require("telescope.actions")
local finders = require("telescope.builtin")
require("telescope").setup({
defaults = {
prompt_prefix = "> ",
initial_mode = "insert",
sorting_strategy = "ascending",
layout_config = {
prompt_position = "top",
},
mappings = {
i = {
["<ESC>"] = actions.close,
["<C-j>"] = actions.move_selection_next,
["<C-k>"] = actions.move_selection_previous,
["<TAB>"] = actions.toggle_selection + actions.move_selection_next,
["<C-s>"] = actions.send_selected_to_qflist,
["<C-q>"] = actions.send_to_qflist,
},
},
},
extensions = {
fzf = {
fuzzy = true,
override_generic_sorter = true,
override_file_sorter = true,
case_mode = "smart_case",
},
},
})
local Telescope = setmetatable({}, {
__index = function(_, k)
if vim.bo.filetype == "NvimTree" then
vim.cmd.wincmd("l")
end
return finders[k]
end,
})
vim.keymap.set("n", "<C-space>", function()
local ok = pcall(Telescope.git_files, { show_untracked = true })
if not ok then
Telescope.find_files()
end
end)
-- Get :help at the speed of light
vim.keymap.set("n", "<leader>H", Telescope.help_tags)
-- Search for string
vim.keymap.set("n", "<leaders>s", Telescope.live_grep)
-- Fuzzy find changed files in git
vim.keymap.set("n", "<leader>c", Telescope.git_status)
|