diff --git a/rplugin/python3/plugin.py b/rplugin/python3/plugin.py index 8b448ca7..d4c7baa8 100644 --- a/rplugin/python3/plugin.py +++ b/rplugin/python3/plugin.py @@ -45,12 +45,16 @@ def copilotChat(self, args: list[str]): prompt = prompts.EXPLAIN_SHORTCUT # Get code from the unnamed register - code = self.nvim.eval("getreg('\"')") + 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": # 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")