dotfiles/nvim/lua/telescope_config.lua

48 lines
1.6 KiB
Lua

local M = {}
local telescope = require("telescope")
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}
local ok = pcall(require"telescope.builtin".git_files, opts)
if not ok 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,
},
},
}
}
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