summaryrefslogtreecommitdiff
path: root/lua/telescope/init.lua
blob: ecec9311e9655ebe3b46d7b4ed428266965a01cc (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
local telescope = {}

--[[
local actions = require('telescope.actions')

require('telescope').setup {
  defaults = {
    -- Picker Configuration
    border = {},
    borderchars = { '─', '│', '─', '│', '┌', '┐', '┘', '└'},
    preview_cutoff = 120,
    selection_strategy = "reset",

    -- Can choose EITHER one of these:
    layout_strategy = "horizontal",

    get_window_options = function(...) end,

    default_mappings = {
      i = {
        ["<C-n>"] = actions.move_selection_next,
        ["<C-p>"] = actions.move_selection_previous,
      },

      n = {
        ["<esc>"] = actions.close,
        ["<CR>"] = actions.goto_file_selection_edit,
      },
    },

    shorten_path = true,

    winblend = 10, -- help winblend

    winblend = {
      preview = 0,
      prompt = 20,
      results = 20,
    },

  },
}

--]]

function telescope.setup(opts)
  if opts.default then
    error("'default' is not a valid value for setup. See 'defaults'")
  end

  require('telescope.config').set_defaults(opts.defaults)
end

-- Until I have better profiling stuff, this will have to do.
PERF = function(...) end
PERF_DEBUG = PERF_DEBUG or nil
START = nil

if PERF_DEBUG then
  PERF = function(...)
    local new_time = (vim.loop.hrtime() - START) / 1E9
    if select('#', ...) == 0 then
      vim.schedule(function()
        vim.api.nvim_buf_set_lines(PERF_DEBUG, -1, -1, false, { '' })
      end)
      return
    end

    local to_insert = ''
    if START then
      to_insert = tostring(new_time) .. ' | '
    end

    for _, v in ipairs({...}) do
      if type(v) == 'table' then
        to_insert = to_insert .. tostring(#v) .. ' | '
      else
        to_insert = to_insert .. tostring(v) .. ' | '
      end
    end

    vim.schedule(function()
      vim.api.nvim_buf_set_lines(PERF_DEBUG, -1, -1, false, { to_insert })
    end)
  end
end

return telescope