Neovim: Improve file browsing
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
"rainbow-delimiters.nvim": { "branch": "master", "commit": "c7e489756b5455f922ce79ac374a4ede594f4a20" },
|
||||
"sqlite.lua": { "branch": "master", "commit": "d0ffd703b56d090d213b497ed4eb840495f14a11" },
|
||||
"telescope-all-recent.nvim": { "branch": "main", "commit": "267e9e5fd13a6e9a4cc6ffe00452d446d040401d" },
|
||||
"telescope-file-browser.nvim": { "branch": "master", "commit": "626998e5c1b71c130d8bc6cf7abb6709b98287bb" },
|
||||
"telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" },
|
||||
"telescope-recent-files": { "branch": "main", "commit": "3a7a1b9c6b52b6ff7938c59f64c87a05e013dff8" },
|
||||
"telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" },
|
||||
|
||||
@@ -33,7 +33,7 @@ end
|
||||
M.file_config = function()
|
||||
builtin.find_files({
|
||||
prompt_title = "Nvim Config",
|
||||
cwd = "~/.config/nvim",
|
||||
cwd = vim.fn.stdpath("config"),
|
||||
hidden = true,
|
||||
no_ignore = true,
|
||||
-- path_display = { "shorten" },
|
||||
@@ -41,7 +41,7 @@ M.file_config = function()
|
||||
end
|
||||
|
||||
M.file_find = function()
|
||||
builtin.find_files({
|
||||
telescope.extensions.file_browser.file_browser({
|
||||
cwd = F.get_current_directory(),
|
||||
hidden = true,
|
||||
no_ignore = true,
|
||||
@@ -49,18 +49,13 @@ M.file_find = function()
|
||||
end
|
||||
|
||||
M.file_find_home = function()
|
||||
builtin.find_files({
|
||||
telescope.extensions.file_browser.file_browser({
|
||||
cwd = "~",
|
||||
hidden = true,
|
||||
no_ignore = true,
|
||||
})
|
||||
end
|
||||
|
||||
M.file_find_root = function()
|
||||
local cwd = F.get_current_directory():gsub("^/", "")
|
||||
builtin.find_files({ default_text = cwd, cwd = "/" })
|
||||
end
|
||||
|
||||
M.file_find_recent = function()
|
||||
telescope.extensions.recent_files.pick()
|
||||
end
|
||||
|
||||
@@ -85,7 +85,6 @@ M.setup = function()
|
||||
K("n", "<leader>fc", F.file_config, { desc = "Config file" })
|
||||
K("n", "<leader>ff", F.file_find, { desc = "Find file" })
|
||||
K("n", "<leader>fh", F.file_find_home, { desc = "Find file in ~" })
|
||||
K("n", "<leader>f/", F.file_find_root, { desc = "Find file in root" })
|
||||
K("n", "<leader>fr", F.file_find_recent, { desc = "Find recent file" })
|
||||
K("n", "<leader>fs", F.file_save, { desc = "Save file" })
|
||||
|
||||
@@ -220,11 +219,19 @@ end
|
||||
M.telescope_default_mappings = function()
|
||||
local actions = require("telescope.actions")
|
||||
return {
|
||||
n = {
|
||||
["<M-h>"] = actions.close,
|
||||
["<M-j>"] = actions.move_selection_next,
|
||||
["<M-k>"] = actions.move_selection_previous,
|
||||
["<M-l>"] = actions.select_default,
|
||||
},
|
||||
i = {
|
||||
["<M-h>"] = actions.close,
|
||||
["<M-j>"] = actions.move_selection_next,
|
||||
["<M-k>"] = actions.move_selection_previous,
|
||||
["<M-l>"] = actions.select_default,
|
||||
|
||||
["<Tab>"] = actions.select_default,
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
@@ -15,6 +15,7 @@ return {
|
||||
end,
|
||||
},
|
||||
-- Extensions
|
||||
"nvim-telescope/telescope-file-browser.nvim",
|
||||
"smartpde/telescope-recent-files",
|
||||
},
|
||||
extensions = {
|
||||
@@ -38,10 +39,17 @@ return {
|
||||
path = vim.fn.stdpath("cache") .. "/telescope_history",
|
||||
},
|
||||
|
||||
mappings = require("keybinds").telescope_default_mappings()
|
||||
mappings = require("keybinds").telescope_default_mappings(),
|
||||
},
|
||||
extensions = {
|
||||
file_browser = {
|
||||
hide_parent_dir = true, -- hide "../"
|
||||
prompt_path = true, -- set path as prompt prefix
|
||||
},
|
||||
},
|
||||
})
|
||||
require("telescope").load_extension("fzf")
|
||||
require("telescope").load_extension "file_browser"
|
||||
require("telescope").load_extension("recent_files")
|
||||
|
||||
--- ┌──────────────────────────────────────────────────┐
|
||||
@@ -85,7 +93,7 @@ return {
|
||||
-- Width
|
||||
prompt.width = max_columns - (bs ~= 0 and search_condensed == 0 and bs or 0)
|
||||
results.width = max_columns - (bs ~= 0 and search_condensed == 0 and bs or 0)
|
||||
preview.width = math.floor(max_columns * 0.5)
|
||||
preview.width = math.floor(max_columns * 0.75)
|
||||
|
||||
-- Line (position), coordinates start at top-left
|
||||
prompt.line = max_lines - results.height + search_condensed - bs -- take overlapping border into account
|
||||
|
||||
Reference in New Issue
Block a user