diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index b26e336..df75502 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -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" }, diff --git a/.config/nvim/lua/keybind-functions.lua b/.config/nvim/lua/keybind-functions.lua index deeaef3..80f6322 100644 --- a/.config/nvim/lua/keybind-functions.lua +++ b/.config/nvim/lua/keybind-functions.lua @@ -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 diff --git a/.config/nvim/lua/keybinds.lua b/.config/nvim/lua/keybinds.lua index be75fae..06f1609 100644 --- a/.config/nvim/lua/keybinds.lua +++ b/.config/nvim/lua/keybinds.lua @@ -85,7 +85,6 @@ M.setup = function() K("n", "fc", F.file_config, { desc = "Config file" }) K("n", "ff", F.file_find, { desc = "Find file" }) K("n", "fh", F.file_find_home, { desc = "Find file in ~" }) - K("n", "f/", F.file_find_root, { desc = "Find file in root" }) K("n", "fr", F.file_find_recent, { desc = "Find recent file" }) K("n", "fs", F.file_save, { desc = "Save file" }) @@ -220,11 +219,19 @@ end M.telescope_default_mappings = function() local actions = require("telescope.actions") return { + n = { + [""] = actions.close, + [""] = actions.move_selection_next, + [""] = actions.move_selection_previous, + [""] = actions.select_default, + }, i = { [""] = actions.close, [""] = actions.move_selection_next, [""] = actions.move_selection_previous, [""] = actions.select_default, + + [""] = actions.select_default, } } end diff --git a/.config/nvim/lua/selection.lua b/.config/nvim/lua/selection.lua index 6a34103..e65b19d 100644 --- a/.config/nvim/lua/selection.lua +++ b/.config/nvim/lua/selection.lua @@ -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