Skip to content

Commit

Permalink
wip(buffer): Adding options
Browse files Browse the repository at this point in the history
  • Loading branch information
AlphabetsAlphabets committed Apr 16, 2024
1 parent 7c5aafb commit 0556ef5
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
14 changes: 8 additions & 6 deletions lua/neogit/buffers/stash_list_view/init.lua
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
local Buffer = require("neogit.lib.buffer")
local ui = require("neogit.buffers.log_view.ui")
local config = require("neogit.config")
local popups = require("neogit.popups")
local notification = require("neogit.lib.notification")
local status_maps = require("neogit.config").get_reversed_status_maps()
local CommitViewBuffer = require("neogit.buffers.commit_view")
local StashEntry = require("neogit.lib.git.stash")

---@class StashListBuffer
---@field stashes StashEntry[]
local M = {}
M.__index = M

---Opens a popup for viewing all stashes
---@param stashes StashEntry[]
function M.new(stashes)
local instance = {}
local instance = {
stashes = stashes
}

setmetatable(instance, M)
return instance
Expand All @@ -28,6 +29,7 @@ function M.open()
filetype = "NeogitStashView",
kind = config.values.stash.kind,
context_higlight = true,
-- Include mapping to turn on options for git stash refer to git-log(1)
mappings = {
["q"] = function()
self:close()
Expand Down
4 changes: 4 additions & 0 deletions lua/neogit/lib/git/stash.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ local util = require("neogit.lib.util")

local M = {}

---@class StashEntry
---@field stash_id string the id of the stash i.e. stash@{7}
---@field message string the message associated with each stash.

local function perform_stash(include)
if not include then
return
Expand Down
20 changes: 19 additions & 1 deletion lua/neogit/popups/stash/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,27 @@ end

--- git stash list
function M.list(popup)
-- This will create a buffer for git stash list
-- git stash list has its own options same as git log from git-log(1)
-- So after uses press `l`, a new popup should show with new options.
-- After the user selects options and stuff then show the output.
-- The output is shown in a buffer.
popup:close() -- from popups/diff/actions.lua

local p = popup
.builder()
:name("NeogitStashPopup")
:arg_heading("Options")
:option("f", "follow", { key_prefix = "-" })
:option("d", "decorate", { default = "no", user_input = true, key_prefix = "-"})
:group_heading("Grouping 2")
:action("t", "test")
:build()

p:show()

-- To build the buffer take example from
-- popups/log/actions.lua L36-40
-- From `popups/branch/actions.lua`
StashViewBuffer:open()
end

Expand Down

0 comments on commit 0556ef5

Please sign in to comment.