Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support wrap config #702

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lua/octo/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ local M = {}
---@field left_bubble_delimiter string
---@field github_hostname string
---@field use_local_fs boolean
---@field wrap boolean
---@field enable_builtin boolean
---@field snippet_context_lines number
---@field gh_cmd string
Expand Down Expand Up @@ -122,6 +123,7 @@ function M.get_default_values()
left_bubble_delimiter = "",
github_hostname = "",
use_local_fs = false,
wrap = false,
enable_builtin = false,
snippet_context_lines = 4,
gh_cmd = "gh",
Expand Down Expand Up @@ -429,6 +431,7 @@ function M.validate_config()

if validate_type(config, "base config", "table") then
validate_type(config.use_local_fs, "use_local_fs", "boolean")
validate_type(config.wrap, "wrap", "boolean")
validate_type(config.enable_builtin, "enable_builtin", "boolean")
validate_type(config.snippet_context_lines, "snippet_context_lines", "number")
validate_type(config.timeout, "timeout", "number")
Expand Down
3 changes: 3 additions & 0 deletions lua/octo/reviews/file-entry.lua
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ function FileEntry:load_buffers(left_winid, right_winid)
if not split.bufid or not vim.api.nvim_buf_is_loaded(split.bufid) then
local conf = config.values
local use_local = conf.use_local_fs and split.pos == "right" and utils.in_pr_branch(self.pull_request)
local wrap = conf.wrap

-- create buffer
split.bufid = M._create_buffer {
Expand All @@ -271,6 +272,7 @@ function FileEntry:load_buffers(left_winid, right_winid)
lines = split.lines,
repo = self.pull_request.repo,
use_local = use_local,
wrap = wrap,
}

-- register new buffer
Expand Down Expand Up @@ -464,6 +466,7 @@ function M._create_buffer(opts)
path = opts.path,
split = string.upper(opts.split),
})
vim.api.nvim_buf_set_option(bufnr, "wrap", opts.wrap)
return bufnr
end

Expand Down
5 changes: 5 additions & 0 deletions lua/tests/octo/config_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ describe("Octo config", function()
assert.True(vim.tbl_count(require("octo.config").validate_config()) ~= 0)
end)

it("should return invalid when wrap isn't a boolean", function()
config.values.wrap = "not a boolean"
assert.True(vim.tbl_count(require("octo.config").validate_config()) ~= 0)
end)

it("should return invalid when enable_builtin isn't a boolean", function()
config.values.enable_builtin = "not a boolean"
assert.True(vim.tbl_count(require("octo.config").validate_config()) ~= 0)
Expand Down