aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/home/.config/nvim/lua/custom/plugins/telescope.lua
blob: d2e97d75945daee4cd4baf654df95204336ece9d (plain) (blame)
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
local map = require("mapper")

return {
  {
    "nvim-telescope/telescope.nvim",
    config = function()
      local actions = require("telescope.actions")
      require("telescope").setup({
        defaults = {
          sorting_strategy = "ascending",
          layout_config = {
            prompt_position = "top",
          },
          scroll_strategy = "cycle",
          selection_strategy = "follow",
          color_devicons = false,
          mappings = {
            i = {
              ["<c-j>"] = actions.move_selection_next,
              ["<c-k>"] = actions.move_selection_previous,
            },
          },
          extensions = {
            fzf = {
              fuzzy = true,                   -- false will only do exact matching
              override_generic_sorter = true, -- override the generic sorter
              override_file_sorter = true,    -- override the file sorter
              case_mode = "smart_case",       -- or "ignore_case" or "respect_case"
            },
            ["ui-select"] = {
              require("telescope.themes").get_dropdown({
                -- even more opts
              }),
            },
          },
        },
      })
      require("telescope").load_extension("fzf")
      require("telescope").load_extension("ui-select")

      local b = require("telescope.builtin")

      map.n("<localleader>B", b.builtin)
      map.n("<localleader>/", b.live_grep)
      map.n("<localleader>?", b.grep_string)
      map.n("<localleader>f", function()
        b.find_files({
          find_command = {
            "fd",
            "--type",
            "file",
            "--follow",
            "--hidden",
            "--exclude",
            ".git",
          },
        })
      end)
      map.n("<localleader>b", function()
        b.buffers({ sort_lastused = true, initial_mode = "normal" })
      end)

      map.n("<localleader>t", b.treesitter)

      map.n("<localleader>c", b.commands)
      map.n("<localleader>h", b.help_tags)
      map.n("<localleader>m", b.man_pages)
      map.n("<localleader>k", b.keymaps)
      map.n("<localleader>Q", function()
        b.quickfix({ initial_mode = "normal" })
      end)
      map.n("<localleader>L", function()
        b.loclist({ initial_mode = "normal" })
      end)
      map.n("<localleader>R", function()
        b.registers({ initial_mode = "normal" })
      end)
      map.n("<localleader>A", b.autocommands)


      vim.api.nvim_create_autocmd("LspAttach", {
        callback = function(event)
          local bnmap = function(keys, func)
            map.n(keys, func, { buffer = event.buf })
          end
          bnmap("gd", function()
            b.lsp_definitions({ initial_mode = "normal" })
          end)
          bnmap("gvd", function()
            b.lsp_definitions({ initial_mode = "normal", jump_type = "vsplit" })
          end)
          bnmap("gxd", function()
            b.lsp_definitions({ initial_mode = "normal", jump_type = "split" })
          end)
          bnmap("gtd", function()
            b.lsp_definitions({ initial_mode = "normal", jump_type = "tab" })
          end)
          bnmap("gi", function()
            b.lsp_implementations({ initial_mode = "normal" })
          end)
          bnmap("gvi", function()
            b.lsp_implementations({ initial_mode = "normal", jump_type = "vsplit" })
          end)
          bnmap("gxi", function()
            b.lsp_implementations({ initial_mode = "normal", jump_type = "split" })
          end)
          bnmap("gti", function()
            b.lsp_implementations({ initial_mode = "normal", jump_type = "tab" })
          end)
          bnmap("go", b.lsp_document_symbols)
          bnmap("gS", b.lsp_dynamic_workspace_symbols)
          bnmap("ge", function()
            b.lsp_document_diagnostics({ initial_mode = "normal" })
          end)
          bnmap("gE", function()
            b.lsp_workspace_diagnostics({ initial_mode = "normal" })
          end)
          bnmap("gr", function()
            b.lsp_references({ initial_mode = "normal" })
          end)
          bnmap("gic", function()
            b.lsp_incoming_calls({ initial_mode = "normal" })
          end)
          bnmap("goc", function()
            b.lsp_outgoing_calls({ initial_mode = "normal" })
          end)
        end,
      })
    end,
    dependencies = {
      "nvim-lua/plenary.nvim",
      {
        "nvim-telescope/telescope-fzf-native.nvim",
        build = "make",
      },
      "nvim-telescope/telescope-ui-select.nvim",
    },
  },
}