80 lines
2.8 KiB
Lua
80 lines
2.8 KiB
Lua
return {
|
|
'FabianWirth/search.nvim',
|
|
dependencies = {
|
|
'nvim-lua/plenary.nvim',
|
|
{
|
|
'nvim-telescope/telescope.nvim',
|
|
dependencies = {
|
|
{ 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' }
|
|
}
|
|
},
|
|
},
|
|
|
|
config = function()
|
|
local telescope = require('telescope')
|
|
local telescopeConfig = require('telescope.config')
|
|
|
|
local vimgrep_arguments = { unpack(telescopeConfig.values.vimgrep_arguments) }
|
|
table.insert(vimgrep_arguments, '--hidden')
|
|
table.insert(vimgrep_arguments, '--glob')
|
|
table.insert(vimgrep_arguments, '!**/.git/*')
|
|
|
|
telescope.setup({
|
|
defaults = {
|
|
vimgrep_arguments = vimgrep_arguments,
|
|
file_ignore_patterns = {
|
|
'node_modules',
|
|
'.git/'
|
|
}
|
|
},
|
|
extensions = {
|
|
fzf = {}
|
|
}
|
|
})
|
|
|
|
telescope.load_extension('fzf')
|
|
|
|
local search = require('search')
|
|
local builtin = require('telescope.builtin')
|
|
|
|
search.setup({
|
|
mappings = { -- optional: configure the mappings for switching tabs (will be set in normal and insert mode(!))
|
|
next = '<Tab>',
|
|
prev = '<S-Tab>'
|
|
},
|
|
tabs = {
|
|
{ name = 'Files', tele_func = builtin.find_files, tele_opts = { no_ignore = true, hidden = true } },
|
|
{ name = 'Grep', tele_func = builtin.live_grep },
|
|
{ name = 'Buffers', tele_func = builtin.buffers },
|
|
},
|
|
append_tabs = { -- append_tabs will add the provided tabs to the default ones
|
|
{
|
|
'Commits', -- or name = 'Commits'
|
|
builtin.git_commits, -- or tele_func = require('telescope.builtin').git_commits
|
|
available = function() -- optional
|
|
return vim.fn.isdirectory('.git') == 1
|
|
end
|
|
},
|
|
},
|
|
})
|
|
|
|
vim.keymap.set('n', '<leader>pf', search.open, {})
|
|
vim.keymap.set('n', '<leader>pb', function()
|
|
search.open({ tab_name = 'Buffers' })
|
|
end)
|
|
vim.keymap.set('n', '<leader>pws', function()
|
|
local word = vim.fn.expand('<cword>')
|
|
builtin.grep_string({ search = word })
|
|
end)
|
|
vim.keymap.set('n', '<leader>pWs', function()
|
|
local word = vim.fn.expand('<cWORD>')
|
|
builtin.grep_string({ search = word })
|
|
end)
|
|
vim.keymap.set('n', '<leader>ps', function()
|
|
builtin.grep_string({ search = vim.fn.input('Grep > ') })
|
|
end)
|
|
vim.keymap.set('n', '<leader>vh', builtin.help_tags, {})
|
|
end
|
|
}
|
|
|