diff --git a/doc/telescope.txt b/doc/telescope.txt index 778feb0..76b5bf2 100644 --- a/doc/telescope.txt +++ b/doc/telescope.txt @@ -967,6 +967,8 @@ builtin.git_files({opts}) *telescope.builtin.git_files()* Options: ~ {cwd} (string) specify the path of the repo + {use_file_path} (boolean) if we should use the current buffer + git root (default: false) {use_git_root} (boolean) if we should use git root as cwd or the cwd (important for submodule) (default: true) @@ -993,11 +995,13 @@ builtin.git_commits({opts}) *telescope.builtin.git_commits()* {opts} (table) options to pass to the picker Options: ~ - {cwd} (string) specify the path of the repo - {use_git_root} (boolean) if we should use git root as cwd or the cwd - (important for submodule) (default: true) - {git_command} (table) command that will be executed. - {"git","log","--pretty=oneline","--abbrev-commit","--","."} + {cwd} (string) specify the path of the repo + {use_file_path} (boolean) if we should use the current buffer git + root (default: false) + {use_git_root} (boolean) if we should use git root as cwd or the cwd + (important for submodule) (default: true) + {git_command} (table) command that will be executed. + {"git","log","--pretty=oneline","--abbrev-commit","--","."} builtin.git_bcommits({opts}) *telescope.builtin.git_bcommits()* @@ -1013,13 +1017,15 @@ builtin.git_bcommits({opts}) *telescope.builtin.git_bcommits()* {opts} (table) options to pass to the picker Options: ~ - {cwd} (string) specify the path of the repo - {use_git_root} (boolean) if we should use git root as cwd or the cwd - (important for submodule) (default: true) - {current_file} (string) specify the current file that should be used - for bcommits (default: current buffer) - {git_command} (table) command that will be executed. - {"git","log","--pretty=oneline","--abbrev-commit"} + {cwd} (string) specify the path of the repo + {use_file_path} (boolean) if we should use the current buffer git + root (default: false) + {use_git_root} (boolean) if we should use git root as cwd or the cwd + (important for submodule) (default: true) + {current_file} (string) specify the current file that should be + used for bcommits (default: current buffer) + {git_command} (table) command that will be executed. + {"git","log","--pretty=oneline","--abbrev-commit"} builtin.git_branches({opts}) *telescope.builtin.git_branches()* @@ -1042,6 +1048,9 @@ builtin.git_branches({opts}) *telescope.builtin.git_branches()* Options: ~ {cwd} (string) specify the path of the repo + {use_file_path} (boolean) if we should use the + current buffer git root + (default: false) {use_git_root} (boolean) if we should use git root as cwd or the cwd (important for submodule) @@ -1064,12 +1073,14 @@ builtin.git_status({opts}) *telescope.builtin.git_status()* {opts} (table) options to pass to the picker Options: ~ - {cwd} (string) specify the path of the repo - {use_git_root} (boolean) if we should use git root as cwd or the cwd - (important for submodule) (default: true) - {git_icons} (table) string -> string. Matches name with icon - (see source code, make_entry.lua - git_icon_defaults) + {cwd} (string) specify the path of the repo + {use_file_path} (boolean) if we should use the current buffer git + root (default: false) + {use_git_root} (boolean) if we should use git root as cwd or the cwd + (important for submodule) (default: true) + {git_icons} (table) string -> string. Matches name with icon + (see source code, make_entry.lua + git_icon_defaults) builtin.git_stash({opts}) *telescope.builtin.git_stash()* @@ -1082,11 +1093,13 @@ builtin.git_stash({opts}) *telescope.builtin.git_stash()* {opts} (table) options to pass to the picker Options: ~ - {cwd} (string) specify the path of the repo - {use_git_root} (boolean) if we should use git root as cwd or the cwd - (important for submodule) (default: true) - {show_branch} (boolean) if we should display the branch name for git - stash entries (default: true) + {cwd} (string) specify the path of the repo + {use_file_path} (boolean) if we should use the current buffer git + root (default: false) + {use_git_root} (boolean) if we should use git root as cwd or the cwd + (important for submodule) (default: true) + {show_branch} (boolean) if we should display the branch name for + git stash entries (default: true) builtin.builtin({opts}) *telescope.builtin.builtin()* diff --git a/lua/telescope/builtin/__git.lua b/lua/telescope/builtin/__git.lua index ef4db8d..a3516b1 100644 --- a/lua/telescope/builtin/__git.lua +++ b/lua/telescope/builtin/__git.lua @@ -382,6 +382,8 @@ end local set_opts_cwd = function(opts) if opts.cwd then opts.cwd = vim.fn.expand(opts.cwd) + elseif opts.use_file_path then + opts.cwd = vim.fn.finddir(".git", vim.fn.expand "%:p" .. ";") else opts.cwd = vim.loop.cwd() end diff --git a/lua/telescope/builtin/init.lua b/lua/telescope/builtin/init.lua index c460c18..c2b1a3f 100644 --- a/lua/telescope/builtin/init.lua +++ b/lua/telescope/builtin/init.lua @@ -132,6 +132,7 @@ builtin.current_buffer_tags = require_on_exported_call("telescope.builtin.__file --- - ``: opens the currently selected file ---@param opts table: options to pass to the picker ---@field cwd string: specify the path of the repo +---@field use_file_path boolean: if we should use the current buffer git root (default: false) ---@field use_git_root boolean: if we should use git root as cwd or the cwd (important for submodule) (default: true) ---@field show_untracked boolean: if true, adds `--others` flag to command and shows untracked files (default: false) ---@field recurse_submodules boolean: if true, adds the `--recurse-submodules` flag to command (default: false) @@ -146,6 +147,7 @@ builtin.git_files = require_on_exported_call("telescope.builtin.__git").files --- - `h`: resets current branch to selected commit using hard mode ---@param opts table: options to pass to the picker ---@field cwd string: specify the path of the repo +---@field use_file_path boolean: if we should use the current buffer git root (default: false) ---@field use_git_root boolean: if we should use git root as cwd or the cwd (important for submodule) (default: true) ---@field git_command table: command that will be executed. {"git","log","--pretty=oneline","--abbrev-commit","--","."} builtin.git_commits = require_on_exported_call("telescope.builtin.__git").commits @@ -158,6 +160,7 @@ builtin.git_commits = require_on_exported_call("telescope.builtin.__git").commit --- - ``: opens a diff in a new tab ---@param opts table: options to pass to the picker ---@field cwd string: specify the path of the repo +---@field use_file_path boolean: if we should use the current buffer git root (default: false) ---@field use_git_root boolean: if we should use git root as cwd or the cwd (important for submodule) (default: true) ---@field current_file string: specify the current file that should be used for bcommits (default: current buffer) ---@field git_command table: command that will be executed. {"git","log","--pretty=oneline","--abbrev-commit"} @@ -173,6 +176,7 @@ builtin.git_bcommits = require_on_exported_call("telescope.builtin.__git").bcomm --- - ``: merges the currently selected branch, with confirmation prompt before deletion ---@param opts table: options to pass to the picker ---@field cwd string: specify the path of the repo +---@field use_file_path boolean: if we should use the current buffer git root (default: false) ---@field use_git_root boolean: if we should use git root as cwd or the cwd (important for submodule) (default: true) ---@field show_remote_tracking_branches boolean: show remote tracking branches like origin/main (default: true) ---@field pattern string: specify the pattern to match all refs @@ -184,6 +188,7 @@ builtin.git_branches = require_on_exported_call("telescope.builtin.__git").branc --- - ``: opens the currently selected file ---@param opts table: options to pass to the picker ---@field cwd string: specify the path of the repo +---@field use_file_path boolean: if we should use the current buffer git root (default: false) ---@field use_git_root boolean: if we should use git root as cwd or the cwd (important for submodule) (default: true) ---@field git_icons table: string -> string. Matches name with icon (see source code, make_entry.lua git_icon_defaults) builtin.git_status = require_on_exported_call("telescope.builtin.__git").status @@ -193,6 +198,7 @@ builtin.git_status = require_on_exported_call("telescope.builtin.__git").status --- - ``: runs `git apply` for currently selected stash ---@param opts table: options to pass to the picker ---@field cwd string: specify the path of the repo +---@field use_file_path boolean: if we should use the current buffer git root (default: false) ---@field use_git_root boolean: if we should use git root as cwd or the cwd (important for submodule) (default: true) ---@field show_branch boolean: if we should display the branch name for git stash entries (default: true) builtin.git_stash = require_on_exported_call("telescope.builtin.__git").stash