Improve telescope file browser

This commit is contained in:
ViViDboarder 2024-07-18 10:24:05 -07:00
parent 20c0af47a6
commit 5f3de9a36d

View File

@ -1,14 +1,18 @@
local function load_extensions() local function load_extensions()
local utils = require("utils") local utils = require("utils")
require("telescope").load_extension("file_browser") if utils.is_plugin_loaded("telescope-file-browser.nvim") then
require("telescope").load_extension("file_browser")
end
if utils.is_plugin_loaded("nvim-notify") then if utils.is_plugin_loaded("nvim-notify") then
require("telescope").load_extension("notify") require("telescope").load_extension("notify")
end end
end end
local function config_telescope() local function config_telescope()
local utils = require("utils")
local actions = require("telescope.actions") local actions = require("telescope.actions")
require("telescope").setup({ local opts = {
defaults = { defaults = {
mappings = { mappings = {
i = { i = {
@ -19,9 +23,19 @@ local function config_telescope()
}, },
layout_strategy = "flex", layout_strategy = "flex",
}, },
}) extensions = {},
}
if utils.is_plugin_loaded("telescope-file-browser.nvim") then
opts.extensions = {
file_browser = {
hidden = true,
show_hidden = true,
dir_icon = "📁",
},
}
end
require("telescope").setup(opts)
local utils = require("utils")
local telescope_builtin = require("telescope.builtin") local telescope_builtin = require("telescope.builtin")
utils.keymap_set("n", "<C-t>", telescope_builtin.find_files, { desc = "Find files" }) utils.keymap_set("n", "<C-t>", telescope_builtin.find_files, { desc = "Find files" })
@ -41,6 +55,10 @@ local function config_telescope()
finder_keymap("t", telescope_builtin.current_buffer_tags, { desc = "Find buffer tags" }) finder_keymap("t", telescope_builtin.current_buffer_tags, { desc = "Find buffer tags" })
finder_keymap("T", telescope_builtin.tags, { desc = "Find tags" }) finder_keymap("T", telescope_builtin.tags, { desc = "Find tags" })
if utils.is_plugin_loaded("telescope-file-browser.nvim") then
finder_keymap("F", require("telescope").extensions.file_browser.file_browser, { desc = "File browser" })
end
utils.try_require("sg.telescope", function(telescope_sg) utils.try_require("sg.telescope", function(telescope_sg)
finder_keymap("G", telescope_sg.fuzzy_search_results, { desc = "Search Sourcegraph" }) finder_keymap("G", telescope_sg.fuzzy_search_results, { desc = "Search Sourcegraph" })
end) end)