summaryrefslogtreecommitdiffstats
path: root/.config/nvim/lua/plugins/telescope.lua
blob: be6fdd7095c15710dac38ae2598e5ecd988aae58 (plain)
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
return {
    {
        "nvim-telescope/telescope.nvim",
        priority = 500,
        dependencies = {
            "nvim-lua/plenary.nvim",
            {
                "nvim-telescope/telescope-fzf-native.nvim",
                build = "make",
                cond = vim.fn.executable("make") == 1
            },
            "gbprod/yanky.nvim",
        },
        lazy = false,
        config = function()
            require('telescope').setup({
                defaults = {
                    path_display = { "truncate" },
                },
                extensions = {
                    fzf = {
                        fuzzy = true, -- false will only do exact matching
                        override_generic_sorter = true,
                        override_file_sorter = true,
                        case_mode = "smart_case",
                    },
                },
            })
            -- Enable telescope fzf native, if installed
            pcall(require("telescope").load_extension, "fzf")

            local map = require("helpers.keys").map

            map("n", "<leader>fr", require("telescope.builtin").oldfiles, "🔭: recently opened")
            map("n", "<leader><space>", require("telescope.builtin").buffers, "🔭: open buffers")
            map("n", "<leader>/", function()
                -- you can pass additional configuration to telescope to change theme, layout, etc.
                require("telescope.builtin").current_buffer_fuzzy_find(require("telescope.themes").get_dropdown({
                    winblend = 10,
                    previewer = false,
                }))
            end, "🔭: search in current buffer")

            map("n", "<leader>sf", require("telescope.builtin").find_files, "🔭: find files")
            map("n", "<leader>sh", require("telescope.builtin").help_tags, "🔭: help")
            map("n", "<leader>sw", require("telescope.builtin").grep_string, "🔭: current word")
            map("n", "<leader>sg", require("telescope.builtin").live_grep, "🔭: live grep")
            map("n", "<leader>sd", require("telescope.builtin").diagnostics, "🔭: diagnostics")
            require("telescope").load_extension("yank_history")
            map("n", "<leader>sp", require("telescope").extensions.yank_history.yank_history, "🔭: yank history")
        end,
    },
}