From ef7b6ada6d91a1b2932492d78c730e4fc00cd2ea Mon Sep 17 00:00:00 2001 From: tami5 Date: Sun, 13 Mar 2022 20:11:27 +0300 Subject: feat: improve UX with vim.notify (#1763) * fix(notify): don't report request on new line * ref(notify): update message format * ref(msgs): always quote values + decrease duplication * fix(ci): undefined variables * ref(actions): temporary silent actions.__index errors * cleanup * revert: panic effort, we continue to use error for those Co-authored-by: Simon Hauser --- lua/telescope/builtin/git.lua | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'lua/telescope/builtin/git.lua') diff --git a/lua/telescope/builtin/git.lua b/lua/telescope/builtin/git.lua index af5d4c6..2683107 100644 --- a/lua/telescope/builtin/git.lua +++ b/lua/telescope/builtin/git.lua @@ -15,13 +15,21 @@ local git = {} git.files = function(opts) if opts.is_bare then - error "This operation must be run in a work tree" + utils.notify("builtin.git_files", { + msg = "This operation must be run in a work tree", + level = "ERROR", + }) + return end local show_untracked = utils.get_default(opts.show_untracked, true) local recurse_submodules = utils.get_default(opts.recurse_submodules, false) if show_untracked and recurse_submodules then - error "Git does not support both --others and --recurse-submodules" + utils.notify("builtin.git_files", { + msg = "Git does not support both --others and --recurse-submodules", + level = "ERROR", + }) + return end -- By creating the entry maker after the cwd options, @@ -300,7 +308,11 @@ end git.status = function(opts) if opts.is_bare then - error "This operation must be run in a work tree" + utils.notify("builtin.git_status", { + msg = "This operation must be run in a work tree", + level = "ERROR", + }) + return end local gen_new_finder = function() @@ -308,13 +320,17 @@ git.status = function(opts) local git_cmd = { "git", "status", "-s", "--", "." } if expand_dir then - table.insert(git_cmd, table.getn(git_cmd) - 1, "-u") + table.insert(git_cmd, #git_cmd - 1, "-u") end local output = utils.get_os_command_output(git_cmd, opts.cwd) - if table.getn(output) == 0 then + if #output == 0 then print "No changes found" + utils.notify("builtin.git_status", { + msg = "No changes found", + level = "WARN", + }) return end -- cgit v1.2.3