diff --git a/lua/telescope/_extensions/file_browser/config.lua b/lua/telescope/_extensions/file_browser/config.lua index 03374476..13d45934 100644 --- a/lua/telescope/_extensions/file_browser/config.lua +++ b/lua/telescope/_extensions/file_browser/config.lua @@ -45,11 +45,22 @@ _TelescopeFileBrowserConfig = { }, }, attach_mappings = function() - action_set.select:replace_if(function() - -- test whether selected entry is directory + local entry_is_dir = function() local entry = action_state.get_selected_entry() return entry and entry.Path:is_dir() - end, fb_actions.open_dir) + end + + local entry_is_nil = function(prompt_bufnr) + local prompt = action_state.get_current_picker(prompt_bufnr):_get_prompt() + local entry = action_state.get_selected_entry() + + return entry == nil and #prompt > 0 + end + + action_set.select:replace_map { + [entry_is_dir] = fb_actions.open_dir, + [entry_is_nil] = fb_actions.create_from_prompt, + } return true end, diff --git a/lua/telescope/_extensions/file_browser/picker.lua b/lua/telescope/_extensions/file_browser/picker.lua index 3c483cc6..48d8a326 100644 --- a/lua/telescope/_extensions/file_browser/picker.lua +++ b/lua/telescope/_extensions/file_browser/picker.lua @@ -30,7 +30,8 @@ local fb_picker = {} --- List, create, delete, rename, or move files and folders of your cwd.
--- Notes --- - Default keymaps in insert/normal mode: ---- - `` : Opens the currently selected file, or navigates to the currently selected directory +--- - `` : Opens the currently selected file/directory, or creates whatever is in the prompt +--- - `` : Create path in prompt --- - `/`, `\` : (OS Path separator) When typing filepath, the path separator will open a directory like ``. --- - `/c`: Create file/folder at current `path` (trailing path separator creates folder) --- - `/r`: Rename multi-selected files/folders