Dotfiles_nvim/lua/editor/search.lua
2024-09-08 01:50:39 +02:00

59 lines
1.6 KiB
Lua

local K = require('core.keymap')
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(
mapping,
method,
search_global
)
local function binding()
local path = search_global and '~'
or require('neo-tree.sources.manager').get_state(
'filesystem'
).path
method({ search_dirs = { path } })
end
vim.keymap.set(mapping.mode, mapping.shortcut, binding, { desc = mapping.description })
end
local telescope = require('telescope.builtin')
setTelescopeBinding(
K.SEARCH.FIND_FILE,
telescope.find_files,
false
)
setTelescopeBinding(
K.SEARCH.FUZZY_FIND,
telescope.live_grep,
false
)
setTelescopeBinding(
K.SEARCH.GLOBAL_FIND_FILE,
telescope.find_files,
true
)
setTelescopeBinding(
K.SEARCH.GLOBAL_FUZZY_FIND,
telescope.live_grep,
true
)
end,
}