76 lines
2.6 KiB
Lua
76 lines
2.6 KiB
Lua
local M = {}
|
|
|
|
local hastelescope, telescope= pcall(require, "telescope")
|
|
|
|
if not hastelescope then
|
|
return M
|
|
end
|
|
|
|
M.project_files = function()
|
|
local opts = require('telescope.themes').get_ivy({}) -- define here if you want to define something
|
|
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
|
|
|
|
M.buffers = function()
|
|
local opts = require('telescope.themes').get_ivy({}) -- define here if you want to define something
|
|
opts["layout_config"] = {height=0.2}
|
|
require"telescope.builtin".buffers(opts)
|
|
end
|
|
|
|
local actions = require("telescope.actions")
|
|
require("telescope").setup{
|
|
defaults = {
|
|
file_ignore_patterns = {
|
|
".cache/.*",
|
|
"node_modules/.*",
|
|
".git/.*",
|
|
"Venv/.*",
|
|
"venv/.*",
|
|
"wandb/.*",
|
|
"Resources/.*"
|
|
},
|
|
mappings = {
|
|
i = {
|
|
["jj"] = actions.close,
|
|
["<C-j>"] = actions.move_selection_next,
|
|
["<C-k>"] = actions.move_selection_previous,
|
|
},
|
|
},
|
|
},
|
|
extensions = {
|
|
undo = {
|
|
side_by_side = true,
|
|
layout_strategy = "vertical",
|
|
layout_config = {
|
|
preview_height = 0.5,
|
|
},
|
|
mappings = {
|
|
i = {
|
|
-- IMPORTANT: Note that telescope-undo must be available when telescope is configured if
|
|
-- you want to replicate these defaults and use the following actions. This means
|
|
-- installing as a dependency of telescope in it's `requirements` and loading this
|
|
-- extension from there instead of having the separate plugin definition as outlined
|
|
-- above.
|
|
["<cr>"] = require("telescope-undo.actions").restore,
|
|
["<S-y>"] = require("telescope-undo.actions").yank_additions,
|
|
},
|
|
},
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
telescope.load_extension("undo")
|
|
telescope.load_extension('fzf')
|
|
|
|
|
|
vim.api.nvim_set_keymap("n", "<C-p>", "<CMD>lua require'telescope_config'.project_files()<CR>", {noremap = true, silent = true})
|
|
vim.api.nvim_set_keymap("n", "<C-O>", "<cmd>lua require('telescope_config').buffers()<cr>", { silent = true, noremap = true })
|
|
vim.api.nvim_set_keymap("n", "<C-f>", "<cmd>lua require('telescope.builtin').live_grep{ cwd = vim.fn.systemlist(\"git rev-parse --show-toplevel 2> /dev/null || pwd\")[1] }<cr>", { silent = true, noremap = true })
|
|
|
|
return M
|