From ac3cec550afd62b00bfd6f385e9785cccbceaabd Mon Sep 17 00:00:00 2001 From: sudhanshu19102003 Date: Tue, 2 Jan 2024 14:21:38 +0530 Subject: [PATCH 1/3] Add vertical split for chat buffer to improve the UX --- rplugin/python3/plugin.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rplugin/python3/plugin.py b/rplugin/python3/plugin.py index 8b448ca7..996e5b6d 100644 --- a/rplugin/python3/plugin.py +++ b/rplugin/python3/plugin.py @@ -50,7 +50,11 @@ def copilotChat(self, args: list[str]): # Check if we're already in a chat buffer if self.nvim.eval("getbufvar(bufnr(), '&buftype')") != "nofile": # Create a new scratch buffer to hold the chat - self.nvim.command("enew") + self.nvim.command("vnew") + # Set it to the left side of the screen + self.nvim.command("wincmd L") + self.nvim.command("vertical resize 50%") + # Set the buffer type to nofile and hide it when it's not active self.nvim.command("setlocal buftype=nofile bufhidden=hide noswapfile") # Set filetype as markdown and wrap with linebreaks self.nvim.command("setlocal filetype=markdown wrap linebreak") From 7efc2e392ccd2c8ede4320fcedf8f933538f76c6 Mon Sep 17 00:00:00 2001 From: sudhanshu19102003 Date: Tue, 2 Jan 2024 15:28:38 +0530 Subject: [PATCH 2/3] nvim.current.eval("getreg('\"')") : it only contains the text from the most recent yank, delete, change, or put operation, if there were no changes it didn't gave any output so i changed it to nvim.current.buffer[:] --- rplugin/python3/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rplugin/python3/plugin.py b/rplugin/python3/plugin.py index 996e5b6d..a3143f4b 100644 --- a/rplugin/python3/plugin.py +++ b/rplugin/python3/plugin.py @@ -45,7 +45,7 @@ def copilotChat(self, args: list[str]): prompt = prompts.EXPLAIN_SHORTCUT # Get code from the unnamed register - code = self.nvim.eval("getreg('\"')") + code = text = self.nvim.current.buffer[:] file_type = self.nvim.eval("expand('%')").split(".")[-1] # Check if we're already in a chat buffer if self.nvim.eval("getbufvar(bufnr(), '&buftype')") != "nofile": From 9903acf5db2e2ca971c1e0fb510370800ee455c8 Mon Sep 17 00:00:00 2001 From: Sudhanshu Suryawanshi Date: Wed, 3 Jan 2024 15:22:55 +0530 Subject: [PATCH 3/3] Update plugin.py --- rplugin/python3/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rplugin/python3/plugin.py b/rplugin/python3/plugin.py index a3143f4b..d4c7baa8 100644 --- a/rplugin/python3/plugin.py +++ b/rplugin/python3/plugin.py @@ -45,7 +45,7 @@ def copilotChat(self, args: list[str]): prompt = prompts.EXPLAIN_SHORTCUT # Get code from the unnamed register - code = text = self.nvim.current.buffer[:] + code = self.nvim.current.buffer[:] file_type = self.nvim.eval("expand('%')").split(".")[-1] # Check if we're already in a chat buffer if self.nvim.eval("getbufvar(bufnr(), '&buftype')") != "nofile":