Compare commits

..

5 Commits

Author SHA1 Message Date
635eac655b
with status update 2022-10-13 22:19:21 +02:00
90fac0d1ef
with notify 2022-10-13 20:54:52 +02:00
ea113ddc74
with options in another statement 2022-10-13 20:49:27 +02:00
4d15b0c8f9
with state 2022-10-13 20:48:08 +02:00
67dd9f958c
with basic hello world 2022-10-13 20:45:46 +02:00
11 changed files with 129 additions and 0 deletions

7
.stylua.toml Normal file
View File

@ -0,0 +1,7 @@
column_width = 100
line_endings = "Unix"
indent_type = "Spaces"
indent_width = 2
quote_style = "AutoPreferDouble"
call_parentheses = "None"
collapse_simple_statement = "Always"

View File

@ -0,0 +1,16 @@
local create = vim.api.nvim_create_augroup
local define = vim.api.nvim_create_autocmd
local M = {}
create("github_presence_autocmds", { clear = true })
function M.setup()
define({ "BufEnter" }, {
group = "github_presence_autocmds",
pattern = { "*" },
callback = function() require("github_presence.updates").set_status() end,
})
end
return M

View File

@ -0,0 +1,14 @@
local M = {}
M.defaults = {}
local config = {}
function M.setup(user_config)
user_config = user_config or {}
config = vim.tbl_deep_extend("force", M.defaults, user_config)
return config
end
return M

View File

@ -0,0 +1,13 @@
local notify = require "github_presence.notify"
local M = {}
function M.set_status(activity)
if activity == nil then return end
local _ = vim.fn.systemlist(
string.format("github-status --message 'Currently editting: %s'", activity.file)
)
notify.info "set status"
end
return M

View File

@ -0,0 +1,13 @@
local notify = require "github_presence.notify"
local M = {}
function M.setup(options)
require("github_presence.autoload").setup()
require("github_presence.updates").setup()
require("github_presence.config").setup(options)
require("github_presence.timer").start_cron()
end
return M

View File

@ -0,0 +1,17 @@
local M = {}
---@param message string
function M.info(message)
vim.schedule(
function() vim.notify(string.format("[%s]: %s", "github-presence", message), "info") end
)
end
---@param message string
function M.debug(message)
vim.schedule(
function() vim.notify(string.format("[%s]: %s", "github-presence", message), "debug") end
)
end
return M

View File

@ -0,0 +1,13 @@
local github = require "github_presence.github"
local updates = require "github_presence.updates"
return {
start_cron = function()
local timer = vim.loop.new_timer()
timer:start(
1000,
1000 * 60,
vim.schedule_wrap(function() github.set_status(updates.last_activity) end)
)
end,
}

View File

@ -0,0 +1,19 @@
local M = {}
M.last_activity = {}
function M.setup() end
function M.set_status()
local current_buffer = vim.api.nvim_get_current_buf()
local buf_name = vim.api.nvim_buf_get_name(current_buffer)
local file_name = buf_name:match(string.format("^.+%s(.+)$", "/"))
if file_name == nil then return end
if file_name == M.last_activity.file then return end
M.last_activity = {
file = file_name,
set_at = os.time(),
}
end
return M

View File

@ -0,0 +1,7 @@
mutation {
changeUserStatus(input: {}) {
status {
message
}
}
}

10
queries/setStatus.graphql Normal file
View File

@ -0,0 +1,10 @@
mutation ($status: ChangeUserStatusInput!) {
changeUserStatus(input: $status) {
status {
emoji
expiresAt
limitedAvailability: indicatesLimitedAvailability
message
}
}
}