diff --git a/CHANGELOG.md b/CHANGELOG.md index c630af62..3b9543d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [1.6.1](https://github.com/CopilotC-Nvim/CopilotChat.nvim/compare/v1.6.0...v1.6.1) (2024-02-18) + + +### Bug Fixes + +* **code_actions:** Add check for 'No diagnostics available' in diagnostic prompts ([e46fa23](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/e46fa23fe7c43a29c849fb9b6a1d565d2e0b83f1)) + ## [1.6.0](https://github.com/CopilotC-Nvim/CopilotChat.nvim/compare/v1.5.0...v1.6.0) (2024-02-18) diff --git a/README.md b/README.md index 6edf20c0..08b4d95c 100644 --- a/README.md +++ b/README.md @@ -97,6 +97,38 @@ call remote#host#RegisterPlugin('python3', '/Users/huynhdung/.local/share/nvim/l 5. Restart `neovim` +### Vim-Plug + +Similar to the lazy setup, you can use the following configuration: + +```lua +Plug 'CopilotC-Nvim/CopilotChat.nvim' +call plug#end() + +local copilot_chat = require("CopilotChat") +copilot_chat.setup({ + debug = true, + show_help = "yes", + prompts = { + Explain = "Explain how it works by Japanese language.", + Review = "Review the following code and provide concise suggestions.", + Tests = "Briefly explain how the selected code works, then generate unit tests.", + Refactor = "Refactor the code to improve clarity and readability.", + }, + build = function() + vim.notify("Please update the remote plugins by running ':UpdateRemotePlugins', then restart Neovim.") + end, + event = "VeryLazy", +}) + +nnoremap cce CopilotChatExplain +nnoremap cct CopilotChatTests +xnoremap ccv :CopilotChatVisual +xnoremap ccx :CopilotChatInPlace +``` + +Credit to @treyhunner and @nekowasabi for the [configuration](https://github.com/CopilotC-Nvim/CopilotChat.nvim/discussions/46). + ### Manual 1. Put the files in the right place diff --git a/doc/CopilotChat.txt b/doc/CopilotChat.txt index 440f4577..0b157fa0 100644 --- a/doc/CopilotChat.txt +++ b/doc/CopilotChat.txt @@ -117,6 +117,40 @@ For example: 1. Restart `neovim` +VIM-PLUG ~ + +Similar to the lazy setup, you can use the following configuration: + +>lua + Plug 'CopilotC-Nvim/CopilotChat.nvim' + call plug#end() + + local copilot_chat = require("CopilotChat") + copilot_chat.setup({ + debug = true, + show_help = "yes", + prompts = { + Explain = "Explain how it works by Japanese language.", + Review = "Review the following code and provide concise suggestions.", + Tests = "Briefly explain how the selected code works, then generate unit tests.", + Refactor = "Refactor the code to improve clarity and readability.", + }, + build = function() + vim.notify("Please update the remote plugins by running ':UpdateRemotePlugins', then restart Neovim.") + end, + event = "VeryLazy", + }) + + nnoremap cce CopilotChatExplain + nnoremap cct CopilotChatTests + xnoremap ccv :CopilotChatVisual + xnoremap ccx :CopilotChatInPlace +< + +Credit to @treyhunner and @nekowasabi for the configuration +. + + MANUAL ~ 1. Put the files in the right place @@ -473,20 +507,22 @@ STARGAZERS OVER TIME ~ 2. Links *CopilotChat-links* 1. *All Contributors*: https://img.shields.io/badge/all_contributors-12-orange.svg?style=flat-square -2. *@jellydn*: -3. *Chat Demo*: https://i.gyazo.com/10fbd1543380d15551791c1a6dcbcd46.gif -4. *Explain Code Demo*: https://i.gyazo.com/e5031f402536a1a9d6c82b2c38d469e3.gif -5. *Generate tests*: https://i.gyazo.com/f285467d4b8d8f8fd36aa777305312ae.gif -6. *Fix diagnostic*: https://i.gyazo.com/4aff3fdbc5c3eee59cb68939546fa2be.gif -7. *Fold Demo*: https://i.gyazo.com/766fb3b6ffeb697e650fc839882822a8.gif -8. *In-place Demo*: https://i.gyazo.com/4a5badaa109cd483c1fc23d296325cb0.gif -9. *Toggle*: https://i.gyazo.com/db5af9e5d88cd2fd09f58968914fa521.gif -10. *Help action with Copilot Chat*: https://i.gyazo.com/146dc35368592ba9f5de047ddc4728ad.gif -11. *Select action base on user prompts*: https://i.gyazo.com/a9c41e6398591c2f1d1d872fd58a2c63.gif -12. *Layout*: https://i.gyazo.com/550daf6cbb729027ca9bd703c21af53e.png -13. *Debug Info*: https://i.gyazo.com/bf00e700bcee1b77bcbf7b516b552521.gif -14. *@ecosse3*: -15. *Stargazers over time*: https://starchart.cc/CopilotC-Nvim/CopilotChat.nvim.svg +2. *@treyhunner*: +3. *@nekowasabi*: +4. *@jellydn*: +5. *Chat Demo*: https://i.gyazo.com/10fbd1543380d15551791c1a6dcbcd46.gif +6. *Explain Code Demo*: https://i.gyazo.com/e5031f402536a1a9d6c82b2c38d469e3.gif +7. *Generate tests*: https://i.gyazo.com/f285467d4b8d8f8fd36aa777305312ae.gif +8. *Fix diagnostic*: https://i.gyazo.com/4aff3fdbc5c3eee59cb68939546fa2be.gif +9. *Fold Demo*: https://i.gyazo.com/766fb3b6ffeb697e650fc839882822a8.gif +10. *In-place Demo*: https://i.gyazo.com/4a5badaa109cd483c1fc23d296325cb0.gif +11. *Toggle*: https://i.gyazo.com/db5af9e5d88cd2fd09f58968914fa521.gif +12. *Help action with Copilot Chat*: https://i.gyazo.com/146dc35368592ba9f5de047ddc4728ad.gif +13. *Select action base on user prompts*: https://i.gyazo.com/a9c41e6398591c2f1d1d872fd58a2c63.gif +14. *Layout*: https://i.gyazo.com/550daf6cbb729027ca9bd703c21af53e.png +15. *Debug Info*: https://i.gyazo.com/bf00e700bcee1b77bcbf7b516b552521.gif +16. *@ecosse3*: +17. *Stargazers over time*: https://starchart.cc/CopilotC-Nvim/CopilotChat.nvim.svg Generated by panvimdoc diff --git a/lua/CopilotChat/code_actions.lua b/lua/CopilotChat/code_actions.lua index 561477f5..78685cdc 100644 --- a/lua/CopilotChat/code_actions.lua +++ b/lua/CopilotChat/code_actions.lua @@ -11,6 +11,10 @@ local user_prompt_actions = {} local function generate_fix_diagnostic_prompt() local diagnostic = utils.get_diagnostics() + if diagnostic == 'No diagnostics available' then + return diagnostic + end + local file_name = vim.fn.expand('%:t') local line_number = vim.fn.line('.') return 'Please assist with fixing the following diagnostic issue in file: "' @@ -23,6 +27,10 @@ end local function generate_explain_diagnostic_prompt() local diagnostic = utils.get_diagnostics() + if diagnostic == 'No diagnostics available' then + return diagnostic + end + local file_name = vim.fn.expand('%:t') local line_number = vim.fn.line('.') return 'Please explain the following diagnostic issue in file: "' diff --git a/rplugin/python3/CopilotChat/handlers/chat_handler.py b/rplugin/python3/CopilotChat/handlers/chat_handler.py index bd5ff58d..153497c0 100644 --- a/rplugin/python3/CopilotChat/handlers/chat_handler.py +++ b/rplugin/python3/CopilotChat/handlers/chat_handler.py @@ -247,6 +247,25 @@ def _add_chat_messages( self.copilot.authenticate() last_line_col = 0 + self.nvim.exec_lua( + 'require("CopilotChat.utils").log_info(...)', + f"System prompt: {system_prompt}", + ) + self.nvim.exec_lua( + 'require("CopilotChat.utils").log_info(...)', f"Prompt: {prompt}" + ) + self.nvim.exec_lua( + 'require("CopilotChat.utils").log_info(...)', f"Code: {code}" + ) + self.nvim.exec_lua( + 'require("CopilotChat.utils").log_info(...)', f"File type: {file_type}" + ) + self.nvim.exec_lua( + 'require("CopilotChat.utils").log_info(...)', f"Model: {model}" + ) + self.nvim.exec_lua( + 'require("CopilotChat.utils").log_info(...)', "Asking Copilot" + ) for token in self.copilot.ask( system_prompt, prompt, code, language=cast(str, file_type), model=model ): @@ -266,6 +285,9 @@ def _add_chat_messages( last_line_col += len(token.encode("utf-8")) if "\n" in token: last_line_col = 0 + self.nvim.exec_lua( + 'require("CopilotChat.utils").log_info(...)', "Copilot answered" + ) def _add_end_separator(self, model: str, disable_separators: bool = False): current_datetime = datetime.now().strftime("%Y-%m-%d %H:%M:%S") diff --git a/version.txt b/version.txt index dc1e644a..9c6d6293 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.6.0 +1.6.1