Skip to content

Commit b5f3378

Browse files
committed
fix: move opts.diff to display.diff
My my own rules this should trigger v4 of the plugin...however because this initial change was less than 24 hours ago, I'm going to let myself slide...
1 parent 574c0ac commit b5f3378

File tree

6 files changed

+24
-24
lines changed

6 files changed

+24
-24
lines changed

README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,13 @@ Use Markdown formatting and include the programming language name at the start o
836836
width = 95,
837837
height = 10,
838838
},
839+
diff = {
840+
enabled = true,
841+
close_chat_at = 240, -- Close an open chat buffer if the total columns of your display are less than...
842+
layout = "vertical", -- vertical|horizontal
843+
opts = { "internal", "filler", "closeoff", "algorithm:patience", "followwrap", "linematch:120" },
844+
provider = "default", -- default
845+
},
839846
chat = {
840847
window = {
841848
layout = "vertical", -- float|vertical|horizontal|buffer
@@ -877,14 +884,6 @@ Use Markdown formatting and include the programming language name at the start o
877884
opts = {
878885
log_level = "ERROR", -- TRACE|DEBUG|ERROR|INFO
879886

880-
diff = {
881-
enabled = true,
882-
close_chat_at = 240, -- Close an open chat buffer if the total columns of your display are less than...
883-
layout = "vertical", -- vertical|horizontal
884-
opts = { "internal", "filler", "closeoff", "algorithm:patience", "followwrap", "linematch:120" },
885-
provider = "default", -- default
886-
},
887-
888887
-- If this is false then any default prompt that is marked as containing code
889888
-- will not be sent to the LLM. Please note that whilst I have made every
890889
-- effort to ensure no code leakage, using this is at your own risk

doc/codecompanion.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*codecompanion.txt* For NVIM v0.9.2 Last change: 2024 September 16
1+
*codecompanion.txt* For NVIM v0.9.2 Last change: 2024 September 17
22

33
==============================================================================
44
Table of Contents *codecompanion-table-of-contents*
@@ -577,6 +577,8 @@ The plugin fires many events during its lifecycle:
577577
- `CodeCompanionInlineFinished` - Fired at the end of the Inline strategy
578578
- `CodeCompanionRequestStarted` - Fired at the start of any API request
579579
- `CodeCompanionRequestFinished` - Fired at the end of any API request
580+
- `CodeCompanionDiffAttached` - Fired when in Diff mode
581+
- `CodeCompanionDiffDetached` - Fired when exiting Diff mode
580582

581583

582584
[!TIP] Some events are sent with a data payload which can be leveraged.

lua/codecompanion/config.lua

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,13 @@ Use Markdown formatting and include the programming language name at the start o
602602
width = 95,
603603
height = 10,
604604
},
605+
diff = {
606+
enabled = true,
607+
close_chat_at = 240, -- Close an open chat buffer if the total columns of your display are less than...
608+
layout = "vertical", -- vertical|horizontal split for default provider
609+
opts = { "internal", "filler", "closeoff", "algorithm:patience", "followwrap", "linematch:120" },
610+
provider = "default", -- default|mini_diff
611+
},
605612
chat = {
606613
window = {
607614
layout = "vertical", -- float|vertical|horizontal|buffer
@@ -643,14 +650,6 @@ Use Markdown formatting and include the programming language name at the start o
643650
opts = {
644651
log_level = "ERROR", -- TRACE|DEBUG|ERROR|INFO
645652

646-
diff = {
647-
enabled = true,
648-
close_chat_at = 240, -- Close an open chat buffer if the total columns of your display are less than...
649-
layout = "vertical", -- vertical|horizontal split for default provider
650-
opts = { "internal", "filler", "closeoff", "algorithm:patience", "followwrap", "linematch:120" },
651-
provider = "default", -- default|mini_diff
652-
},
653-
654653
-- If this is false then any default prompt that is marked as containing code
655654
-- will not be sent to the LLM. Please note that whilst I have made every
656655
-- effort to ensure no code leakage, using this is at your own risk

lua/codecompanion/helpers/diff/default.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,16 @@ function Diff.new(args)
4242
local wrap = vim.wo.wrap
4343
local linebreak = vim.wo.linebreak
4444
local breakindent = vim.wo.breakindent
45-
vim.cmd("set diffopt=" .. table.concat(config.opts.diff.opts, ","))
45+
vim.cmd("set diffopt=" .. table.concat(config.display.diff.opts, ","))
4646

4747
--- Minimize the chat buffer window if there's not enough screen estate
4848
local last_chat = require("codecompanion").last_chat()
49-
if last_chat and last_chat:is_visible() and config.opts.diff.close_chat_at > vim.o.columns then
49+
if last_chat and last_chat:is_visible() and config.display.diff.close_chat_at > vim.o.columns then
5050
last_chat:hide()
5151
end
5252

5353
-- Create the diff buffer
54-
if config.opts.diff.layout == "vertical" then
54+
if config.display.diff.layout == "vertical" then
5555
vim.cmd("vsplit")
5656
else
5757
vim.cmd("split")

lua/codecompanion/helpers/tools/editor.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ return {
1919
local lines = vim.split(action.code, "\n", { plain = true, trimempty = false })
2020

2121
-- Diff the buffer
22-
if config.opts.diff.enabled then
22+
if config.display.diff.enabled then
2323
local ok
24-
local provider = config.opts.diff.provider
24+
local provider = config.display.diff.provider
2525
ok, diff = pcall(require, "codecompanion.helpers.diff." .. provider)
2626

2727
if ok then

lua/codecompanion/strategies/inline.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -561,11 +561,11 @@ end
561561
---Start the diff process
562562
---@return nil
563563
function Inline:start_diff()
564-
if config.opts.diff.enabled == false then
564+
if config.display.diff.enabled == false then
565565
return
566566
end
567567

568-
local provider = config.opts.diff.provider
568+
local provider = config.display.diff.provider
569569
local ok, diff = pcall(require, "codecompanion.helpers.diff." .. provider)
570570
if not ok then
571571
return log:error("Diff provider not found: %s", provider)

0 commit comments

Comments
 (0)