summaryrefslogtreecommitdiffstats
path: root/.config/nvim/lua/plugins/telescope.lua
blob: 40c99a434ad58a003ce6b355e0752a95b7c1dde7 (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
54
55
56
57
58
59
60
61
62
63
64
65
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",
        },
        config = function()
            require('telescope').setup({
                defaults = {
                    path_display = { "truncate" },
                    prompt_prefix = " ",
                },
                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")
            map("n", "<leader>st", function()
                require("telescope.builtin").spell_suggest(require("telescope.themes").get_cursor({
                    prompt_title = "",
                    layout_config = {
                        height = 0.25,
                        width = 0.25,
                    },
                    winblend = 10,
                    previewer = false,
                }))
            end
            , "🔭: spelling suggest")
            require("telescope").load_extension("yank_history")
            map("n", "<leader>sp", require("telescope").extensions.yank_history.yank_history, "🔭: yank history")
        end,
    },
}