generated from 2KAbhishek/template.nvim
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
175 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,6 @@ | ||
---@class octohub | ||
local M = {} | ||
|
||
---@class octohub.config | ||
---@field contrib_icons table : Table of icons to use for contributions, can be any length | ||
---@field per_user_dir boolean : Whether to create a directory for each user | ||
---@field projects_dir string : Directory where repositories are cloned | ||
---@field sort_repos_by string : Sort repositories by various params | ||
---@field repo_type string : Type of repositories to display | ||
---@field max_contributions number : Max number of contributions per day to use for icon selection | ||
---@field top_lang_count number : Number of top languages to display | ||
---@field event_count number : Number of activity events to show | ||
---@field window_width number : Width in percentage of the window to display stats | ||
---@field window_height number :Height in percentage of the window to display stats | ||
---@field show_recent_activity boolean : Whether to show recent activity | ||
---@field show_contributions boolean : Whether to show contributions | ||
---@field show_repo_stats boolean : Whether to show repository stats | ||
---@field repo_cache_timeout number : Time in seconds to cache repositories | ||
---@field username_cache_timeout number : Time in seconds to cache username | ||
---@field events_cache_timeout number : Time in seconds to cache events data | ||
---@field contributions_cache_timeout number : Time in seconds to contributions data | ||
---@field user_cache_timeout number : Time in seconds to cache user data | ||
---@field add_default_keybindings boolean : Whether to add default keybindings | ||
local config = { | ||
contrib_icons = { '', '', '', '', '', '', '' }, | ||
per_user_dir = true, | ||
projects_dir = '~/Projects/', | ||
sort_repos_by = '', | ||
repo_type = '', | ||
max_contributions = 50, | ||
top_lang_count = 5, | ||
event_count = 5, | ||
window_width = 90, | ||
window_height = 60, | ||
show_recent_activity = true, | ||
show_contributions = true, | ||
show_repo_stats = true, | ||
events_cache_timeout = 3600 * 6, | ||
contibutions_cache_timeout = 3600 * 6, | ||
repo_cache_timeout = 3600 * 24 * 7, | ||
username_cache_timeout = 3600 * 24 * 7, | ||
user_cache_timeout = 3600 * 24 * 7, | ||
add_default_keybindings = true, | ||
return { | ||
setup = function (opts) | ||
require('octohub.config').setup(opts) | ||
require('octohub.setup_cmd').setup() | ||
end | ||
} | ||
|
||
---@type octohub.config | ||
M.config = config | ||
|
||
---@param args octohub.config | ||
M.setup = function(args) | ||
M.config = vim.tbl_deep_extend('force', M.config, args or {}) | ||
end | ||
|
||
return M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
---@class octohub | ||
local M = {} | ||
|
||
---@class octohub.config | ||
---@field contrib_icons table : Table of icons to use for contributions, can be any length | ||
---@field per_user_dir boolean : Whether to create a directory for each user | ||
---@field projects_dir string : Directory where repositories are cloned | ||
---@field sort_repos_by string : Sort repositories by various params | ||
---@field repo_type string : Type of repositories to display | ||
---@field max_contributions number : Max number of contributions per day to use for icon selection | ||
---@field top_lang_count number : Number of top languages to display | ||
---@field event_count number : Number of activity events to show | ||
---@field window_width number : Width in percentage of the window to display stats | ||
---@field window_height number :Height in percentage of the window to display stats | ||
---@field show_recent_activity boolean : Whether to show recent activity | ||
---@field show_contributions boolean : Whether to show contributions | ||
---@field show_repo_stats boolean : Whether to show repository stats | ||
---@field repo_cache_timeout number : Time in seconds to cache repositories | ||
---@field username_cache_timeout number : Time in seconds to cache username | ||
---@field events_cache_timeout number : Time in seconds to cache events data | ||
---@field contributions_cache_timeout number : Time in seconds to contributions data | ||
---@field user_cache_timeout number : Time in seconds to cache user data | ||
---@field add_default_keybindings boolean : Whether to add default keybindings | ||
local config = { | ||
contrib_icons = { '', '', '', '', '', '', '' }, | ||
per_user_dir = true, | ||
projects_dir = '~/Projects/', | ||
sort_repos_by = '', | ||
repo_type = '', | ||
max_contributions = 50, | ||
top_lang_count = 5, | ||
event_count = 5, | ||
window_width = 90, | ||
window_height = 60, | ||
show_recent_activity = true, | ||
show_contributions = true, | ||
show_repo_stats = true, | ||
events_cache_timeout = 3600 * 6, | ||
contibutions_cache_timeout = 3600 * 6, | ||
repo_cache_timeout = 3600 * 24 * 7, | ||
username_cache_timeout = 3600 * 24 * 7, | ||
user_cache_timeout = 3600 * 24 * 7, | ||
add_default_keybindings = true, | ||
} | ||
|
||
---@type octohub.config | ||
M.config = config | ||
|
||
---@param args octohub.config | ||
M.setup = function(args) | ||
M.config = vim.tbl_deep_extend('force', M.config, args or {}) | ||
end | ||
|
||
return M | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
local repos = require('octohub.repos') | ||
local stats = require('octohub.stats') | ||
local web = require('octohub.web') | ||
local config = require('octohub.config').config | ||
|
||
M = {} | ||
|
||
M.setup = function() | ||
vim.api.nvim_create_user_command('OctoRepos', function(opts) | ||
local args = vim.split(opts.args, ' ') | ||
local user_arg, sort_arg, type_arg = '', '', '' | ||
|
||
for _, arg in ipairs(args) do | ||
if arg:sub(1, 5) == 'sort:' then | ||
sort_arg = arg:sub(6) | ||
elseif arg:sub(1, 5) == 'type:' then | ||
type_arg = arg:sub(6) | ||
else | ||
user_arg = arg | ||
end | ||
end | ||
|
||
repos.show_repos(user_arg, sort_arg, type_arg) | ||
end, { nargs = '*' }) | ||
|
||
vim.api.nvim_create_user_command('OctoRepo', function(opts) | ||
local args = vim.split(opts.args, ' ') | ||
if #args == 1 then | ||
repos.open_repo(args[1]) | ||
elseif #args == 2 then | ||
repos.open_repo(args[2], args[1]) | ||
end | ||
end, { nargs = '*' }) | ||
|
||
vim.api.nvim_create_user_command('OctoStats', function(opts) | ||
stats.show_all_stats(opts.args) | ||
end, { nargs = '?' }) | ||
|
||
vim.api.nvim_create_user_command('OctoActivityStats', function(opts) | ||
local args = vim.split(opts.args, ' ') | ||
local user_arg, count_arg = '', '' | ||
|
||
for _, arg in ipairs(args) do | ||
if arg:sub(1, 6) == 'count:' then | ||
count_arg = arg:sub(7) | ||
else | ||
user_arg = arg | ||
end | ||
end | ||
stats.show_activity_stats(user_arg, tonumber(count_arg)) | ||
end, { nargs = '*' }) | ||
|
||
vim.api.nvim_create_user_command('OctoContributionStats', function(opts) | ||
stats.show_contribution_stats(opts.args) | ||
end, { nargs = '?' }) | ||
|
||
vim.api.nvim_create_user_command('OctoRepoStats', function(opts) | ||
stats.show_repo_stats(opts.args) | ||
end, { nargs = '?' }) | ||
|
||
vim.api.nvim_create_user_command('OctoRepoWeb', function(_) | ||
web.open_repo_web() | ||
end, { nargs = '?' }) | ||
|
||
vim.api.nvim_create_user_command('OctoProfile', function(opts) | ||
web.open_github_profile(opts.args) | ||
end, { nargs = '?' }) | ||
|
||
if config.add_default_keybindings then | ||
local function add_keymap(keys, cmd, desc) | ||
vim.api.nvim_set_keymap('n', keys, cmd, { noremap = true, silent = true, desc = desc }) | ||
end | ||
|
||
add_keymap('<leader>goo', ':OctoRepos<CR>', 'All Repos') | ||
add_keymap('<leader>gos', ':OctoRepos sort:stars<CR>', 'Top Starred Repos') | ||
add_keymap('<leader>goi', ':OctoRepos sort:issues<CR>', 'Repos With Issues') | ||
add_keymap('<leader>gou', ':OctoRepos sort:updated<CR>', 'Recently Updated Repos') | ||
add_keymap('<leader>gop', ':OctoRepos type:private<CR>', 'Private Repos') | ||
add_keymap('<leader>gof', ':OctoRepos type:fork<CR>', 'Forked Repos') | ||
add_keymap('<leader>goc', ':OctoRepo<CR>', 'Open Repo') | ||
add_keymap('<leader>got', ':OctoStats<CR>', 'All Stats') | ||
add_keymap('<leader>goa', ':OctoActivityStats<CR>', 'Activity Stats') | ||
add_keymap('<leader>gog', ':OctoContributionStats<CR>', 'Contribution Graph') | ||
add_keymap('<leader>gor', ':OctoRepoStats<CR>', 'Repo Stats') | ||
add_keymap('<leader>goh', ':OctoProfile<CR>', 'Open GitHub Profile') | ||
add_keymap('<leader>gow', ':OctoRepoWeb<CR>', 'Open Repo in Browser') | ||
end | ||
end | ||
|
||
return M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.