dotfiles/nvim/lua/telescope_config.lua

53 lines
1.7 KiB
Lua
Raw Normal View History

2022-07-03 14:30:11 +02:00
local M = {}
local hastelescope, telescope= pcall(require, "telescope")
if not hastelescope then
return M
end
2022-07-03 14:30:11 +02:00
M.project_files = function()
2022-07-03 18:00:31 +02:00
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}
2022-11-19 15:08:26 +01:00
if not pcall(require"telescope.builtin".git_files, opts) then
require"telescope.builtin".find_files(opts)
end
2022-07-03 14:30:11 +02:00
end
2022-07-05 11:35:42 +02:00
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
2022-07-03 18:00:31 +02:00
local actions = require("telescope.actions")
require("telescope").setup{
defaults = {
2022-07-05 11:35:42 +02:00
file_ignore_patterns = {
2022-08-29 16:52:25 +02:00
".cache/.*",
2022-07-05 11:35:42 +02:00
"node_modules/.*",
".git/.*",
"Venv/.*",
"venv/.*",
"wandb/.*",
"Resources/.*"
},
2022-07-03 18:00:31 +02:00
mappings = {
i = {
2022-07-05 11:35:42 +02:00
["jj"] = actions.close,
["<C-j>"] = actions.move_selection_next,
["<C-k>"] = actions.move_selection_previous,
2022-07-03 18:00:31 +02:00
},
},
}
}
2022-07-03 14:30:11 +02:00
telescope.load_extension('fzf')
2022-07-04 14:04:29 +02:00
vim.api.nvim_set_keymap("n", "<C-p>", "<CMD>lua require'telescope_config'.project_files()<CR>", {noremap = true, silent = true})
2022-07-05 11:35:42 +02:00
vim.api.nvim_set_keymap("n", "<C-O>", "<cmd>lua require('telescope_config').buffers()<cr>", { silent = true, noremap = true })
2022-07-04 11:24:36 +02:00
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 })
2022-07-03 14:30:11 +02:00
return M