Skip to content

Commit

Permalink
Merge pull request #499 from samjwillis97/master
Browse files Browse the repository at this point in the history
  • Loading branch information
Alvaro Muñoz authored Feb 16, 2024
2 parents 9190a1a + 3d1ffd4 commit feae1e5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ require"octo".setup({
left_bubble_delimiter = ""; -- bubble delimiter
github_hostname = ""; -- GitHub Enterprise host
snippet_context_lines = 4; -- number or lines around commented lines
gh_cmd = "gh", -- Command to use when calling Github CLI
gh_env = {}, -- extra environment variables to pass on to GitHub CLI, can be a table or function returning a table
timeout = 5000, -- timeout for requests between the remote server
default_to_projects_v2 = false, -- use projects v2 for the `Octo card ...` command by default. Both legacy and v2 commands are available under `Octo cardlegacy ...` and `Octo cardv2 ...` respectively.
Expand Down
3 changes: 3 additions & 0 deletions lua/octo/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ local M = {}
---@field use_local_fs boolean
---@field enable_builtin boolean
---@field snippet_context_lines number
---@field gh_cmd string
---@field gh_env table
---@field timeout number
---@field default_to_projects_v2 boolean
Expand Down Expand Up @@ -103,6 +104,7 @@ function M.get_default_values()
use_local_fs = false,
enable_builtin = false,
snippet_context_lines = 4,
gh_cmd = "gh",
gh_env = {},
timeout = 5000,
default_to_projects_v2 = false,
Expand Down Expand Up @@ -383,6 +385,7 @@ function M.validate_config()
if validate_type(config.suppress_missing_scope, "supress_missing_scope", "table") then
validate_type(config.suppress_missing_scope.projects_v2, "supress_missing_scope.projects_v2", "boolean")
end
validate_type(config.gh_cmd, "gh_cmd", "string")
validate_type(config.gh_env, "gh_env", "table")
validate_type(config.reaction_viewer_hint_icon, "reaction_viewer_hint_icon", "string")
validate_type(config.user_icon, "user_icon", "string")
Expand Down
6 changes: 3 additions & 3 deletions lua/octo/gh/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function M.get_user_name(remote_hostname)

local job = Job:new {
enable_recording = true,
command = "gh",
command = config.values.gh_cmd,
args = { "auth", "status", "--hostname", remote_hostname },
env = get_env(),
}
Expand Down Expand Up @@ -89,7 +89,7 @@ function M.setup()
_G.octo_pv2_fragment = ""
Job:new({
enable_recording = true,
command = "gh",
command = config.values.gh_cmd,
args = { "auth", "status" },
env = get_env(),
on_exit = vim.schedule_wrap(function(j_self, _, _)
Expand Down Expand Up @@ -146,7 +146,7 @@ function M.run(opts)
end
local job = Job:new {
enable_recording = true,
command = "gh",
command = config.values.gh_cmd,
args = opts.args,
on_stdout = vim.schedule_wrap(function(err, data, _)
if mode == "async" and opts.stream_cb then
Expand Down
10 changes: 6 additions & 4 deletions lua/octo/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,17 @@ _G.octo_colors_loaded = false
local M = {}

function M.setup(user_config)
if not vim.fn.executable "gh" then
utils.error "gh executable not found"
return
end
if not vim.fn.has "nvim-0.7" then
utils.error "octo.nvim requires neovim 0.7+"
return
end

config.setup(user_config or {})
if not vim.fn.executable(config.values.gh_cmd) then
utils.error("gh executable not found using path: " .. config.values.gh_cmd)
return
end

signs.setup()
picker.setup()
completion.setup()
Expand Down

0 comments on commit feae1e5

Please sign in to comment.