Skip to content

Commit b6eb3c6

Browse files
committed
feat(config): stage.telescopeOpts to pass in telescope picker config
1 parent d3824e4 commit b6eb3c6

File tree

3 files changed

+29
-12
lines changed

3 files changed

+29
-12
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,17 @@ require("tinygit").setup {
323323
resetHunk = "<C-r>",
324324
},
325325
moveToNextHunkOnStagingToggle = false,
326+
327+
-- accepts the common telescope picker config
328+
telescopeOpts = {
329+
layout_strategy = "horizontal",
330+
layout_config = {
331+
horizontal = {
332+
preview_width = 0.65,
333+
height = { 0.7, min = 20 },
334+
},
335+
},
336+
},
326337
},
327338
commit = {
328339
preview = true, -- requires `nvim-notify` or `snacks.nvim`

lua/tinygit/commands/staging/telescope.lua

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -105,19 +105,14 @@ end
105105
-- DOCS https://github.com/nvim-telescope/telescope.nvim/blob/master/developers.md
106106
---@param hunks Tinygit.Hunk[]
107107
function M.pickHunk(hunks)
108-
local icon = require("tinygit.config").config.appearance.mainIcon
108+
local config = require("tinygit.config").config
109+
local title = vim.trim(config.appearance.mainIcon .. " Git hunks")
110+
local telescopeOpts = config.stage.telescopeOpts
111+
109112
pickers
110-
.new({}, {
111-
prompt_title = vim.trim(icon .. " Git hunks"),
112-
sorter = telescopeConf.generic_sorter {},
113-
114-
layout_strategy = "horizontal",
115-
layout_config = {
116-
horizontal = {
117-
preview_width = 0.65,
118-
height = { 0.7, min = 20 },
119-
},
120-
},
113+
.new(telescopeOpts, {
114+
prompt_title = title,
115+
sorter = telescopeConf.generic_sorter(telescopeOpts),
121116

122117
finder = newFinder(hunks),
123118

lua/tinygit/config.lua

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@ local defaultConfig = {
1212
resetHunk = "<C-r>",
1313
},
1414
moveToNextHunkOnStagingToggle = false,
15+
16+
-- accepts the common telescope picker config
17+
telescopeOpts = {
18+
layout_strategy = "horizontal",
19+
layout_config = {
20+
horizontal = {
21+
preview_width = 0.65,
22+
height = { 0.7, min = 20 },
23+
},
24+
},
25+
},
1526
},
1627
commit = {
1728
preview = true, -- requires `nvim-notify` or `snacks.nvim`

0 commit comments

Comments
 (0)