Skip to content

Conversation

maarutan
Copy link

@maarutan maarutan commented Jan 16, 2025

Enhance GitGraph: Keybindings, Layout Options, and Configuration Updates

Proposed Changes in My Fork

1. Added Keybindings for Toggling and Closing GitGraph:

  • :GitGraph - Toggle GitGraph.
  • :GitGraphClose - Close the GitGraph buffer.

2. Introduced Multiple Layout Options for Opening GitGraph:

  • Added support for floating, vertical, and horizontal layouts.

3. Updated Configuration:

  • Enhanced configurability for GitGraph with options for layout, keybindings, and symbols.

4. README Update:

  • I propose updating the README to include concise and clear information about configuration options. Here’s an example of how users can configure the plugin:

Example Configuration

require("gitgraph").setup({

	layout = "floating", -- Options: "floating", "vertical", "horizontal"
	floating_width = 80, -- Width for floating window (percentage of the screen)
	floating_height = 80, -- Height for floating window (percentage of the screen)
	border = "single", -- Options: "single", "double", "rounded", "solid", "shadow"
	toggle_keymap = "<leader>gi", -- Default keymap for toggling GitGraph
	key_close = "q", -- Keymap to close GitGraph buffer

	symbols = {
		merge_commit = "",
		commit = "",
		merge_commit_end = "",
		commit_end = "",

		-- Advanced symbols
		GVER = "",
		GHOR = "",
		GCLD = "",
		GCRD = "",
		GCLU = "",
		GCRU = "",
		GLRU = "",
		GLRD = "",
		GLUD = "",
		GRUD = "",
		GFORKU = "",
		GFORKD = "",
		GRUDCD = "",
		GRUDCU = "",
		GLUDCD = "",
		GLUDCU = "",
		GLRDCL = "",
		GLRDCR = "",
		GLRUCL = "",
		GLRUCR = "",
	},

	hooks = {
		on_select_commit = function(commit)
			log.info("Selected commit:", commit.hash)
		end,
		on_select_range_commit = function(from, to)
			log.info("Selected range:", from.hash, to.hash)
		end,
	},
	format = {
		timestamp = "%H:%M:%S %d-%m-%Y",
		fields = { "hash", "timestamp", "author", "branch_name", "tag" },
	},
	log_level = vim.log.levels.ERROR,
})

I believe these improvements make the plugin more user-friendly and configurable. Please review the changes and consider accepting my pull request. I’m looking forward to contributing further enhancements! 😊

@luisdavim
Copy link

This seems great 👍

@isakbm
Copy link
Owner

isakbm commented Jun 2, 2025

Sry been a while since I checked PR's, I see now that this needs to be rebased on upstream @maarutan

Based on the feedback I promise to try to get it in if you rebase 🤞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants