[FEATURE REQUEST]: Get `GITHUB_TOKEN` from a function
mrjones2014 opened this issue · comments
I see that in https://github.com/pwntester/octo.nvim/blob/master/lua/octo/gh/init.lua
you grab GITHUB_TOKEN
from vim.env
. I would like to use the 1Password CLI to populate the GITHUB_TOKEN
.
Currently I have it set up like so (using the op.nvim
1Password Neovim plugin):
local github_token = require('op.api').item.get({ '[item uuid here]', '--fields', 'token' })[1]
if not github_token or not vim.startswith(github_token, 'ghp_') then
error('Failed to get GitHub token.')
end
vim.env.GITHUB_TOKEN = github_token
require('octo').setup()
However, this means I am prompted for auth immediately, instead of only when octo.nvim
actually goes to run the gh
CLI.
Would it be possible to have an option in setup
like so:
require('octo').setup({
get_gh_token = function()
local github_token = require('op.api').item.get({ '[item uuid here]', '--fields', 'token' })[1]
if not github_token or not vim.startswith(github_token, 'ghp_') then
error('Failed to get GitHub token.')
end
return github_token
end,
})
Or it could more generally be get_env
which gets merged with your env_vars
table.
I've opened a PR for this.
Thanks for PR, added few comments there