local wk = require("which-key") local actions = require("telescope.actions") local M = {} M.project_files = function() local opts = {} local ok = pcall(require("telescope.builtin").git_files, opts) if not ok then require("telescope.builtin").find_files(opts) end end M.file_browser = function() require("telescope").extensions.file_browser.file_browser({ cwd = vim.fn.expand("%:p:h"), }) end require("telescope").setup({ defaults = { mappings = { i = { [""] = actions.close, }, }, }, pickers = { git_files = { show_untracked = true, }, find_files = { hidden = true, follow = true, }, live_grep = { hidden = true, follow = true, }, }, extensions = { file_browser = { hidden = true, follow = true, }, fzf = { fuzzy = true, override_generic_sorter = true, override_file_sorter = true, case_mode = "smart_case", }, }, }) require("telescope").load_extension("file_browser") require("telescope").load_extension("ui-select") require("telescope").load_extension("fzf") require("telescope").load_extension("projects") local browse_files = { function() M.file_browser() end, "Browse files", } local find_file_in_project = { function() M.project_files() end, "Find file in project", } wk.register({ f = { f = { "Telescope find_files", "Find file" }, p = { [[lua require('telescope.builtin').find_files{ cwd = '~/.config/nvim/' }]], "Find config file", }, o = { "Telescope oldfiles", "Open recent file" }, b = browse_files, }, b = { b = { "Telescope buffers", "Switch buffer" }, }, h = { h = { "Telescope help_tags", "Vim help tags" }, m = { "Telescope man_pages", "Man pages" }, }, p = { p = { "Telescope projects", "Switch to project" }, f = find_file_in_project, }, g = { c = { "Telescope git_commits", "Checkout commit" }, C = { "Telescope git_bcommits", "Checkout buffer commit" }, B = { "Telescope git_branches", "Switch branch" }, s = { "Telescope git_stash", "Apply stash" }, }, [""] = find_file_in_project, ["."] = browse_files, [","] = { "Telescope buffers", "Switch buffer" }, ["/"] = { "Telescope live_grep", "Live grep" }, }, { prefix = "", }) return M