Dotfiles_nvim/lua/editor/search.lua

53 lines
1.5 KiB
Lua
Raw Normal View History

2024-09-08 01:50:39 +02:00
local K = require('core.keymap')
2024-07-02 23:52:43 +02: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 --
2025-01-13 15:30:01 +01:00
local function setTelescopeBinding(mapping, method, search_global)
2024-07-02 23:52:43 +02:00
local function binding()
local path = search_global and '~'
or require('neo-tree.sources.manager').get_state(
'filesystem'
).path
method({ search_dirs = { path } })
end
2025-01-13 15:30:01 +01:00
vim.keymap.set(
mapping.mode,
mapping.shortcut,
binding,
{ desc = mapping.description }
)
2024-07-02 23:52:43 +02:00
end
local telescope = require('telescope.builtin')
2025-01-13 15:30:01 +01:00
setTelescopeBinding(K.SEARCH.FIND_FILE, telescope.find_files, false)
setTelescopeBinding(K.SEARCH.FUZZY_FIND, telescope.live_grep, false)
2024-07-02 23:52:43 +02:00
setTelescopeBinding(
2024-09-08 01:50:39 +02:00
K.SEARCH.GLOBAL_FIND_FILE,
2024-07-02 23:52:43 +02:00
telescope.find_files,
2024-09-08 01:50:39 +02:00
true
2024-07-02 23:52:43 +02:00
)
setTelescopeBinding(
2024-09-08 01:50:39 +02:00
K.SEARCH.GLOBAL_FUZZY_FIND,
2024-07-02 23:52:43 +02:00
telescope.live_grep,
2024-09-08 01:50:39 +02:00
true
2024-07-02 23:52:43 +02:00
)
end,
}