Skip to content

jfgordon2/gh-notifications.nvim

Repository files navigation

GitHub Notifications for Neovim

View your GitHub notifications in NeoVim, with sensible defaults, and the ability to filter for just the types of notifications you want to see.

gh-notifications

By default, this tries to narrow down notifications to just what I, personally, like to see, filtering out the vast majority. It also doesn't give full insights into what is contained in each notification, limiting to just the type, title, and URL. If this isn't for you, there are good alternatives with much better options listed at the bottom.

Installation

This plugin requires you to have the GitHub CLI installed.

lazy.nvim

return {
  'jfgordon2/gh-notifications.nvim',
  opts = {},
}
-- These are the default config settings
require('gh_notifications').setup({
  unread_only = true,
  pull_request_filter = {
    enabled = true,
    states = {
      'open',
    },
  },
  notification_reasons = {
    "assign",
    "author",
    "comment",
    "manual",
    "mention",
    "review_requested",
    "security_alert",
    "subscribed",
    "team_mention",
  },
})

Packer

-- in your init.lua or a separate plugins.lua
require('packer').startup(function()
  use {
    'jfgordon2/gh-notifications.nvim',
    config = function()
      require('gh_notifications').setup({
        unread_only = true,
        notification_reasons = {
          "mention",
          "review_requested",
          "subscribed",
          "team_mention",
        },
      })
    end
  }
end)

Extra: Snacks Dashboard Config

See snacks.nvim for full config.

{
  title = 'Notifications',
  cmd = "nvim --headless -c ':GHNotificationsText' -c 'sleep 20000m' -c 'qa!'",
  action = function()
    vim.ui.open 'https://github.com/notifications'
  end,
  key = 'n',
  icon = '',
  height = 8,
  enabled = true,
}

Usage

# view notifications using the vim.notify api
:GHNotifications

# view notifications in a windowed buffer
:GHNotificationsDisplay

# print out notifications as text
# for use in custom context such as your dashboard
:GHNotificationsText

Configuration

unread_only (default: true) - only show unread notifications

notification_reasons - filter notifications by type See GitHub docs for full list of values.

Keybind

vim.api.nvim_set_keymap('n', '<leader>gn', '<cmd>GHNotifications<CR>', { noremap = true, silent = true, desc = "GitHub Notifications" })

Testing

Pre-requisites

Get luarocks

brew install luarocks

Install nlua

luarocks --local install nlua

Then install busted and create a ~/.luarocks/config-nlua.lua as described.

luarocks --local install busted
# add the below to your ~/.zshrc or similar
eval $(luarocks path --no-bin)
export PATH=$PATH:$HOME/.luarocks/bin:

Running tests

make test

Similar Plugins

About

GitHub Notifications for Neovim

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published