Skip to content

Commit df026a1

Browse files
committed
refactor: make telescope explicit dependency
For `lazy.nvim` users, this means they have to explicitly list `telescope` as dependency. This will only affect those not having `telescope` as a plugin or dependency elsewhere in their config. Making it an explicit dependency to be listed by the user is necessary to prepare for `tinygit` supporting other picker plugins, since `lazy.nvim`'s package specification via a `lazy.lua` build file does not give us the flexibility to specify alternative packages.
1 parent 45d379c commit df026a1

File tree

6 files changed

+28
-12
lines changed

6 files changed

+28
-12
lines changed

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
Bundle of commands focused on swift and streamlined git operations.
88

9+
<!-- DEPRECATION 2025-03-03 -->
910
## Breaking changes in v1.0
1011
- `dressing.nvim` and `nvim-notify` are **no longer dependencies**.
1112
- `telescope.nvim` is now a **required dependency**.
@@ -99,8 +100,11 @@ Bundle of commands focused on swift and streamlined git operations.
99100
- *optional*: Treesitter parser for syntax highlighting: `TSInstall gitcommit`
100101
101102
```lua
102-
-- lazy.nvim (automatically takes care of dependencies)
103-
{ "chrisgrieser/nvim-tinygit" },
103+
-- lazy.nvim
104+
{
105+
"chrisgrieser/nvim-tinygit"
106+
dependencies = "nvim-telescope/telescope.nvim",
107+
},
104108
105109
-- packer
106110
use {
@@ -361,7 +365,7 @@ require("tinygit").createGitHubPr()
361365

362366
### File history
363367
Search the git history of the current file. Select from the matching commits to
364-
open a popup with a diffview of the changes.
368+
open a popup with a diff view of the changes.
365369

366370
If the config `history.autoUnshallowIfNeeded` is set to `true`, will also
367371
automatically un-shallow the repo if needed.

lazy.lua

Lines changed: 0 additions & 6 deletions
This file was deleted.

lua/tinygit/commands/commit.lua

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,13 @@ end
178178

179179
---@param opts? { selectFromLastXCommits?: number, squashInstead: boolean, autoRebase?: boolean }
180180
function M.fixupCommit(opts)
181+
-- GUARD
181182
if u.notInGitRepo() or hasNoChanges() then return end
183+
local installed, _ = pcall(require, "telescope")
184+
if not installed then
185+
u.notify("telescope.nvim is not installed.", "warn")
186+
return
187+
end
182188

183189
local defaultOpts = { selectFromLastXCommits = 15, autoRebase = false }
184190
opts = vim.tbl_deep_extend("force", defaultOpts, opts or {})
@@ -246,7 +252,7 @@ function M.fixupCommit(opts)
246252
updateStatusline()
247253
end
248254

249-
require("tinygit.shared.selector").withTelescope(
255+
require("tinygit.shared.picker").withTelescope(
250256
prompt,
251257
commits,
252258
commitFormatter,

lua/tinygit/commands/github.lua

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,19 @@ end
7979
---CAVEAT Due to GitHub API limitations, only the last 100 issues are shown.
8080
---@param opts? { state?: string, type?: string }
8181
function M.issuesAndPrs(opts)
82+
-- GUARD
8283
if u.notInGitRepo() then return end
8384
local repo = M.getGithubRemote()
8485
if not repo then return end
8586
if vim.fn.executable("curl") == 0 then
8687
u.notify("`curl` cannot be found.", "warn")
8788
return
8889
end
90+
local installed, _ = pcall(require, "telescope")
91+
if not installed then
92+
u.notify("telescope.nvim is not installed.", "warn")
93+
return
94+
end
8995

9096
local defaultOpts = { state = "all", type = "all" }
9197
opts = vim.tbl_deep_extend("force", defaultOpts, opts or {})
@@ -151,7 +157,7 @@ function M.issuesAndPrs(opts)
151157
return ("%s #%s %s by %s"):format(icon, issue.number, issue.title, issue.user.login)
152158
end
153159

154-
require("tinygit.shared.selector").withTelescope(
160+
require("tinygit.shared.picker").withTelescope(
155161
prompt,
156162
issues,
157163
issueListFormatter,

lua/tinygit/commands/history.lua

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ local function selectFromCommits(commitList)
314314
end
315315
local onChoice = function(_, commitIdx) showDiff(commitIdx) end
316316

317-
require("tinygit.shared.selector").withTelescope(
317+
require("tinygit.shared.picker").withTelescope(
318318
prompt,
319319
commits,
320320
commitFormatter,
@@ -423,7 +423,13 @@ end
423423
--------------------------------------------------------------------------------
424424

425425
function M.fileHistory()
426+
-- GUARD
426427
if u.notInGitRepo() then return end
428+
local installed, _ = pcall(require, "telescope")
429+
if not installed then
430+
u.notify("telescope.nvim is not installed.", "warn")
431+
return
432+
end
427433

428434
state.absPath = vim.api.nvim_buf_get_name(0)
429435
state.ft = vim.bo.filetype
File renamed without changes.

0 commit comments

Comments
 (0)