-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
telescope.lua
131 lines (122 loc) · 3.37 KB
/
telescope.lua
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
return {
'nvim-telescope/telescope.nvim',
cmd = 'Telescope',
dependencies = {
'nvim-lua/plenary.nvim',
'nvim-telescope/telescope-ui-select.nvim',
{
'danielfalk/smart-open.nvim',
dependencies = {
'kkharji/sqlite.lua',
{ 'nvim-telescope/telescope-fzy-native.nvim' },
},
opts = {
mappings = {
i = {
-- Delete word backward, might be able to remove once this is resolved:
-- https://github.com/danielfalk/smart-open.nvim/issues/71
['<C-w>'] = function()
vim.api.nvim_input '<c-s-w>'
end,
},
},
},
},
},
opts = function()
local actions = require 'telescope.actions'
local themes = require 'telescope.themes'
local custom_pickers = require 'j.telescope_custom_pickers'
return {
defaults = {
mappings = {
i = {
['<esc>'] = actions.close,
['<s-up>'] = actions.cycle_history_prev,
['<s-down>'] = actions.cycle_history_next,
['<c-w>'] = function()
vim.api.nvim_input '<c-s-w>'
end,
['<c-u>'] = function()
vim.api.nvim_input '<c-s-u>'
end,
['<c-a>'] = function()
vim.api.nvim_input '<home>'
end,
['<c-e>'] = function()
vim.api.nvim_input '<end>'
end,
['<c-f>'] = actions.preview_scrolling_down,
['<c-b>'] = actions.preview_scrolling_up,
['<c-p>'] = require('telescope.actions.layout').toggle_preview,
},
},
},
pickers = {
oldfiles = {
sort_lastused = true,
cwd_only = true,
path_display = { 'filename_first' },
},
find_files = {
hidden = true,
find_command = {
'rg',
'--files',
'--color',
'never',
'--ignore-file',
vim.env.XDG_CONFIG_HOME .. '/ripgrep/ignore',
},
},
live_grep = {
path_display = { 'shorten' },
mappings = {
i = {
['<c-f>'] = custom_pickers.actions.set_extension,
['<c-l>'] = custom_pickers.actions.set_folders,
},
},
},
},
extensions = {
['ui-select'] = {
themes.get_cursor {},
},
},
}
end,
config = function(_, opts)
require('telescope').setup(opts)
require('telescope').load_extension 'smart_open'
require('telescope').load_extension 'ui-select'
end,
keys = {
{
'<c-p>',
function()
local ignores = require('telescope._extensions.smart_open.default_config').ignore_patterns
require('telescope').extensions.smart_open.smart_open {
cwd_only = true,
ignore_patterns = vim.list_extend(ignores, { 'node_modules/*' }),
}
end,
},
{
'<leader>ff',
function()
require('j.telescope_custom_pickers').live_grep()
end,
},
{ '<leader>fh', '<cmd>Telescope help_tags<cr>' },
{
'<leader>fr',
function()
require('telescope.builtin').oldfiles()
end,
},
{ '<leader>fx', '<cmd>Telescope git_status<cr>' },
{ '<leader>fc', '<cmd>Telescope git_commits<cr>' },
{ '<leader>ca', vim.lsp.buf.code_action },
},
}