Git Product home page Git Product logo

github-notifications.nvim's Introduction

github-notifications.nvim ๐Ÿ””

A lightweight, unobstructive, yet WIP neovim plugin for viewing GitHub notifications in your statusline + Telescope popup. All requests are processed asynchronously, debounced and cached to ensure no delays in your UI! ๐Ÿš€

Preview

Installation

Use your favourite package manager:

use {
  'rlch/github-notifications.nvim',
  config = [[require('config.github-notifications')]],
  requires = {
    'nvim-lua/plenary.nvim',
    'nvim-telescope/telescope.nvim',
  },
}

Getting Started

Using gh CLI (recommended)

Install the CLI and you're off!

Make sure you authenticate with gh auth login.

Using personal access token

Call setup with your personal access token with the Notifications scope. You can make one here.

local secrets = require 'secrets'

require('github-notifications').setup {
  username = secrets.username,
  token = secrets.token,
}

Default config:

local defaults = {
  github_api_endpoint = 'https://api.github.com', -- Github API Endpoint
  username = nil, -- GitHub username
  token = nil, -- Your personal access token with `notifications` scope
  icon = '๏ˆ', -- Icon to be shown in statusline
  hide_statusline_on_all_read = true,
  hide_entry_on_read = false, -- Whether to hide the Telescope entry after reading (buggy)
  debounce_duration = 60, -- Minimum time until next refresh
  cache = false, -- Opt in/out of caching
  sort_unread_first = true,
  mappings = {
    mark_read = '<CR>',
    hide = 'd', -- remove from Telescope picker, but don't mark as read
    -- open_in_browser = 'o', (WIP)
  },
  prompt_mappings = {
    mark_all_read = '<C-r>'
  } -- keymaps that apply on a Telescope prompt level (insert mode)
}

Lua-based statusline

Statusline

I've only tested this with lualine, but it should work with any Lua-based statusline that takes a Lua function as an argument for displaying data.

require('lualine').setup {
  ...
  sections = {
    ...
    lualine_b = { 'branch', require('github-notifications').statusline_notification_count },
    ...
  },
  ...
}

You can also use statusline_notifications() and build your own formatter:

  local ghn_formatter = function()
    local data = require('github-notifications').statusline_notifications()
    if data.count > 10 then
      return data.icon .. ' purge time'
    elseif data.count == 0 then
      return ''
    end
    return data.icon .. tostring(data.count)
  end

Telescope

Optionally load the extension using:

require('telescope').load_extension 'ghn'

So that require('telescope').extensions.ghn.notifications() can open the popup.

Otherwise, you can simply call:

require('github-notifications.menu').notifications()

I'm aware my API design is abysmal

TODOs

  • Add support for CI status for current branch in statusline
  • Redirect to follow-up URL (instead of API url)
  • Refresh UI on state changes (i.e. when marking notifications as read)
  • Add highlights to Telescope entries
  • Improve Telescope preview UI instead of being lazy with markdown
  • Hide notifications without Telescope shitting itself

Contributing ๐Ÿ‘Œ

Please lmao

github-notifications.nvim's People

Contributors

burahimu avatar rlch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

burahimu

github-notifications.nvim's Issues

Error in packer_compiled

After installing the plugin i get a long error message in the neovim load like this:
image

Error in packer_compiled: /Users/leikoilja/.config/nvim/plugin/packer_compiled.lua:291: module 'config.github-notifications' not found:^@^Ino field package.preload['config.github-notifications']^@^Ino file './config/github-notifications.lua'^@^Ino file '/opt/homebrew/share/luajit-2.1.0-beta3/config/github-notifications.lua'^@^Ino file '/usr/local/share/lua/5.1/config/github-notifications.lua'^@^Ino file '/usr/local/share/l
ua/5.1/config/github-notifications/init.lua'^@^Ino file '/opt/homebrew/share/lua/5.1/config/github-notifications.lua'^@^Ino file '/opt/homebrew/share/lua/5.1/config/github-notifications/init.lua'^@^Ino file '/Users/leikoilja/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/config/github-notifications.lua'^@^Ino file '/Users/leikoilja/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/config/github-notifications/i
nit.lua'^@^Ino file '/Users/leikoilja/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/config/github-notifications.lua'^@^Ino file '/Users/leikoilja/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/config/github-notifications/init.lua'^@^Ino file './config/github-notifications.so'^@^Ino file '/usr/local/lib/lua/5.1/config/github-notifications.so'^@^Ino file '/opt/homebrew/lib/lua/5.1/config/gi
thub-notifications.so'^@^Ino file '/usr/local/lib/lua/5.1/loadall.so'^@^Ino file '/Users/leikoilja/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/lua/5.1/config/github-notifications.so'^@^Ino file './config.so'^@^Ino file '/usr/local/lib/lua/5.1/config.so'^@^Ino file '/opt/homebrew/lib/lua/5.1/config.so'^@^Ino file '/usr/local/lib/lua/5.1/loadall.so'^@^Ino file '/Users/leikoilja/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/l
ua/5.1/config.so'

The last line claims "please check your config for correctness", but i use very default setup, following README:
image

With that being said, the plugin seems to work ad shows me the GH notification on the bottom

[Feature request] option to hide statusline item if no notifications

Hi @rlch, thanks for getting the gh cli working ๐Ÿ‘๐Ÿฟ , I've now swapped out my custom statusline component with this plugin's. One thing I had in my implementation was a way of hiding the statusline element if there were no notifications since I personally prefer having each item in my statusline only visible if there is content/something actionable e.g. a count of > 0 etc. I wonder if this could either be offered as an option, but that might be too specific ๐Ÿคท๐Ÿฟโ€โ™‚๏ธ or alternatively maybe the count and icon could be returned in a table similar to gitsigns e.g. {icon = "x", count = 1} or a user could pass their own formatter function.

The first I think would be simplest, but not sure if this would be too specific a use case to accommodate ๐Ÿคท๐Ÿฟโ€โ™‚๏ธ

E5108: Error executing lua ...ns.nvim/lua/github-notifications/telescope/previewer.lua:23: attempt to concatenate field 'url' (a userdata value)

As per the title, I get this error for some github notifications, not all..no idea why

E5108: Error executing lua ...ns.nvim/lua/github-notifications/telescope/previewer.lua:23: attempt to concatenate field 'url' (a userdata value)
stack traceback:
...ns.nvim/lua/github-notifications/telescope/previewer.lua:23: in function 'define_preview'
...scope.nvim/lua/telescope/previewers/buffer_previewer.lua:386: in function 'preview'
...pack/packer/opt/telescope.nvim/lua/telescope/pickers.lua:1075: in function 'refresh_previewer'
...pack/packer/opt/telescope.nvim/lua/telescope/pickers.lua:1028: in function 'set_selection'
...pack/packer/opt/telescope.nvim/lua/telescope/pickers.lua:792: in function 'move_selection'
.../packer/opt/telescope.nvim/lua/telescope/actions/set.lua:39: in function 'run_replace_or_original'
...k/packer/opt/telescope.nvim/lua/telescope/actions/mt.lua:65: in function 'shift_selection'
...packer/opt/telescope.nvim/lua/telescope/actions/init.lua:87: in function 'run_replace_or_original'
...k/packer/opt/telescope.nvim/lua/telescope/actions/mt.lua:65: in function 'key_func'
...ack/packer/opt/telescope.nvim/lua/telescope/mappings.lua:341: in function 'execute_keymap'
[string ":lua"]:1: in main chunk

No fuzzy finding within telescope

Currently it is not possible to filter the notifications within Telescope via fuzzy finding, which is a main part of Telescope's functionality.

use gh cli tool to remove the need for a token

Hi ๐Ÿ‘‹๐Ÿฟ ,

just stumbled upon this and it seems pretty cool, I've got a much smaller version of this in my statusline but I like the ability to open notifications in a telescope picker etc. One thing I noticed is that it requires a user to pass credentials explicitly in their config which is a little inconvenient and potentially could lead to exposing these.

In my dots I use gh api notifications which seems to work quite well and has the advantage that if a user has the github cli installed and setup then they can make this call without credentials i.e. they will already be auth'ed through the cli.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.