Your git contributions heatmap chart inside your favorite nvim dashboards.
โ TOC
โ Intro
git-dashboard-nvim is a modular solution to display your git commit contributions as an nvim heatmap dashboard that adapts to the current branch and repository.
It uses vimdev/dashboard-nvim or goolord/alpha-nvim as the base for the dashboard and this plugin generates the header dynamically that we can pass to dashboard-nvim or alpha-nvim.
It allows you to track project based progress in a visual way, making your nvim dashboard look cool while still being useful by showcasing the current git branch and project.
I've mainly developed this plugin for myself, so to make sure it looks well for you, check the Style Variations section, to see some fun styling configurations.
Take into accout that this plugin is in alpha version and you may encounter some unexpected edge cases.
โ Installation
- neovim 0.8.0+ required
- install using your favorite plugin manager (i am using
Lazyin this case) - install using lazy.nvim
- Install nvimdev/dashboard-nvim or goolord/alpha-nvim
{
'nvimdev/dashboard-nvim',
event = 'VimEnter',
dependencies = {
{ 'juansalvatore/git-dashboard-nvim', dependencies = { 'nvim-lua/plenary.nvim' } },
},
opts = function()
local git_dashboard = require('git-dashboard-nvim').setup {}
local opts = { theme = 'doom', config = { header = git_dashboard, center = { { action = '', desc = '', icon = '', key = 'n' }, }, footer = function() return {} end, }, }
-- extra dashboard nvim config ...
return opts end, }
โ Getting Started
The dashboard by default will show a heatmap for the repo in which you are opening nvim and it will track the branch you are currently at (switching branches will change the heatmap to show commits in the respective branch). By default it tracks all commits, but you can specify an author to just track their commits.โ Config
This is the default config, feel free to change things around (some things like chaning months or day labels may look bad if more characters are added)Default config
local git_dashboard = require('git-dashboard-nvim').setup {
fallback_header = '',
top_padding = 0,
bottom_padding = 0,
usegitusernameasauthor = false,
author = '',
branch = 'main',
gap = 'ย ',
centered = true,
daylabelgap = 'ย ',
empty = 'ย ',
empty_square = 'โก',
filled_squares = { 'โ ', 'โ ', 'โ ', 'โ ', 'โ ', 'โ ' },
hide_cursor = true,
is_horizontal = true,
showcontributionscount = true,
showonlyweekswithcommits = false,
title = 'repo_name',
showcurrentbranch = true,
days = { 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' },
months = { 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' },
usecurrentbranch = true,
basepoints = { "master", "main" },
colors = {
daysandmonths_labels = '#7eac6f',
emptysquarehighlight = '#54734a',
filledsquarehighlights = { '#2a3925', '#54734a', '#7eac6f', '#98c689', '#afd2a3', '#bad9b0' },
branch_highlight = '#8DC07C',
dashboard_title = '#a3cc96',
},
}
local opts = { theme = 'doom', config = { header = git_dashboard, center = { { action = '', desc = '', icon = '', key = 'n' }, }, footer = function() return {} end, }, }
Config Definition
---@class Colors ---@field daysandmonths_labels string ---@field emptysquarehighlight string ---@field filledsquarehighlights string[] ---@field branch_highlight string ---@field dashboard_title string
---@class Config ---@field fallback_header string ---@field top_padding number ---@field bottom_padding number ---@field usegitusernameasauthor boolean ---@field author string ignored if usegitusernameasauthor is true ---@field is_horizontal boolean ---@field branch string ---@field centered boolean ---@field gap string ---@field daylabelgap string ---@field empty string ---@field hide_cursor boolean ---@field empty_square string ---@field showcontributionscount boolean ---@field showonlyweekswithcommits boolean ---@field filled_squares string[] ---@field title "ownerwithreponame" | "reponame" | "none" ---@field showcurrentbranch boolean ---@field days string[] ---@field months string[] ---@field usecurrentbranch boolean ---@field basepoints string[] remove commits from base branch, empty array to disable and show all commits ---@field colors Colors
If you want to have an icons show (Eg. branch icon) install a nerd font and set the following global in your init.lua:
vim.g.havenerdfont = true
โ Style Variations
These are some suggested styles and dashboard variations. If you decide to create your own feel free to commit your config with a screen capture and code!Default
Code
local ascii_heatmap = require('git-dashboard-nvim').setup {}
local opts = { theme = 'doom', config = { header = ascii_heatmap, center = { { action = '', desc = '', icon = '', key = 'n' }, }, footer = function() return {} end, }, }
Only weeks with commits
Code
local ascii_heatmap = require('git-dashboard-nvim').setup {
showonlyweekswithcommits = true,
}
local opts = { theme = 'doom', config = { header = ascii_heatmap, center = { { action = '', desc = '', icon = '', key = 'n' }, }, footer = function() return {} end, }, }
With repo owner
Code
local ascii_heatmap = require('git-dashboard-nvim').setup {
title = 'ownerwithrepo_name',
showonlyweekswithcommits = true,
}
local opts = { theme = 'doom', config = { header = ascii_heatmap, center = { { action = '', desc = '', icon = '', key = 'n' }, }, footer = function() return {} end, }, }
Updated day labels
Code
local ascii_heatmap = require('git-dashboard-nvim').setup {
days = { 's', 'm', 't', 'w', 't', 'f', 's' },
}
local opts = { theme = 'doom', config = { header = ascii_heatmap, center = { { action = '', desc = '', icon = '', key = 'n' }, }, footer = function() return {} end, }, }
Updated empty square
Code
local ascii_heatmap = require('git-dashboard-nvim').setup {
days = { 'ะฒ', 'ะฟ', 'ะฒ', 'ั', 'ั', 'ะฟ', 'ั' },
showonlyweekswithcommits = true,
empty_square = ' ',
}
local opts = { theme = 'doom', config = { header = ascii_heatmap, center = { { action = '', desc = '', icon = '', key = 'n' }, }, footer = function() return {} end, }, }
Updated filled squares with different characters
Code
local ascii_heatmap = require('git-dashboard-nvim').setup {
days = { 'ะฒ', 'ะฟ', 'ะฒ', 'ั', 'ั', 'ะฟ', 'ั' },
showonlyweekswithcommits = true,
empty_square = ' ',
filled_squares = { '๎ทฏ', '๎ทฒ', '๎ทฑ', '๎ทฎ', '๎ทญ', '๎ทฐ' },
}
local opts = { theme = 'doom', config = { header = ascii_heatmap, center = { { action = '', desc = '', icon = '', key = 'n' }, }, footer = function() return {} end, }, }
Vertical with weekly commits
Code
local ascii_heatmap = require('git-dashboard-nvim').setup {
showonlyweekswithcommits = true,
is_horizontal = false,
}
local opts = { theme = 'doom', config = { header = ascii_heatmap, center = { { action = '', desc = '', icon = '', key = 'n' }, }, footer = function() return {} end, }, }
Vertical without weekly commits
Code
local ascii_heatmap = require('git-dashboard-nvim').setup {
showonlyweekswithcommits = true,
showcontributionscount = false,
is_horizontal = false,
}
local opts = { theme = 'doom', config = { header = ascii_heatmap, center = { { action = '', desc = '', icon = '', key = 'n' }, }, footer = function() return {} end, }, }
Catppuccin theme
Code
local ascii_heatmap = require('git-dashboard-nvim').setup {
showonlyweekswithcommits = true,
showcontributionscount = false,
days = { 's', 'm', 't', 'w', 't', 'f', 's' },
colors = {
--catpuccin theme
daysandmonths_labels = '#8FBCBB',
emptysquarehighlight = '#3B4252',
filledsquarehighlights = { '#88C0D0', '#88C0D0', '#88C0D0', '#88C0D0', '#88C0D0', '#88C0D0', '#88C0D0' },
branch_highlight = '#88C0D0',
dashboard_title = '#88C0D0',
},
}
local opts = { theme = 'doom', config = { header = ascii_heatmap, center = { { action = '', desc = '', icon = '', key = 'n' }, }, footer = function() return {} end, }, }
Different ascii characters
Code
local ascii_heatmap = require('git-dashboard-nvim').setup {
showonlyweekswithcommits = true,
showcontributionscount = false,
days = { 's', 'm', 't', 'w', 't', 'f', 's' },
filled_squares = { '๏', '๏', '๏', '๏', '๏', '๏' },
empty_square = '๎',
colors = {
-- tokionight colors
daysandmonths_labels = '#61afef',
emptysquarehighlight = '#3e4452',
filledsquarehighlights = { '#61afef', '#61afef', '#61afef', '#61afef', '#61afef', '#61afef' },
branch_highlight = '#61afef',
dashboard_title = '#61afef',
},
}
local opts = { theme = 'doom', config = { header = ascii_heatmap, center = { { action = '', desc = '', icon = '', key = 'n' }, }, footer = function() return {} end, }, }
Different gap and fill ascii
Code
local ascii_heatmap = require('git-dashboard-nvim').setup {
showonlyweekswithcommits = true,
showcontributionscount = false,
days = { 's', 'm', 't', 'w', 't', 'f', 's' },
filled_squares = { 'โ', 'โ', 'โ', 'โ', 'โ', 'โ' },
empty_square = ' ',
gap = '',
colors = {
-- tokinight colors
daysandmonths_labels = '#61afef',
emptysquarehighlight = '#3e4452',
filledsquarehighlights = { '#61afef', '#61afef', '#61afef', '#61afef', '#61afef', '#61afef' },
branch_highlight = '#61afef',
dashboard_title = '#61afef',
},
}
local opts = { theme = 'doom', config = { header = ascii_heatmap, center = { { action = '', desc = '', icon = '', key = 'n' }, }, footer = function() return {} end, }, }
Vertical with different filled and empty squares, and different gap
Code
local ascii_heatmap = require('git-dashboard-nvim').setup {
showonlyweekswithcommits = true,
showcontributionscount = false,
is_horizontal = false,
days = { 's', 'm', 't', 'w', 't', 'f', 's' },
filled_squares = { 'โ', 'โ', 'โ', 'โ', 'โ', 'โ' },
empty_square = ' ',
gap = '',
colors = {
-- tokinight colors
daysandmonths_labels = '#61afef',
emptysquarehighlight = '#3e4452',
filledsquarehighlights = { '#61afef', '#61afef', '#61afef', '#61afef', '#61afef', '#61afef' },
branch_highlight = '#61afef',
dashboard_title = '#61afef',
},
}
local opts = { theme = 'doom', config = { header = ascii_heatmap, center = { { action = '', desc = '', icon = '', key = 'n' }, }, footer = function() return {} end, }, }
Tracking more than one branch
Code
local ascii_heatmap = require('git-dashboard-nvim').setup {
showonlyweekswithcommits = true,
showcontributionscount = false,
usecurrentbranch = false,
branch = 'main',
title = 'ownerwithrepo_name',
top_padding = 15,
centered = false,
days = { 's', 'm', 't', 'w', 't', 'f', 's' },
colors = {
-- tokinight colors
daysandmonths_labels = '#61afef',
emptysquarehighlight = '#3e4452',
filledsquarehighlights = { '#61afef', '#61afef', '#61afef', '#61afef', '#61afef', '#61afef' },
branch_highlight = '#61afef',
dashboard_title = '#61afef',
},
}
local ascii_heatmap2 = require('git-dashboard-nvim').setup { showonlyweekswithcommits = true, showcontributionscount = false, usecurrentbranch = true, branch = 'main', centered = false, title = 'none', days = { 's', 'm', 't', 'w', 't', 'f', 's' }, colors = { -- tokinight colors daysandmonths_labels = '#61afef', emptysquarehighlight = '#3e4452', filledsquarehighlights = { '#61afef', '#61afef', '#61afef', '#61afef', '#61afef', '#61afef' }, branch_highlight = '#61afef', dashboard_title = '#61afef', }, }
local header = {}
for , line in ipairs(asciiheatmap) do table.insert(header, line) end
for , line in ipairs(asciiheatmap2) do table.insert(header, line) end
local opts = { theme = 'doom', config = { header = header, center = { { action = '', desc = '', icon = '', key = 'n' }, }, footer = function() return {} end, }, }
Fallback header for when you are not inside a git repository
Code
local ascii_heatmap = require('git-dashboard-nvim').setup {
showonlyweekswithcommits = true,
showcontributionscount = false,
usecurrentbranch = false,
branch = 'main',
title = 'ownerwithrepo_name',
top_padding = 15,
centered = false,
days = { 's', 'm', 't', 'w', 't', 'f', 's' },
colors = {
-- tokinight colors
daysandmonths_labels = '#61afef',
emptysquarehighlight = '#3e4452',
filledsquarehighlights = { '#61afef', '#61afef', '#61afef', '#61afef', '#61afef', '#61afef' },
branch_highlight = '#61afef',
dashboard_title = '#61afef',
},
}
local ascii_heatmap2 = require('git-dashboard-nvim').setup { showonlyweekswithcommits = true, showcontributionscount = false, usecurrentbranch = true, branch = 'main', centered = false, title = 'none', days = { 's', 'm', 't', 'w', 't', 'f', 's' }, colors = { -- tokinight colors daysandmonths_labels = '#61afef', emptysquarehighlight = '#3e4452', filledsquarehighlights = { '#61afef', '#61afef', '#61afef', '#61afef', '#61afef', '#61afef' }, branch_highlight = '#61afef', dashboard_title = '#61afef', }, }
local header = {}
for , line in ipairs(asciiheatmap) do table.insert(header, line) end
for , line in ipairs(asciiheatmap2) do table.insert(header, line) end
local opts = { theme = 'doom', config = { header = header, center = { { action = '', desc = '', icon = '', key = 'n' }, }, footer = function() return {} end, }, }
Showing a center section
Code
local git_dashboard = require('git-dashboard-nvim').setup {
centered = false,
top_padding = 19,
bottom_padding = 2,
}
local opts = { theme = 'doom', config = { header = git_dashboard, center = { { action = 'ene | startinsert', desc = ' New File', icon = '๏
', key = 'n' }, { action = 'Telescope oldfiles', desc = ' Recent Files', icon = '๏
', key = 'r' }, { action = 'Telescope live_grep', desc = ' Find Text', icon = '๏ข ', key = 'g' }, { action = 'Lazy', desc = ' Lazy', icon = '๓ฐฒ ', key = 'l' }, { action = 'qa', desc = ' Quit', icon = '๏ฆ ', key = 'q' }, }, footer = function() return {} end, }, }
โ Contribution
This project open source, so feel free to fork if you want very specific functionality. If you wish to contribute I am totally willing for PRs, as long as your PR leaves the default look and functionality intact I will accept features that build on top or improve things. I started using nvim around two months ago along with lua, so this is a project I mainly built for myself and to learn a bit more about lua and nvim, but given that I think someone else may enjoy having this as their dashboard I decided to make it open source.Current loading speed
Tests I'm using plenary and for now I'm just running them using <Plug>PlenaryTestFile %