From 457439fa9603984fc0ab38be77c418ab821bb12a Mon Sep 17 00:00:00 2001 From: d7ryLinux Date: Mon, 25 Mar 2024 18:10:40 -0700 Subject: [PATCH 01/12] feat: done notification is toggleable --- lua/CopilotChat/config.lua | 3 +++ lua/CopilotChat/spinner.lua | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lua/CopilotChat/config.lua b/lua/CopilotChat/config.lua index 06e6f0c6..99380292 100644 --- a/lua/CopilotChat/config.lua +++ b/lua/CopilotChat/config.lua @@ -76,6 +76,8 @@ local select = require('CopilotChat.select') ---@field prompts table? ---@field window CopilotChat.config.window? ---@field mappings CopilotChat.config.mappings? +---@field notify_done boolean? +--- return { debug = false, -- Enable debug logging proxy = nil, -- [protocol://]host[:port] Use this proxy @@ -92,6 +94,7 @@ return { show_folds = true, -- Shows folds for sections in chat show_help = true, -- Shows help message as virtual lines when waiting for user input + notify_done = true, -- Notify when chat is done auto_follow_cursor = true, -- Auto-follow cursor in chat auto_insert_mode = false, -- Automatically enter insert mode when opening window and if auto follow cursor is enabled on new prompt clear_chat_on_new_prompt = false, -- Clears chat on every new prompt diff --git a/lua/CopilotChat/spinner.lua b/lua/CopilotChat/spinner.lua index 8001e8e4..02fb9fbd 100644 --- a/lua/CopilotChat/spinner.lua +++ b/lua/CopilotChat/spinner.lua @@ -5,6 +5,7 @@ ---@field finish fun(self: CopilotChat.Spinner) local utils = require('CopilotChat.utils') +local config = require('CopilotChat.config') local class = utils.class local spinner_frames = { @@ -78,7 +79,9 @@ function Spinner:finish() timer:stop() timer:close() vim.api.nvim_buf_del_extmark(self.bufnr, self.ns, self.ns) - vim.notify('Done!', vim.log.levels.INFO, { title = self.title }) + if config.notify_done then + vim.notify('Done!', vim.log.levels.INFO, { title = self.title }) + end end return Spinner From 37b4b603dcb908fec5735f4b1ba7e0927a16bb0e Mon Sep 17 00:00:00 2001 From: d7ryLinux Date: Mon, 25 Mar 2024 18:17:32 -0700 Subject: [PATCH 02/12] fix: fix config pathing in spinner.lua --- lua/CopilotChat/spinner.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/CopilotChat/spinner.lua b/lua/CopilotChat/spinner.lua index 02fb9fbd..76c6293a 100644 --- a/lua/CopilotChat/spinner.lua +++ b/lua/CopilotChat/spinner.lua @@ -5,7 +5,7 @@ ---@field finish fun(self: CopilotChat.Spinner) local utils = require('CopilotChat.utils') -local config = require('CopilotChat.config') +local config = require('CopilotChat.init').config local class = utils.class local spinner_frames = { From efa275b2de4a55a42cb25c84e41a8aea52117ebf Mon Sep 17 00:00:00 2001 From: d7ryLinux Date: Mon, 25 Mar 2024 18:18:39 -0700 Subject: [PATCH 03/12] fix: fix config pathing fr --- lua/CopilotChat/spinner.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/CopilotChat/spinner.lua b/lua/CopilotChat/spinner.lua index 76c6293a..543ea8dc 100644 --- a/lua/CopilotChat/spinner.lua +++ b/lua/CopilotChat/spinner.lua @@ -5,7 +5,6 @@ ---@field finish fun(self: CopilotChat.Spinner) local utils = require('CopilotChat.utils') -local config = require('CopilotChat.init').config local class = utils.class local spinner_frames = { @@ -78,6 +77,8 @@ function Spinner:finish() timer:stop() timer:close() + + local config = require('CopilotChat.init').config vim.api.nvim_buf_del_extmark(self.bufnr, self.ns, self.ns) if config.notify_done then vim.notify('Done!', vim.log.levels.INFO, { title = self.title }) From 6979d67620fbde5d368766daf494054bfd847f8a Mon Sep 17 00:00:00 2001 From: d7ryLinux Date: Mon, 25 Mar 2024 18:23:36 -0700 Subject: [PATCH 04/12] chore: clean up spinner config --- lua/CopilotChat/chat.lua | 2 +- lua/CopilotChat/spinner.lua | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lua/CopilotChat/chat.lua b/lua/CopilotChat/chat.lua index 331ec174..86730f11 100644 --- a/lua/CopilotChat/chat.lua +++ b/lua/CopilotChat/chat.lua @@ -49,7 +49,7 @@ local Chat = class(function(self, mark_ns, help, on_buf_create) end if not self.spinner then - self.spinner = Spinner(bufnr, mark_ns, 'copilot-chat') + self.spinner = Spinner(bufnr, mark_ns, 'copilot-chat', require('CopilotChat.config').notify_done) else self.spinner.bufnr = bufnr end diff --git a/lua/CopilotChat/spinner.lua b/lua/CopilotChat/spinner.lua index 543ea8dc..af2dfeca 100644 --- a/lua/CopilotChat/spinner.lua +++ b/lua/CopilotChat/spinner.lua @@ -20,12 +20,13 @@ local spinner_frames = { '⠏', } -local Spinner = class(function(self, bufnr, ns, title) +local Spinner = class(function(self, bufnr, ns, title, notify_when_done) self.ns = ns self.bufnr = bufnr self.title = title self.timer = nil self.index = 1 + self.b_notify_when_done = notify_when_done end) function Spinner:start() @@ -79,8 +80,7 @@ function Spinner:finish() timer:close() local config = require('CopilotChat.init').config - vim.api.nvim_buf_del_extmark(self.bufnr, self.ns, self.ns) - if config.notify_done then + if self.b_notify_when_done then vim.notify('Done!', vim.log.levels.INFO, { title = self.title }) end end From 2448276bab9d328ce0bbe1bfc00b011ed637356f Mon Sep 17 00:00:00 2001 From: d7ryLinux Date: Mon, 25 Mar 2024 18:28:28 -0700 Subject: [PATCH 05/12] fix: fix config frfr --- lua/CopilotChat/chat.lua | 4 ++-- lua/CopilotChat/init.lua | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lua/CopilotChat/chat.lua b/lua/CopilotChat/chat.lua index 86730f11..3cc6584d 100644 --- a/lua/CopilotChat/chat.lua +++ b/lua/CopilotChat/chat.lua @@ -30,7 +30,7 @@ function CopilotChatFoldExpr(lnum, separator) return '=' end -local Chat = class(function(self, mark_ns, help, on_buf_create) +local Chat = class(function(self, mark_ns, help, on_buf_create, config) self.mark_ns = mark_ns self.help = help self.on_buf_create = on_buf_create @@ -49,7 +49,7 @@ local Chat = class(function(self, mark_ns, help, on_buf_create) end if not self.spinner then - self.spinner = Spinner(bufnr, mark_ns, 'copilot-chat', require('CopilotChat.config').notify_done) + self.spinner = Spinner(bufnr, mark_ns, 'copilot-chat', config.notify_when_done) else self.spinner.bufnr = bufnr end diff --git a/lua/CopilotChat/init.lua b/lua/CopilotChat/init.lua index 2162b42f..5a1dd2ec 100644 --- a/lua/CopilotChat/init.lua +++ b/lua/CopilotChat/init.lua @@ -749,7 +749,7 @@ function M.setup(config) append(M.config.question_header .. M.config.separator .. '\n\n') state.chat:finish() - end) + end, config) tiktoken.setup() debuginfo.setup() From dea8d3b5afbd1a1e1da7eb7d81b086fe3edaba99 Mon Sep 17 00:00:00 2001 From: d7ryLinux Date: Mon, 25 Mar 2024 18:31:33 -0700 Subject: [PATCH 06/12] chore(doc): update readme with new config --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index b54e4d4f..1e7f0c11 100644 --- a/README.md +++ b/README.md @@ -203,6 +203,8 @@ Also see [here](/lua/CopilotChat/config.lua): error_header = '**Error** ', -- Header to use for errors separator = '---', -- Separator to use in chat + notify_done = true, -- Send notification when chat is complete + show_folds = true, -- Shows folds for sections in chat show_help = true, -- Shows help message as virtual lines when waiting for user input auto_follow_cursor = true, -- Auto-follow cursor in chat From 6ff64076753189f2c3aeaacfee12aaf42263b43b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 26 Mar 2024 01:32:54 +0000 Subject: [PATCH 07/12] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lua/CopilotChat/spinner.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/CopilotChat/spinner.lua b/lua/CopilotChat/spinner.lua index af2dfeca..d46f4b47 100644 --- a/lua/CopilotChat/spinner.lua +++ b/lua/CopilotChat/spinner.lua @@ -78,7 +78,7 @@ function Spinner:finish() timer:stop() timer:close() - + local config = require('CopilotChat.init').config if self.b_notify_when_done then vim.notify('Done!', vim.log.levels.INFO, { title = self.title }) From b7b191c244a8b78504b6d3f3ecb844e9f6887d99 Mon Sep 17 00:00:00 2001 From: d7ryLinux Date: Mon, 25 Mar 2024 21:05:49 -0700 Subject: [PATCH 08/12] fix: fix spinner not disappearing --- lua/CopilotChat/chat.lua | 2 +- lua/CopilotChat/spinner.lua | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lua/CopilotChat/chat.lua b/lua/CopilotChat/chat.lua index 3cc6584d..8248e93a 100644 --- a/lua/CopilotChat/chat.lua +++ b/lua/CopilotChat/chat.lua @@ -49,7 +49,7 @@ local Chat = class(function(self, mark_ns, help, on_buf_create, config) end if not self.spinner then - self.spinner = Spinner(bufnr, mark_ns, 'copilot-chat', config.notify_when_done) + self.spinner = Spinner(bufnr, mark_ns, 'copilot-chat', config.notify_done) else self.spinner.bufnr = bufnr end diff --git a/lua/CopilotChat/spinner.lua b/lua/CopilotChat/spinner.lua index d46f4b47..cbb62365 100644 --- a/lua/CopilotChat/spinner.lua +++ b/lua/CopilotChat/spinner.lua @@ -20,13 +20,13 @@ local spinner_frames = { '⠏', } -local Spinner = class(function(self, bufnr, ns, title, notify_when_done) +local Spinner = class(function(self, bufnr, ns, title, notify_done) self.ns = ns self.bufnr = bufnr self.title = title self.timer = nil self.index = 1 - self.b_notify_when_done = notify_when_done + self.b_notify_when_done = notify_done end) function Spinner:start() @@ -79,7 +79,9 @@ function Spinner:finish() timer:stop() timer:close() - local config = require('CopilotChat.init').config + -- Clear the extmark + vim.api.nvim_buf_del_extmark(self.bufnr, self.ns, self.ns) + if self.b_notify_when_done then vim.notify('Done!', vim.log.levels.INFO, { title = self.title }) end From 818406f53897a6ccb77d9767a712dbb3f4759852 Mon Sep 17 00:00:00 2001 From: d7ryLinux Date: Tue, 26 Mar 2024 22:54:24 -0700 Subject: [PATCH 09/12] remove notify completely --- README.md | 1 - lua/CopilotChat/chat.lua | 2 +- lua/CopilotChat/config.lua | 4 +--- lua/CopilotChat/spinner.lua | 7 +------ 4 files changed, 3 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 1e7f0c11..84936264 100644 --- a/README.md +++ b/README.md @@ -203,7 +203,6 @@ Also see [here](/lua/CopilotChat/config.lua): error_header = '**Error** ', -- Header to use for errors separator = '---', -- Separator to use in chat - notify_done = true, -- Send notification when chat is complete show_folds = true, -- Shows folds for sections in chat show_help = true, -- Shows help message as virtual lines when waiting for user input diff --git a/lua/CopilotChat/chat.lua b/lua/CopilotChat/chat.lua index 8248e93a..1de2b596 100644 --- a/lua/CopilotChat/chat.lua +++ b/lua/CopilotChat/chat.lua @@ -49,7 +49,7 @@ local Chat = class(function(self, mark_ns, help, on_buf_create, config) end if not self.spinner then - self.spinner = Spinner(bufnr, mark_ns, 'copilot-chat', config.notify_done) + self.spinner = Spinner(bufnr, mark_ns, 'copilot-chat') else self.spinner.bufnr = bufnr end diff --git a/lua/CopilotChat/config.lua b/lua/CopilotChat/config.lua index 99380292..a0533eb8 100644 --- a/lua/CopilotChat/config.lua +++ b/lua/CopilotChat/config.lua @@ -76,8 +76,7 @@ local select = require('CopilotChat.select') ---@field prompts table? ---@field window CopilotChat.config.window? ---@field mappings CopilotChat.config.mappings? ----@field notify_done boolean? ---- + return { debug = false, -- Enable debug logging proxy = nil, -- [protocol://]host[:port] Use this proxy @@ -94,7 +93,6 @@ return { show_folds = true, -- Shows folds for sections in chat show_help = true, -- Shows help message as virtual lines when waiting for user input - notify_done = true, -- Notify when chat is done auto_follow_cursor = true, -- Auto-follow cursor in chat auto_insert_mode = false, -- Automatically enter insert mode when opening window and if auto follow cursor is enabled on new prompt clear_chat_on_new_prompt = false, -- Clears chat on every new prompt diff --git a/lua/CopilotChat/spinner.lua b/lua/CopilotChat/spinner.lua index cbb62365..1b00524f 100644 --- a/lua/CopilotChat/spinner.lua +++ b/lua/CopilotChat/spinner.lua @@ -20,13 +20,12 @@ local spinner_frames = { '⠏', } -local Spinner = class(function(self, bufnr, ns, title, notify_done) +local Spinner = class(function(self, bufnr, ns, title) self.ns = ns self.bufnr = bufnr self.title = title self.timer = nil self.index = 1 - self.b_notify_when_done = notify_done end) function Spinner:start() @@ -79,12 +78,8 @@ function Spinner:finish() timer:stop() timer:close() - -- Clear the extmark vim.api.nvim_buf_del_extmark(self.bufnr, self.ns, self.ns) - if self.b_notify_when_done then - vim.notify('Done!', vim.log.levels.INFO, { title = self.title }) - end end return Spinner From f049ad69d04e0706f53b964b544e758d748d8e93 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 27 Mar 2024 05:54:32 +0000 Subject: [PATCH 10/12] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lua/CopilotChat/spinner.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/lua/CopilotChat/spinner.lua b/lua/CopilotChat/spinner.lua index 1b00524f..ed184b61 100644 --- a/lua/CopilotChat/spinner.lua +++ b/lua/CopilotChat/spinner.lua @@ -79,7 +79,6 @@ function Spinner:finish() timer:close() vim.api.nvim_buf_del_extmark(self.bufnr, self.ns, self.ns) - end return Spinner From a626e4ecb5878b1fe960cd92d38a16f7dbc6dbdb Mon Sep 17 00:00:00 2001 From: d7ryLinux Date: Tue, 26 Mar 2024 23:23:23 -0700 Subject: [PATCH 11/12] remove config passed to chat --- lua/CopilotChat/chat.lua | 2 +- lua/CopilotChat/init.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/CopilotChat/chat.lua b/lua/CopilotChat/chat.lua index 1de2b596..331ec174 100644 --- a/lua/CopilotChat/chat.lua +++ b/lua/CopilotChat/chat.lua @@ -30,7 +30,7 @@ function CopilotChatFoldExpr(lnum, separator) return '=' end -local Chat = class(function(self, mark_ns, help, on_buf_create, config) +local Chat = class(function(self, mark_ns, help, on_buf_create) self.mark_ns = mark_ns self.help = help self.on_buf_create = on_buf_create diff --git a/lua/CopilotChat/init.lua b/lua/CopilotChat/init.lua index 5a1dd2ec..2162b42f 100644 --- a/lua/CopilotChat/init.lua +++ b/lua/CopilotChat/init.lua @@ -749,7 +749,7 @@ function M.setup(config) append(M.config.question_header .. M.config.separator .. '\n\n') state.chat:finish() - end, config) + end) tiktoken.setup() debuginfo.setup() From 2886f84cc038859d8535d321c400f7197e85e1e8 Mon Sep 17 00:00:00 2001 From: "Dung Duc Huynh (Kaka)" <870029+jellydn@users.noreply.github.com> Date: Wed, 27 Mar 2024 17:23:20 +0800 Subject: [PATCH 12/12] chore: remove new line --- README.md | 1 - lua/CopilotChat/config.lua | 1 - 2 files changed, 2 deletions(-) diff --git a/README.md b/README.md index 84936264..b54e4d4f 100644 --- a/README.md +++ b/README.md @@ -203,7 +203,6 @@ Also see [here](/lua/CopilotChat/config.lua): error_header = '**Error** ', -- Header to use for errors separator = '---', -- Separator to use in chat - show_folds = true, -- Shows folds for sections in chat show_help = true, -- Shows help message as virtual lines when waiting for user input auto_follow_cursor = true, -- Auto-follow cursor in chat diff --git a/lua/CopilotChat/config.lua b/lua/CopilotChat/config.lua index a0533eb8..06e6f0c6 100644 --- a/lua/CopilotChat/config.lua +++ b/lua/CopilotChat/config.lua @@ -76,7 +76,6 @@ local select = require('CopilotChat.select') ---@field prompts table? ---@field window CopilotChat.config.window? ---@field mappings CopilotChat.config.mappings? - return { debug = false, -- Enable debug logging proxy = nil, -- [protocol://]host[:port] Use this proxy