summaryrefslogtreecommitdiff
path: root/.config/nvim/lua/plugins/telescope.lua
blob: 4d8e86c8fa8c11d0d4f2a03eafd1a5f36ca160b5 (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
return {
  'nvim-telescope/telescope.nvim',
  dependencies = {
    { 'nvim-lua/plenary.nvim' },
    { 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' },
    { 'nvim-telescope/telescope-smart-history.nvim' },
    { 'kkharji/sqlite.lua' },
  },
  config = function()
    local data = assert(vim.fn.stdpath 'data') --[[@as string]]

    require('telescope').setup {
      extensions = {
        fzf = {
          fuzzy = true,
          override_generic_sorter = true,
          override_file_sorter = true,
          case_mode = 'smart_case',
        },
        wrap_results = true,
        history = {
          path = vim.fs.joinpath(data, 'telescope_history.sqlite3'),
          limit = 100,
        },
      },
    }

    pcall(require('telescope').load_extension, 'fzf')
    pcall(require('telescope').load_extension, 'smart_history')

    local builtin = require 'telescope.builtin'

    vim.keymap.set('n', '<space>fd', builtin.find_files)
    vim.keymap.set('n', '<space>fh', builtin.help_tags)
    vim.keymap.set('n', '<space>fg', builtin.live_grep)
    vim.keymap.set('n', '<space>/', builtin.current_buffer_fuzzy_find)
    vim.keymap.set('n', '<space>gw', builtin.grep_string)

    vim.keymap.set('n', '<space>fa', function()
      ---@diagnostic disable-next-line: param-type-mismatch
      builtin.find_files { cwd = vim.fs.joinpath(vim.fn.stdpath 'data', 'lazy') }
    end)

    vim.keymap.set('n', '<space>en', function()
      builtin.find_files { cwd = vim.fn.stdpath 'config' }
    end)
  end,
}