From d0a7c71f502cf51a421f7c80e953dad776388684 Mon Sep 17 00:00:00 2001 From: agoodshort Date: Sun, 7 Jan 2024 17:28:56 +0000 Subject: [PATCH] feat: display message if `git` is not in path --- README.md | 6 ----- lua/telescope/_extensions/git_submodules.lua | 25 ++++++++++++-------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index c2ec4e8..f474caa 100644 --- a/README.md +++ b/README.md @@ -30,12 +30,6 @@ return { } ``` -### Requirements - -- [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim) -- [toggleterm.nvim](https://github.com/akinsho/toggleterm.nvim) -- `git` - ## Configuration The extension comes with the following defaults: diff --git a/lua/telescope/_extensions/git_submodules.lua b/lua/telescope/_extensions/git_submodules.lua index e4a49f0..57c16b2 100644 --- a/lua/telescope/_extensions/git_submodules.lua +++ b/lua/telescope/_extensions/git_submodules.lua @@ -199,13 +199,18 @@ local show_repos = function(opts) end end -return require("telescope").register_extension({ - setup = function(ext_config) - for k, v in pairs(ext_config) do - setup_opts[k] = v - end - end, - exports = { - git_submodules = show_repos, - }, -}) +if vim.fn.executable("git") == 0 then + print("telescope-git-submodules: git not in path. Cannot register extension.") + return +else + return require("telescope").register_extension({ + setup = function(ext_config) + for k, v in pairs(ext_config) do + setup_opts[k] = v + end + end, + exports = { + git_submodules = show_repos, + }, + }) +end