aboutsummaryrefslogtreecommitdiffstats
path: root/lua/alpha/telescope/init.lua
blob: 7b0ffd224b544dfbe63e53bc30d472a79fc265d6 (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
local actions = require('telescope.actions')

local M = {}

function M.project_files()
  local opts = {} -- define here if you want to define something
  local ok = pcall(require'telescope.builtin'.git_files, opts)
  if not ok then require'telescope.builtin'.find_files(opts) end
end

function M.branches()
    require'telescope.builtin'.git_branches({ attach_mappings = function(_, map)
      map('i', '<c-j>', actions.git_create_branch)
      map('n', '<c-j>', actions.git_create_branch)
      return true
    end})
end

function M.search_config()
    require("telescope.builtin").git_files({
        prompt_title = "< dotfiles >",
        cwd = "$HOME/.dotfiles",
    })
end

function M.grep_string()
    vim.ui.input("Grep for > ", function (input)
        if input == nil then
            return
        end
        require('telescope.builtin').grep_string({ search = input})
    end)
end

function M.grep_word()
    require('telescope.builtin').grep_string({ search = vim.fn.expand("<cword>")})
end

function M.find_symbol ()
    vim.ui.input("Symbol for > ", function (input)
        if input == nil then
            return
        end
        require('telescope.builtin').lsp_workspace_symbols({ search = input})
    end)
end

function M.my_plugins()
    require("telescope.builtin").find_files {
        cwd = "~/plugins/",
    }
end

return setmetatable({}, {
  __index = function(_, k)

    if M[k] then
      return M[k]
    else
      return require("telescope.builtin")[k]
    end
  end,
})