diff options
Diffstat (limited to 'lua/telescope/builtin/git.lua')
| -rw-r--r-- | lua/telescope/builtin/git.lua | 43 |
1 files changed, 14 insertions, 29 deletions
diff --git a/lua/telescope/builtin/git.lua b/lua/telescope/builtin/git.lua index 0302c7d..7bc88cd 100644 --- a/lua/telescope/builtin/git.lua +++ b/lua/telescope/builtin/git.lua @@ -22,16 +22,14 @@ git.files = function(opts) -- By creating the entry maker after the cwd options, -- we ensure the maker uses the cwd options when being created. - opts.entry_maker = opts.entry_maker or make_entry.gen_from_file(opts) + opts.entry_maker = vim.F.if_nil(opts.entry_maker, make_entry.gen_from_file(opts)) + local git_command = vim.F.if_nil(opts.git_command, { "git", "ls-files", "--exclude-standard", "--cached" }) pickers.new(opts, { prompt_title = "Git Files", finder = finders.new_oneshot_job( vim.tbl_flatten { - "git", - "ls-files", - "--exclude-standard", - "--cached", + git_command, show_untracked and "--others" or nil, recurse_submodules and "--recurse-submodules" or nil, }, @@ -43,22 +41,12 @@ git.files = function(opts) end git.commits = function(opts) - opts.entry_maker = opts.entry_maker or make_entry.gen_from_git_commits(opts) + opts.entry_maker = vim.F.if_nil(opts.entry_maker, make_entry.gen_from_git_commits(opts)) + local git_command = vim.F.if_nil(opts.git_command, { "git", "log", "--pretty=oneline", "--abbrev-commit", "--", "." }) pickers.new(opts, { prompt_title = "Git Commits", - - finder = finders.new_oneshot_job( - vim.tbl_flatten { - "git", - "log", - "--pretty=oneline", - "--abbrev-commit", - "--", - ".", - }, - opts - ), + finder = finders.new_oneshot_job(git_command, opts), previewer = { previewers.git_commit_diff_to_parent.new(opts), previewers.git_commit_diff_to_head.new(opts), @@ -80,7 +68,7 @@ git.commits = function(opts) end git.stash = function(opts) - opts.entry_maker = opts.entry_maker or make_entry.gen_from_git_stash() + opts.entry_maker = vim.F.if_nil(opts.entry_maker, make_entry.gen_from_git_stash()) pickers.new(opts, { prompt_title = "Git Stash", @@ -108,19 +96,16 @@ local get_current_buf_line = function(winnr) end git.bcommits = function(opts) - opts.current_line = not opts.current_file and get_current_buf_line(0) or nil - opts.current_file = opts.current_file or vim.fn.expand "%:p" - - opts.entry_maker = opts.entry_maker or make_entry.gen_from_git_commits(opts) + opts.current_line = (opts.current_file == nil) and get_current_buf_line(0) or nil + opts.current_file = vim.F.if_nil(opts.current_file, vim.fn.expand "%:p") + opts.entry_maker = vim.F.if_nil(opts.entry_maker, make_entry.gen_from_git_commits(opts)) + local git_command = vim.F.if_nil(opts.git_command, { "git", "log", "--pretty=oneline", "--abbrev-commit" }) pickers.new(opts, { prompt_title = "Git BCommits", finder = finders.new_oneshot_job( vim.tbl_flatten { - "git", - "log", - "--pretty=oneline", - "--abbrev-commit", + git_command, opts.current_file, }, opts @@ -326,7 +311,7 @@ git.status = function(opts) return finders.new_table { results = output, - entry_maker = opts.entry_maker or make_entry.gen_from_git_status(opts), + entry_maker = vim.F.if_nil(opts.entry_maker, make_entry.gen_from_git_status(opts)), } end @@ -380,7 +365,7 @@ end local function apply_checks(mod) for k, v in pairs(mod) do mod[k] = function(opts) - opts = opts or {} + opts = vim.F.if_nil(opts, {}) set_opts_cwd(opts) v(opts) |
