dotfiles/nvim/lua/telescope_config.lua

31 lines
1.1 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
local actions = require("telescope.actions")
require("telescope").setup{
defaults = {
mappings = {
i = {
["jj"] = actions.close
},
},
}
}
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>Telescope buffers theme=ivy<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