dotfiles/.config/nvim/lua/plugins/telescope.lua

89 lines
3.4 KiB
Lua
Raw Normal View History

2024-01-17 13:01:32 +01:00
return {
'nvim-telescope/telescope.nvim',
dependencies = {
'nvim-lua/plenary.nvim',
'nvim-telescope/telescope-fzy-native.nvim',
},
opts = {
defaults = {
file_ignore_patterns = {
".cache/.*",
"node_modules/.*",
".git/.*",
"Venv/.*",
"venv/.*",
"wandb/.*",
"Resources/.*",
"build/.*"
},
mappings = {
i = {
["jj"] = require("telescope.actions").close,
["<C-j>"] = require("telescope.actions").move_selection_next,
["<C-k>"] = require("telescope.actions").move_selection_previous,
},
},
file_sorter = require'telescope.sorters'.get_fzy_sorter,
generic_sorter = require'telescope.sorters'.get_fzy_sorter,
},
extensions = {
undo = {
side_by_side = false,
layout_strategy = "vertical",
use_delta = true,
layout_config = {
preview_height = 0.5,
},
mappings = {
i = {
["<cr>"] = require("telescope-undo.actions").restore,
["<S-y>"] = require("telescope-undo.actions").yank_additions,
},
},
}
},
fzy_native = {
override_generic_sorter = false,
override_file_sorter = true,
}
},
keys = {
{ "<leader>u", require("telescope").extensions.undo.undo},
{ "<C-Space>", require("telescope.builtin").oldfiles},
2024-01-24 21:45:15 +01:00
{ "<C-f>", function () require"telescope.builtin".live_grep({ path_display = { 'smart' }, }) end},
2024-01-17 13:01:32 +01:00
{ "<C-p>", function () -- git files
local opts = require('telescope.themes').get_ivy({})
opts["show_untracked"] = true
opts["layout_config"] = {height=0.2}
if not pcall(require"telescope.builtin".git_files, opts) then
require"telescope.builtin".find_files(opts)
end
end},
{ "<C-o>", function () -- project files
local opts = require('telescope.themes').get_ivy({})
opts["layout_config"] = {height=0.2}
require"telescope.builtin".find_files(opts)
end},
{ "<C-S-o>", function () -- buffer files
local opts = require('telescope.themes').get_ivy({})
opts["layout_config"] = {height=0.2}
require"telescope.builtin".buffers(opts)
end},
2024-01-24 21:45:15 +01:00
{ "<C-S-f>", function () -- fuzzy search
2024-01-17 13:01:32 +01:00
require"telescope.builtin".grep_string({
path_display = { 'smart' },
only_sort_text = true,
word_match = "-w",
search = '',
})
end},
},
config = function (_, opts)
local telescope = require("telescope")
telescope.setup(opts)
telescope.load_extension("undo")
telescope.load_extension('fzy_native')
end
}