1
0
Fork 1
Dotfiles_nvim/lua/editor/search.lua

60 lines
1.6 KiB
Lua
Raw Permalink Normal View History

2024-09-07 23:50:39 +00:00
local K = require('core.keymap')
2024-07-02 21:52:43 +00:00
return {
'nvim-telescope/telescope.nvim',
tag = '0.1.5',
dependencies = {
'nvim-lua/plenary.nvim',
'nvim-telescope/telescope-ui-select.nvim',
},
config = function()
-- Setup --
require('telescope').setup({
extensions = {
['ui-select'] = {
require('telescope.themes').get_dropdown({}),
},
},
})
require('telescope').load_extension('ui-select')
-- Keybinding --
local function setTelescopeBinding(
2024-09-07 23:50:39 +00:00
mapping,
2024-07-02 21:52:43 +00:00
method,
2024-09-07 23:50:39 +00:00
search_global
2024-07-02 21:52:43 +00:00
)
local function binding()
local path = search_global and '~'
or require('neo-tree.sources.manager').get_state(
'filesystem'
).path
method({ search_dirs = { path } })
end
2024-09-07 23:50:39 +00:00
vim.keymap.set(mapping.mode, mapping.shortcut, binding, { desc = mapping.description })
2024-07-02 21:52:43 +00:00
end
local telescope = require('telescope.builtin')
setTelescopeBinding(
2024-09-07 23:50:39 +00:00
K.SEARCH.FIND_FILE,
2024-07-02 21:52:43 +00:00
telescope.find_files,
2024-09-07 23:50:39 +00:00
false
2024-07-02 21:52:43 +00:00
)
setTelescopeBinding(
2024-09-07 23:50:39 +00:00
K.SEARCH.FUZZY_FIND,
2024-07-02 21:52:43 +00:00
telescope.live_grep,
2024-09-07 23:50:39 +00:00
false
2024-07-02 21:52:43 +00:00
)
setTelescopeBinding(
2024-09-07 23:50:39 +00:00
K.SEARCH.GLOBAL_FIND_FILE,
2024-07-02 21:52:43 +00:00
telescope.find_files,
2024-09-07 23:50:39 +00:00
true
2024-07-02 21:52:43 +00:00
)
setTelescopeBinding(
2024-09-07 23:50:39 +00:00
K.SEARCH.GLOBAL_FUZZY_FIND,
2024-07-02 21:52:43 +00:00
telescope.live_grep,
2024-09-07 23:50:39 +00:00
true
2024-07-02 21:52:43 +00:00
)
end,
}