diff --git a/.all-contributorsrc b/.all-contributorsrc index 0a5effab..fc6bbd7e 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -46,6 +46,41 @@ "avatar_url": "https://avatars.githubusercontent.com/u/9963717?v=4", "profile": "https://www.linkedin.com/in/guruprakashrajakkannu/", "contributions": ["code"] + }, + { + "login": "kristofka", + "name": "kristofka", + "avatar_url": "https://avatars.githubusercontent.com/u/140354?v=4", + "profile": "https://github.com/kristofka", + "contributions": ["code"] + }, + { + "login": "PostCyberPunk", + "name": "PostCyberPunk", + "avatar_url": "https://avatars.githubusercontent.com/u/134976996?v=4", + "profile": "https://github.com/PostCyberPunk", + "contributions": ["doc"] + }, + { + "login": "ktns", + "name": "Katsuhiko Nishimra", + "avatar_url": "https://avatars.githubusercontent.com/u/1302759?v=4", + "profile": "https://github.com/ktns", + "contributions": ["code"] + }, + { + "login": "errnoh", + "name": "Erno Hopearuoho", + "avatar_url": "https://avatars.githubusercontent.com/u/373946?v=4", + "profile": "https://github.com/errnoh", + "contributions": ["code"] + }, + { + "login": "shaungarwood", + "name": "Shaun Garwood", + "avatar_url": "https://avatars.githubusercontent.com/u/4156525?v=4", + "profile": "https://github.com/shaungarwood", + "contributions": ["code"] } ], "contributorsPerLine": 7, @@ -53,5 +88,5 @@ "repoType": "github", "repoHost": "https://github.com", "projectName": "CopilotChat.nvim", - "projectOwner": "jellydn" + "projectOwner": "CopilotC-Nvim" } diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 00000000..ce9dcccd --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,3 @@ +# These are supported funding model platforms + +github: [acheong08, jellydn] diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8123c9e1..1b355bf7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,10 +16,15 @@ jobs: docs: runs-on: ubuntu-latest + permissions: + # Give the default GITHUB_TOKEN write permission to commit and push the changed files back to the repository. + contents: write name: pandoc to vimdoc if: ${{ github.ref == 'refs/heads/main' }} steps: - uses: actions/checkout@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} - name: panvimdoc uses: kdheepak/panvimdoc@main with: @@ -31,6 +36,7 @@ jobs: commit_user_name: "github-actions[bot]" commit_user_email: "github-actions[bot]@users.noreply.github.com" commit_author: "github-actions[bot] " + commit_options: "--no-verify" test: name: Run Test diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9860c202..a0cc66fc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,7 +1,16 @@ name: Release on: push: + branches: + - release pull_request: + branches: + - main + - release + +permissions: + contents: write + pull-requests: write jobs: release: @@ -13,6 +22,7 @@ jobs: with: release-type: simple package-name: CopilotChat.nvim + token: ${{ secrets.GITHUB_TOKEN }} - uses: actions/checkout@v3 - name: tag stable versions if: ${{ steps.release.outputs.release_created }} diff --git a/.github/workflows/todo.yml b/.github/workflows/todo.yml new file mode 100644 index 00000000..cc131582 --- /dev/null +++ b/.github/workflows/todo.yml @@ -0,0 +1,10 @@ +name: "Run TODO to Issue" + +on: ["push"] +jobs: + build: + runs-on: "ubuntu-latest" + steps: + - uses: "actions/checkout@v3" + - name: "TODO to Issue" + uses: "alstr/todo-to-issue-action@v4" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 93e78079..b83089ed 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,10 +3,6 @@ repos: rev: "23.10.0" hooks: - id: black - - repo: https://github.com/PyCQA/isort - rev: "5.12.0" - hooks: - - id: isort - repo: https://github.com/PyCQA/flake8 rev: "6.1.0" hooks: diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c095c00..7aa3208b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,57 +1,70 @@ # Changelog -## [1.2.0](https://github.com/jellydn/CopilotChat.nvim/compare/v1.1.0...v1.2.0) (2024-02-04) +## [1.3.0](https://github.com/CopilotC-Nvim/CopilotChat.nvim/compare/v1.2.0...v1.3.0) (2024-02-14) ### Features -* show date time and additional information on end separator ([#53](https://github.com/jellydn/CopilotChat.nvim/issues/53)) ([b8d0a9d](https://github.com/jellydn/CopilotChat.nvim/commit/b8d0a9d0e0824ff3b643a2652202be2a51b37dbc)) +* add reset buffer for CopilotChatReset command ([bf6d29f](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/bf6d29f3bde05c8a2b0f127737af13cc6df73b9a)) +* CopilotChatReset command ([528e6b4](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/528e6b4b33737e4863fccdb7ed2c6d7aec4f2029)) ### Bug Fixes -* handle get remote plugin path on Windows ([0b917f6](https://github.com/jellydn/CopilotChat.nvim/commit/0b917f633eaef621d293f344965e9e0545be9a80)) - -## [1.1.0](https://github.com/jellydn/CopilotChat.nvim/compare/v1.0.0...v1.1.0) (2024-02-04) +* Include more info about refusal reason ([46bdf01](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/46bdf018069072a8a43c468ee1cede45536909a3)) +## [1.2.0](https://github.com/CopilotC-Nvim/CopilotChat.nvim/compare/v1.1.0...v1.2.0) (2024-02-13) ### Features -* add CopilotChatDebugInfo command ([#51](https://github.com/jellydn/CopilotChat.nvim/issues/51)) ([89b6276](https://github.com/jellydn/CopilotChat.nvim/commit/89b6276e995de2e05ea391a9d1045676737c93bd)) - -## 1.0.0 (2024-02-03) +- restructure for pynvim 0.4.3 backwards compatibility ([#45](https://github.com/CopilotC-Nvim/CopilotChat.nvim/issues/45)) ([52350c7](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/52350c78dbcfcb3acabf3478276ad9a87ebbfd26)) +## [1.1.0](https://github.com/CopilotC-Nvim/CopilotChat.nvim/compare/v1.0.1...v1.1.0) (2024-02-10) -### ⚠ BREAKING CHANGES +### Features -* drop new buffer mode +- **chat_handler:** show extra info only once ([589a453](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/589a4538d648c8723d839ca963a47a6176be3c78)) +- Environment variables for proxy (HTTPS_PROXY and ALL_PROXY) ([043e731](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/043e731005278649dbdf1d5866c6e3c7719f1202)) +- Proxy support ([19a8088](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/19a8088c171cb956fd553200b77c8dbbe76707b6)) -### Features +### Bug Fixes -* add a note for help user to continue the chat ([8a80ee7](https://github.com/jellydn/CopilotChat.nvim/commit/8a80ee7d3f9d0dcb65b315255d629c2cd8263dac)) -* add CCExplain command ([640f361](https://github.com/jellydn/CopilotChat.nvim/commit/640f361a54be51e7c479257c374d4a26d8fcd31d)) -* add CCTests command ([b34a78f](https://github.com/jellydn/CopilotChat.nvim/commit/b34a78f05ebe65ca093e4dc4b66de9120a681f4c)) -* add configuration options for wrap and filetype ([b4c6e76](https://github.com/jellydn/CopilotChat.nvim/commit/b4c6e760232ec54d4632edef3869e1a05ec61751)) -* add CopilotChatToggleLayout ([07988b9](https://github.com/jellydn/CopilotChat.nvim/commit/07988b95a412756169016e991dabcf190a930c7e)) -* add debug flag ([d0dbd4c](https://github.com/jellydn/CopilotChat.nvim/commit/d0dbd4c6fb9be75ccaa591b050198d40c097f423)) -* add health check ([974f14f](https://github.com/jellydn/CopilotChat.nvim/commit/974f14f0d0978d858cbe0126568f30fd63262cb6)) -* add new keymap to get previous user prompt ([6e7e80f](https://github.com/jellydn/CopilotChat.nvim/commit/6e7e80f118c589a009fa1703a284ad292260e3a0)) -* set filetype to markdown and text wrapping ([9b19d51](https://github.com/jellydn/CopilotChat.nvim/commit/9b19d51deacdf5c958933e99a2e75ebe4c968a9b)) -* show chat in markdown format ([9c14152](https://github.com/jellydn/CopilotChat.nvim/commit/9c141523de12e723b1d72d95760f2daddcecd1d9)) +- Wacky indentation in readme ([c5bf963](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/c5bf963f4702a8a94aa97de2e6205796cb381ae5)) +## [1.0.1](https://github.com/CopilotC-Nvim/CopilotChat.nvim/compare/v1.0.0...v1.0.1) (2024-02-08) ### Bug Fixes -* **ci:** generate doc ([6287fd4](https://github.com/jellydn/CopilotChat.nvim/commit/6287fd452d83d43a739d4c7c7a5524537032fc5d)) -* Close spinner if the buffer does not exist ([#11](https://github.com/jellydn/CopilotChat.nvim/issues/11)) ([0ea238d](https://github.com/jellydn/CopilotChat.nvim/commit/0ea238d7be9c7872dd9932a56d3521531b2297db)) -* remove LiteralString, use Any for fixing issue on Python 3.10 ([b68c352](https://github.com/jellydn/CopilotChat.nvim/commit/b68c3522d03c8ac9a332169c56e725b69a43b07c)), closes [#45](https://github.com/jellydn/CopilotChat.nvim/issues/45) +- multi-byte languages by manually tracking last_line_col for buf_set_text ([20a4234](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/20a4234a542deef1a128aca4d0dd7e8d429a1f2a)) +## 1.0.0 (2024-02-06) -### Reverts +### ⚠ BREAKING CHANGES -* change back to CopilotChat command ([e304f79](https://github.com/jellydn/CopilotChat.nvim/commit/e304f792a5fbba412c2a5a1f717ec7e2ab12e5b0)) +- disable extra info as default +- drop new buffer mode +### Features -### Code Refactoring +- add a note for help user to continue the chat ([8a80ee7](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/8a80ee7d3f9d0dcb65b315255d629c2cd8263dac)) +- add CCExplain command ([640f361](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/640f361a54be51e7c479257c374d4a26d8fcd31d)) +- add CCTests command ([b34a78f](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/b34a78f05ebe65ca093e4dc4b66de9120a681f4c)) +- add configuration options for wrap and filetype ([b4c6e76](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/b4c6e760232ec54d4632edef3869e1a05ec61751)) +- add CopilotChatDebugInfo command ([#51](https://github.com/CopilotC-Nvim/CopilotChat.nvim/issues/51)) ([89b6276](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/89b6276e995de2e05ea391a9d1045676737c93bd)) +- add CopilotChatToggleLayout ([07988b9](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/07988b95a412756169016e991dabcf190a930c7e)) +- add debug flag ([d0dbd4c](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/d0dbd4c6fb9be75ccaa591b050198d40c097f423)) +- add health check ([974f14f](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/974f14f0d0978d858cbe0126568f30fd63262cb6)) +- add new keymap to get previous user prompt ([6e7e80f](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/6e7e80f118c589a009fa1703a284ad292260e3a0)) +- set filetype to markdown and text wrapping ([9b19d51](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/9b19d51deacdf5c958933e99a2e75ebe4c968a9b)) +- show chat in markdown format ([9c14152](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/9c141523de12e723b1d72d95760f2daddcecd1d9)) +- show date time and additional information on end separator ([#53](https://github.com/CopilotC-Nvim/CopilotChat.nvim/issues/53)) ([b8d0a9d](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/b8d0a9d0e0824ff3b643a2652202be2a51b37dbc)) + +### Bug Fixes -* drop new buffer mode ([0a30b7c](https://github.com/jellydn/CopilotChat.nvim/commit/0a30b7cfbd8b52bf8a9e4cd96dcade4995e6eb3a)) +- **ci:** generate doc ([6287fd4](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/6287fd452d83d43a739d4c7c7a5524537032fc5d)) +- **ci:** generate vimdoc on main branch ([94fb10c](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/94fb10cb65bc32cc0c1d96c93ec2d94c4f5d40eb)) +- **ci:** setup release action ([2f1e046](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/2f1e0466af30c26fdcd2b94d331ea4004d32bb07)) +- **ci:** skip git hook on vimdoc ([94fb10c](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/94fb10cb65bc32cc0c1d96c93ec2d94c4f5d40eb)) +- Close spinner if the buffer does not exist ([#11](https://github.com/CopilotC-Nvim/CopilotChat.nvim/issues/11)) ([0ea238d](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/0ea238d7be9c7872dd9932a56d3521531b2297db)) +- handle get remote plugin path on Windows ([0b917f6](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/0b917f633eaef621d293f344965e9e0545be9a80)) +- remove LiteralString, use Any for fixing issue on Python 3.10 ([b68c352](https://github.com/CopilotC-Nvim/CopilotChat.nvim/commit/b68c3522d03c8ac9a332169c56e725b69a43b07c)), closes [#45](https://github.com/CopilotC-Nvim/CopilotChat.nvim/issues/45) diff --git a/README.md b/README.md index 71812b99..5a522b6d 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,19 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-6-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-11-orange.svg?style=flat-square)](#contributors-) > [!NOTE] > A new command, `CopilotChatInPlace` has been introduced. It functions like the ChatGPT plugin. Please run ":UpdateRemotePlugins" command and restart Neovim before starting a chat with Copilot. To stay updated on our roadmap, please join our [Discord](https://discord.gg/vy6hJsTWaZ) community. +## Prerequisites + +Ensure you have the following installed: + +- Python 3.10 or later + ## Authentication It will prompt you with instructions on your first start. If you already have `Copilot.vim` or `Copilot.lua`, it will work automatically. @@ -24,11 +30,12 @@ It will prompt you with instructions on your first start. If you already have `C ```lua return { { - "jellydn/CopilotChat.nvim", - dependencies = { "zbirenbaum/copilot.lua" }, -- Or { "github/copilot.vim" } + "CopilotC-Nvim/CopilotChat.nvim", opts = { show_help = "yes", -- Show help text for CopilotChatInPlace, default: yes debug = false, -- Enable or disable debug mode, the log file will be in ~/.local/state/nvim/CopilotChat.nvim.log + disable_extra_info = 'no', -- Disable extra information (e.g: system prompt) in the response. + -- proxy = "socks5://127.0.0.1:3000", -- Proxies requests via https or socks. }, build = function() vim.notify("Please update the remote plugins by running ':UpdateRemotePlugins', then restart Neovim.") @@ -60,7 +67,7 @@ For example: ```vim " python3 plugins -call remote#host#RegisterPlugin('python3', '/Users/huynhdung/.local/share/nvim/lazy/CopilotChat.nvim/rplugin/python3/copilot-plugin.py', [ +call remote#host#RegisterPlugin('python3', '/Users/huynhdung/.local/share/nvim/lazy/CopilotChat.nvim/rplugin/python3/CopilotChat', [ \ {'sync': v:false, 'name': 'CopilotChat', 'type': 'command', 'opts': {'nargs': '1'}}, \ {'sync': v:false, 'name': 'CopilotChatVisual', 'type': 'command', 'opts': {'nargs': '1', 'range': ''}}, \ {'sync': v:false, 'name': 'CopilotChatInPlace', 'type': 'command', 'opts': {'nargs': '*', 'range': ''}}, @@ -76,7 +83,7 @@ call remote#host#RegisterPlugin('python3', '/Users/huynhdung/.local/share/nvim/l 1. Put the files in the right place ``` -$ git clone https://github.com/jellydn/CopilotChat.nvim +$ git clone https://github.com/CopilotC-Nvim/CopilotChat.nvim $ cd CopilotChat.nvim $ cp -r --backup=nil rplugin ~/.config/nvim/ ``` @@ -111,7 +118,7 @@ You have the capability to expand the prompts to create more versatile commands: ```lua return { - "jellydn/CopilotChat.nvim", + "CopilotC-Nvim/CopilotChat.nvim", opts = { debug = true, show_help = "yes", @@ -174,7 +181,7 @@ For further reference, you can view @jellydn's [configuration](https://github.co [![In-place Demo](https://i.gyazo.com/4a5badaa109cd483c1fc23d296325cb0.gif)](https://gyazo.com/4a5badaa109cd483c1fc23d296325cb0) -## Receipts +## Tips ### Debugging with `:messages` and `:CopilotChatDebugInfo` @@ -188,7 +195,7 @@ A special thanks to @ecosse3 for the configuration of [which-key](https://github ```lua { - "jellydn/CopilotChat.nvim", + "CopilotC-Nvim/CopilotChat.nvim", event = "VeryLazy", opts = { prompts = { @@ -249,12 +256,41 @@ Follow the example below to create a simple input for CopilotChat. }, ``` -## Roadmap +### Add same keybinds in both visual and normal mode + +```lua + { + "CopilotC-Nvim/CopilotChat.nvim", + keys = + function() + local keybinds={ + --add your custom keybinds here + } + -- change prompt and keybinds as per your need + local my_prompts = { + {prompt = "In Neovim.",desc = "Neovim",key = "n"}, + {prompt = "Help with this",desc = "Help",key = "h"}, + {prompt = "Simplify and imporve readablilty",desc = "Simplify",key = "s"}, + {prompt = "Optimize the code to improve perfomance and readablilty.",desc = "Optimize",key = "o"}, + {prompt = "Find possible errors and fix them for me",desc = "Fix",key = "f"}, + {prompt = "Explain in detail",desc = "Explain",key = "e"}, + {prompt = "Write a shell scirpt",desc = "Shell",key = "S"}, + } + -- you can change cc to your desired keybind prefix + for _,v in pairs(my_prompts) do + table.insert(keybinds,{ "cc"..v.key, ":CopilotChatVisual "..v.prompt.."", mode = "x", desc = "CopilotChat - "..v.desc }) + table.insert(keybinds,{ "cc"..v.key, "CopilotChat "..v.prompt.."", desc = "CopilotChat - "..v.desc }) + end + return keybinds + end, + }, +``` + +## Roadmap (Wishlist) -- Translation to pure Lua -- Tokenizer - Use vector encodings to automatically select code -- Sub commands - See [issue #5](https://github.com/gptlang/CopilotChat.nvim/issues/5) +- Treesitter integration for function definitions +- General QOL improvements ## Development @@ -278,12 +314,19 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d - - - - - - + + + + + + + + + + + + +
gptlang
gptlang

💻 📖
Dung Duc Huynh (Kaka)
Dung Duc Huynh (Kaka)

💻 📖
Ahmed Haracic
Ahmed Haracic

💻
Trí Thiện Nguyễn
Trí Thiện Nguyễn

💻
He Zhizhou
He Zhizhou

💻
Guruprakash Rajakkannu
Guruprakash Rajakkannu

💻
gptlang
gptlang

💻 📖
Dung Duc Huynh (Kaka)
Dung Duc Huynh (Kaka)

💻 📖
Ahmed Haracic
Ahmed Haracic

💻
Trí Thiện Nguyễn
Trí Thiện Nguyễn

💻
He Zhizhou
He Zhizhou

💻
Guruprakash Rajakkannu
Guruprakash Rajakkannu

💻
kristofka
kristofka

💻
PostCyberPunk
PostCyberPunk

📖
Katsuhiko Nishimra
Katsuhiko Nishimra

💻
Erno Hopearuoho
Erno Hopearuoho

💻
Shaun Garwood
Shaun Garwood

💻
@@ -293,4 +336,8 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d -This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! +This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind are welcome! + +### Stargazers over time + +[![Stargazers over time](https://starchart.cc/CopilotC-Nvim/CopilotChat.nvim.svg)](https://starchart.cc/CopilotC-Nvim/CopilotChat.nvim) diff --git a/cspell-tool.txt b/cspell-tool.txt index 400bb5a2..3893944c 100644 --- a/cspell-tool.txt +++ b/cspell-tool.txt @@ -1,10 +1,17 @@ +keymap pynvim nvim nargs +rplugin +Rplugin +checkhealth +bufnr +noremap Neovim healthcheck bufexists vlog +sysname vararg tjdevries neovim @@ -16,14 +23,19 @@ lineinfo currentline echom tiktoken -jellydn -zbirenbaum -rplugin +Nvim +huynhdung +Autocmd jellydn's ecosse pcall -noremap nowait +keybinds +imporve +readablilty +perfomance +scirpt +keybind gptlang Huynh Haracic @@ -32,20 +44,19 @@ Nguyễn Zhizhou Guruprakash Rajakkannu +kristofka vsplit mypynvim -Nvim AUTOCMD -Autocmd getreg -bufnr autocmd dotenv machineid winnr Nightfly -keymaps +foldmethod linebreak +keymaps diffthis diffoff conceallevel @@ -62,9 +73,4 @@ autocmds shrinked zindex noautocmd -roleplay -vusted -luarocks -isort -checkhealth -sysname \ No newline at end of file +roleplay \ No newline at end of file diff --git a/doc/CopilotChat.txt b/doc/CopilotChat.txt index 1ff3f1bd..e6a327ea 100644 --- a/doc/CopilotChat.txt +++ b/doc/CopilotChat.txt @@ -1,14 +1,15 @@ -*CopilotChat.txt* For NVIM v0.8.0 Last change: 2024 February 04 +*CopilotChat.txt* For NVIM v0.8.0 Last change: 2024 February 14 ============================================================================== Table of Contents *CopilotChat-table-of-contents* 1. Copilot Chat for Neovim |CopilotChat-copilot-chat-for-neovim| + - Prerequisites |CopilotChat-copilot-chat-for-neovim-prerequisites| - Authentication |CopilotChat-copilot-chat-for-neovim-authentication| - Installation |CopilotChat-copilot-chat-for-neovim-installation| - Usage |CopilotChat-copilot-chat-for-neovim-usage| - - Receipts |CopilotChat-copilot-chat-for-neovim-receipts| - - Roadmap |CopilotChat-copilot-chat-for-neovim-roadmap| + - Tips |CopilotChat-copilot-chat-for-neovim-tips| + - Roadmap (Wishlist)|CopilotChat-copilot-chat-for-neovim-roadmap-(wishlist)| - Development |CopilotChat-copilot-chat-for-neovim-development| - Contributors ✨ |CopilotChat-copilot-chat-for-neovim-contributors-✨| @@ -23,6 +24,13 @@ Table of Contents *CopilotChat-table-of-contents* Neovim before starting a chat with Copilot. To stay updated on our roadmap, please join our Discord community. +PREREQUISITES *CopilotChat-copilot-chat-for-neovim-prerequisites* + +Ensure you have the following installed: + +- Python 3.10 or later + + AUTHENTICATION *CopilotChat-copilot-chat-for-neovim-authentication* It will prompt you with instructions on your first start. If you already have @@ -41,11 +49,12 @@ LAZY.NVIM ~ >lua return { { - "jellydn/CopilotChat.nvim", - dependencies = { "zbirenbaum/copilot.lua" }, -- Or { "github/copilot.vim" } + "CopilotC-Nvim/CopilotChat.nvim", opts = { show_help = "yes", -- Show help text for CopilotChatInPlace, default: yes debug = false, -- Enable or disable debug mode, the log file will be in ~/.local/state/nvim/CopilotChat.nvim.log + disable_extra_info = 'no', -- Disable extra information (e.g: system prompt) in the response. + -- proxy = "socks5://127.0.0.1:3000", -- Proxies requests via https or socks. }, build = function() vim.notify("Please update the remote plugins by running ':UpdateRemotePlugins', then restart Neovim.") @@ -77,7 +86,7 @@ For example: >vim " python3 plugins - call remote#host#RegisterPlugin('python3', '/Users/huynhdung/.local/share/nvim/lazy/CopilotChat.nvim/rplugin/python3/copilot-plugin.py', [ + call remote#host#RegisterPlugin('python3', '/Users/huynhdung/.local/share/nvim/lazy/CopilotChat.nvim/rplugin/python3/CopilotChat', [ \ {'sync': v:false, 'name': 'CopilotChat', 'type': 'command', 'opts': {'nargs': '1'}}, \ {'sync': v:false, 'name': 'CopilotChatVisual', 'type': 'command', 'opts': {'nargs': '1', 'range': ''}}, \ {'sync': v:false, 'name': 'CopilotChatInPlace', 'type': 'command', 'opts': {'nargs': '*', 'range': ''}}, @@ -94,7 +103,7 @@ MANUAL ~ 1. Put the files in the right place > - $ git clone https://github.com/jellydn/CopilotChat.nvim + $ git clone https://github.com/CopilotC-Nvim/CopilotChat.nvim $ cd CopilotChat.nvim $ cp -r --backup=nil rplugin ~/.config/nvim/ < @@ -133,7 +142,7 @@ commands: >lua return { - "jellydn/CopilotChat.nvim", + "CopilotC-Nvim/CopilotChat.nvim", opts = { debug = true, show_help = "yes", @@ -199,7 +208,7 @@ IN-PLACE CHAT POPUP ~ -RECEIPTS *CopilotChat-copilot-chat-for-neovim-receipts* +TIPS *CopilotChat-copilot-chat-for-neovim-tips* DEBUGGING WITH :MESSAGES AND :COPILOTCHATDEBUGINFO ~ @@ -218,7 +227,7 @@ A special thanks to @ecosse3 for the configuration of which-key >lua { - "jellydn/CopilotChat.nvim", + "CopilotC-Nvim/CopilotChat.nvim", event = "VeryLazy", opts = { prompts = { @@ -281,12 +290,42 @@ Follow the example below to create a simple input for CopilotChat. < -ROADMAP *CopilotChat-copilot-chat-for-neovim-roadmap* +ADD SAME KEYBINDS IN BOTH VISUAL AND NORMAL MODE ~ + +>lua + { + "CopilotC-Nvim/CopilotChat.nvim", + keys = + function() + local keybinds={ + --add your custom keybinds here + } + -- change prompt and keybinds as per your need + local my_prompts = { + {prompt = "In Neovim.",desc = "Neovim",key = "n"}, + {prompt = "Help with this",desc = "Help",key = "h"}, + {prompt = "Simplify and imporve readablilty",desc = "Simplify",key = "s"}, + {prompt = "Optimize the code to improve perfomance and readablilty.",desc = "Optimize",key = "o"}, + {prompt = "Find possible errors and fix them for me",desc = "Fix",key = "f"}, + {prompt = "Explain in detail",desc = "Explain",key = "e"}, + {prompt = "Write a shell scirpt",desc = "Shell",key = "S"}, + } + -- you can change cc to your desired keybind prefix + for _,v in pairs(my_prompts) do + table.insert(keybinds,{ "cc"..v.key, ":CopilotChatVisual "..v.prompt.."", mode = "x", desc = "CopilotChat - "..v.desc }) + table.insert(keybinds,{ "cc"..v.key, "CopilotChat "..v.prompt.."", desc = "CopilotChat - "..v.desc }) + end + return keybinds + end, + }, +< + + +ROADMAP (WISHLIST) *CopilotChat-copilot-chat-for-neovim-roadmap-(wishlist)* -- Translation to pure Lua -- Tokenizer - Use vector encodings to automatically select code -- Sub commands - See issue #5 +- Treesitter integration for function definitions +- General QOL improvements DEVELOPMENT *CopilotChat-copilot-chat-for-neovim-development* @@ -309,14 +348,19 @@ CONTRIBUTORS ✨ *CopilotChat-copilot-chat-for-neovim-contributors-✨* Thanks goes to these wonderful people (emoji key ): -gptlang💻 📖Dung Duc Huynh (Kaka)💻 📖Ahmed Haracic💻Trí Thiện Nguyễn💻He Zhizhou💻Guruprakash Rajakkannu💻This project follows the all-contributors +gptlang💻 📖Dung Duc Huynh (Kaka)💻 📖Ahmed Haracic💻Trí Thiện Nguyễn💻He Zhizhou💻Guruprakash Rajakkannu💻kristofka💻PostCyberPunk📖Katsuhiko Nishimra💻Erno Hopearuoho💻Shaun Garwood💻This project follows the all-contributors specification. -Contributions of any kind welcome! +Contributions of any kind are welcome! + + +STARGAZERS OVER TIME ~ + + ============================================================================== 2. Links *CopilotChat-links* -1. *All Contributors*: https://img.shields.io/badge/all_contributors-6-orange.svg?style=flat-square +1. *All Contributors*: https://img.shields.io/badge/all_contributors-11-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 @@ -325,6 +369,7 @@ Contributions of any kind welcome! 7. *In-place Demo*: https://i.gyazo.com/4a5badaa109cd483c1fc23d296325cb0.gif 8. *Debug Info*: https://i.gyazo.com/bf00e700bcee1b77bcbf7b516b552521.gif 9. *@ecosse3*: +10. *Stargazers over time*: https://starchart.cc/CopilotC-Nvim/CopilotChat.nvim.svg Generated by panvimdoc diff --git a/lua/CopilotChat/health.lua b/lua/CopilotChat/health.lua index 6677898c..5893f812 100644 --- a/lua/CopilotChat/health.lua +++ b/lua/CopilotChat/health.lua @@ -24,7 +24,8 @@ end --- Run a python command and handle potential errors ---@param command string local function run_python_command(command) - return run_command_on_executable('python3', command) + local python3_host_prog = vim.g['python3_host_prog'] + return run_command_on_executable(python3_host_prog or 'python3', command) end -- Add health check for python3 and pynvim @@ -38,8 +39,8 @@ function M.check() end local major, minor = string.match(python_version, 'Python (%d+)%.(%d+)') - if not (major and minor and tonumber(major) >= 3 and tonumber(minor) >= 7) then - warn('Python version 3.7 or higher is required') + if not (major and minor and tonumber(major) >= 3 and tonumber(minor) >= 10) then + warn('Python version 3.10 or higher is required') else ok('Python version ' .. major .. '.' .. minor .. ' is supported') end @@ -52,7 +53,9 @@ function M.check() return end - file:write('import pynvim; print(pynvim.__version__)') + file:write( + 'import pynvim; v = pynvim.VERSION; print("{0}.{1}.{2}".format(v.major, v.minor, v.patch))' + ) file:close() -- Run the temporary Python script and capture the output @@ -66,7 +69,7 @@ function M.check() -- Delete the temporary Python script os.remove(temp_file) - if pynvim_version ~= '0.5.0' then + if vim.version.lt(pynvim_version, '0.4.3') then warn('pynvim version ' .. pynvim_version .. ' is not supported') else ok('pynvim version ' .. pynvim_version .. ' is supported') diff --git a/lua/CopilotChat/init.lua b/lua/CopilotChat/init.lua index 85510023..1542e0f9 100644 --- a/lua/CopilotChat/init.lua +++ b/lua/CopilotChat/init.lua @@ -4,7 +4,7 @@ local M = {} local default_prompts = { Explain = 'Explain how it works.', - Tests = 'Briefly how selected code works then generate unit tests.', + Tests = 'Briefly explain how selected code works then generate unit tests.', } _COPILOT_CHAT_GLOBAL_CONFIG = {} @@ -12,10 +12,13 @@ _COPILOT_CHAT_GLOBAL_CONFIG = {} -- Set up the plugin ---@param options (table | nil) -- - show_help: ('yes' | 'no') default: 'yes'. +-- - disable_extra_info: ('yes' | 'no') default: 'yes'. -- - prompts: (table?) default: default_prompts. -- - debug: (boolean?) default: false. M.setup = function(options) vim.g.copilot_chat_show_help = options and options.show_help or 'yes' + vim.g.copilot_chat_disable_separators = options and options.disable_extra_info or 'yes' + vim.g.copilot_chat_proxy = options and options.proxy or '' local debug = options and options.debug or false _COPILOT_CHAT_GLOBAL_CONFIG.debug = debug diff --git a/rplugin/python3/CopilotChat/__init__.py b/rplugin/python3/CopilotChat/__init__.py new file mode 100644 index 00000000..446ecc17 --- /dev/null +++ b/rplugin/python3/CopilotChat/__init__.py @@ -0,0 +1 @@ +from .copilot_plugin import CopilotPlugin as CopilotPlugin diff --git a/rplugin/python3/copilot.py b/rplugin/python3/CopilotChat/copilot.py similarity index 87% rename from rplugin/python3/copilot.py rename to rplugin/python3/CopilotChat/copilot.py index ee471b64..c03e7927 100644 --- a/rplugin/python3/copilot.py +++ b/rplugin/python3/CopilotChat/copilot.py @@ -4,11 +4,11 @@ import uuid from typing import Dict, List +import CopilotChat.prompts as prompts +import CopilotChat.typings as typings +import CopilotChat.utilities as utilities import dotenv -import prompts import requests -import typings -import utilities from prompt_toolkit import PromptSession from prompt_toolkit.history import InMemoryHistory @@ -22,7 +22,7 @@ class Copilot: - def __init__(self, token: str = None): + def __init__(self, token: str = None, proxy: str = None): if token is None: token = utilities.get_cached_token() self.github_token = token @@ -33,6 +33,9 @@ def __init__(self, token: str = None): self.session = requests.Session() + if proxy: + self.session.proxies = {"https": proxy} + def request_auth(self): url = "https://github.com/login/device/code" @@ -87,6 +90,9 @@ def authenticate(self): self.token = self.session.get(url, headers=headers).json() + def reset(self): + self.chat_history = [] + def ask( self, system_prompt: str, @@ -118,19 +124,32 @@ def ask( error_messages = { 401: "Unauthorized. Make sure you have access to Copilot Chat.", 500: "Internal server error. Please try again later.", - 400: "The developer of this plugin has made a mistake. Please report this issue.", + 400: "Your prompt has been rejected by Microsoft.", 419: "You have been rate limited. Please try again later.", } + # Log error to /tmp/copilot.log + with open("/tmp/copilot.log", "a") as f: + f.write(f"Error: {response.status_code}\n") + f.write(f"Request: {data}\n") + f.write(f"Response: {response.text}\n") + + error_code = response.json().get("error", {}).get("code") + if error_code and error_messages.get(response.status_code): + error_messages[ + response.status_code + ] = f"{error_messages[response.status_code]}: {error_code}" + raise Exception( error_messages.get( response.status_code, f"Unknown error: {response.status_code}" ) ) for line in response.iter_lines(): - line = line.decode("utf-8").replace("data: ", "").strip() - if line.startswith("[DONE]"): + line: bytes = line + line = line.replace(b"data: ", b"") + if line.startswith(b"[DONE]"): break - elif line == "": + elif line == b"": continue try: line = json.loads(line) diff --git a/rplugin/python3/copilot-plugin.py b/rplugin/python3/CopilotChat/copilot_plugin.py similarity index 86% rename from rplugin/python3/copilot-plugin.py rename to rplugin/python3/CopilotChat/copilot_plugin.py index ec9b4b5b..5e2708fc 100644 --- a/rplugin/python3/copilot-plugin.py +++ b/rplugin/python3/CopilotChat/copilot_plugin.py @@ -1,7 +1,7 @@ import pynvim -from handlers.inplace_chat_handler import InPlaceChatHandler -from handlers.vsplit_chat_handler import VSplitChatHandler -from mypynvim.core.nvim import MyNvim +from CopilotChat.handlers.inplace_chat_handler import InPlaceChatHandler +from CopilotChat.handlers.vsplit_chat_handler import VSplitChatHandler +from CopilotChat.mypynvim.core.nvim import MyNvim PLUGIN_MAPPING_CMD = "CopilotChatMapping" PLUGIN_AUTOCMD_CMD = "CopilotChatAutocmd" @@ -28,6 +28,12 @@ def copilot_agent_cmd(self, args: list[str]): code = self.nvim.eval("getreg('\"')") self.vsplit_chat_handler.chat(args[0], file_type, code) + @pynvim.command("CopilotChatReset") + def copilot_agent_reset_cmd(self): + if self.vsplit_chat_handler: + self.vsplit_chat_handler.copilot.reset() + self.vsplit_chat_handler.reset_buffer() + @pynvim.command("CopilotChatVisual", nargs="1", range="") def copilot_agent_visual_cmd(self, args: list[str], range: list[int]): self.init_vsplit_chat_handler() diff --git a/rplugin/python3/handlers/chat_handler.py b/rplugin/python3/CopilotChat/handlers/chat_handler.py similarity index 69% rename from rplugin/python3/handlers/chat_handler.py rename to rplugin/python3/CopilotChat/handlers/chat_handler.py index 75f1a3d7..07637cb8 100644 --- a/rplugin/python3/handlers/chat_handler.py +++ b/rplugin/python3/CopilotChat/handlers/chat_handler.py @@ -1,10 +1,12 @@ +import os +import time from datetime import datetime from typing import Optional, cast -import prompts as system_prompts -from copilot import Copilot -from mypynvim.core.buffer import MyBuffer -from mypynvim.core.nvim import MyNvim +import CopilotChat.prompts as system_prompts +from CopilotChat.copilot import Copilot +from CopilotChat.mypynvim.core.buffer import MyBuffer +from CopilotChat.mypynvim.core.nvim import MyNvim def is_module_installed(name): @@ -15,11 +17,15 @@ def is_module_installed(name): return False +# TODO: Abort request if the user closes the layout class ChatHandler: + has_show_extra_info = False + def __init__(self, nvim: MyNvim, buffer: MyBuffer): self.nvim: MyNvim = nvim - self.copilot = None + self.copilot: Copilot = None self.buffer: MyBuffer = buffer + self.proxy: str = os.getenv("HTTPS_PROXY") or os.getenv("ALL_PROXY") or "" # public @@ -34,9 +40,15 @@ def chat( disable_end_separator: bool = False, model: str = "gpt-4", ): + disable_separators = ( + self.nvim.eval("g:copilot_chat_disable_separators") == "yes" + ) + self.proxy = self.nvim.eval("g:copilot_chat_proxy") + if "://" not in self.proxy: + self.proxy = None + if system_prompt is None: system_prompt = self._construct_system_prompt(prompt) - # Start the spinner self.nvim.exec_lua('require("CopilotChat.spinner").show()') @@ -45,7 +57,9 @@ def chat( ) if not disable_start_separator: - self._add_start_separator(system_prompt, prompt, code, filetype, winnr) + self._add_start_separator( + system_prompt, prompt, code, filetype, winnr, disable_separators + ) self._add_chat_messages(system_prompt, prompt, code, filetype, model) @@ -53,7 +67,7 @@ def chat( self.nvim.exec_lua('require("CopilotChat.spinner").hide()') if not disable_end_separator: - self._add_end_separator(model) + self._add_end_separator(model, disable_separators) # private @@ -74,14 +88,15 @@ def _add_start_separator( code: str, file_type: str, winnr: int, + no_annoyance: bool = False, ): - if is_module_installed("tiktoken"): + if is_module_installed("tiktoken") and not no_annoyance: self._add_start_separator_with_token_count( system_prompt, prompt, code, file_type, winnr ) else: self._add_regular_start_separator( - system_prompt, prompt, code, file_type, winnr + system_prompt, prompt, code, file_type, winnr, no_annoyance ) def _add_regular_start_separator( @@ -91,15 +106,17 @@ def _add_regular_start_separator( code: str, file_type: str, winnr: int, + no_annoyance: bool = False, ): - if code: + if code and not no_annoyance: code = f"\n \nCODE:\n```{file_type}\n{code}\n```" last_row_before = len(self.buffer.lines()) system_prompt_height = len(system_prompt.split("\n")) code_height = len(code.split("\n")) - start_separator = f"""### User + start_separator = ( + f"""### User SYSTEM PROMPT: ``` @@ -110,8 +127,13 @@ def _add_regular_start_separator( ### Copilot """ + if not no_annoyance + else f"### User\n{prompt}\n\n### Copilot\n\n" + ) self.buffer.append(start_separator.split("\n")) + if no_annoyance: + return self._add_folds(code, code_height, last_row_before, system_prompt_height, winnr) def _add_start_separator_with_token_count( @@ -167,6 +189,7 @@ def _add_folds( system_prompt_height: int, winnr: int, ): + self.nvim.command("set foldmethod=manual") system_fold_start = last_row_before + 2 system_fold_end = system_fold_start + system_prompt_height + 3 main_command = f"{system_fold_start}, {system_fold_end} fold | normal! Gzz" @@ -184,8 +207,24 @@ def _add_chat_messages( self, system_prompt: str, prompt: str, code: str, file_type: str, model: str ): if self.copilot is None: - self.copilot = Copilot() - + self.copilot = Copilot(proxy=self.proxy) + if self.copilot.github_token is None: + req = self.copilot.request_auth() + self.nvim.out_write( + f"Please visit {req['verification_uri']} and enter the code {req['user_code']}\n" + ) + current_time = time.time() + wait_until = current_time + req["expires_in"] + while self.copilot.github_token is None: + self.copilot.poll_auth(req["device_code"]) + time.sleep(req["interval"]) + if time.time() > wait_until: + self.nvim.out_write("Timed out waiting for authentication\n") + return + self.nvim.out_write("Successfully authenticated with Copilot\n") + self.copilot.authenticate() + + last_line_col = 0 for token in self.copilot.ask( system_prompt, prompt, code, language=cast(str, file_type), model=model ): @@ -194,8 +233,6 @@ def _add_chat_messages( ) buffer_lines = cast(list[str], self.buffer.lines()) last_line_row = len(buffer_lines) - 1 - last_line_col = len(buffer_lines[-1]) - self.nvim.api.buf_set_text( self.buffer.number, last_line_row, @@ -204,14 +241,25 @@ def _add_chat_messages( last_line_col, token.split("\n"), ) + last_line_col += len(token.encode("utf-8")) + if "\n" in token: + last_line_col = 0 - def _add_end_separator(self, model: str): + def _add_end_separator(self, model: str, disable_separators: bool = False): current_datetime = datetime.now().strftime("%Y-%m-%d %H:%M:%S") model_info = f"\n#### Answer provided by Copilot (Model: `{model}`) on {current_datetime}." additional_instructions = ( "\n> For additional queries, please use the `CopilotChat` command." ) - disclaimer = "\n> Please be aware that the AI's output may not always be accurate. Always cross-verify the output.\n---\n" + disclaimer = "\n> Please be aware that the AI's output may not always be accurate. Always cross-verify the output." end_message = model_info + additional_instructions + disclaimer + + show_extra = disable_separators or ChatHandler.has_show_extra_info + + if show_extra: + end_message = "\n" + current_datetime + "\n\n---\n" + + ChatHandler.has_show_extra_info = True + self.buffer.append(end_message.split("\n")) diff --git a/rplugin/python3/handlers/inplace_chat_handler.py b/rplugin/python3/CopilotChat/handlers/inplace_chat_handler.py similarity index 97% rename from rplugin/python3/handlers/inplace_chat_handler.py rename to rplugin/python3/CopilotChat/handlers/inplace_chat_handler.py index f0d784f2..ed938c30 100644 --- a/rplugin/python3/handlers/inplace_chat_handler.py +++ b/rplugin/python3/CopilotChat/handlers/inplace_chat_handler.py @@ -1,9 +1,9 @@ -import prompts as system_prompts -from handlers.chat_handler import ChatHandler -from mypynvim.core.buffer import MyBuffer -from mypynvim.core.nvim import MyNvim -from mypynvim.ui_components.layout import Box, Layout -from mypynvim.ui_components.popup import PopUp +import CopilotChat.prompts as system_prompts +from CopilotChat.handlers.chat_handler import ChatHandler +from CopilotChat.mypynvim.core.buffer import MyBuffer +from CopilotChat.mypynvim.core.nvim import MyNvim +from CopilotChat.mypynvim.ui_components.layout import Box, Layout +from CopilotChat.mypynvim.ui_components.popup import PopUp # Define constants for the models MODEL_GPT4 = "gpt-4" @@ -11,7 +11,6 @@ # TODO: change the layout, e.g: move to right side of the screen -# TODO: Abort request if the user closes the layout class InPlaceChatHandler: """This class handles in-place chat functionality.""" diff --git a/rplugin/python3/handlers/vsplit_chat_handler.py b/rplugin/python3/CopilotChat/handlers/vsplit_chat_handler.py similarity index 74% rename from rplugin/python3/handlers/vsplit_chat_handler.py rename to rplugin/python3/CopilotChat/handlers/vsplit_chat_handler.py index 191fd6b2..9cd76a82 100644 --- a/rplugin/python3/handlers/vsplit_chat_handler.py +++ b/rplugin/python3/CopilotChat/handlers/vsplit_chat_handler.py @@ -1,12 +1,13 @@ -from handlers.chat_handler import ChatHandler -from mypynvim.core.buffer import MyBuffer -from mypynvim.core.nvim import MyNvim +from CopilotChat.copilot import Copilot +from CopilotChat.handlers.chat_handler import ChatHandler +from CopilotChat.mypynvim.core.buffer import MyBuffer +from CopilotChat.mypynvim.core.nvim import MyNvim class VSplitChatHandler(ChatHandler): def __init__(self, nvim: MyNvim): self.nvim: MyNvim = nvim - self.copilot = None + self.copilot: Copilot = None self.buffer: MyBuffer = MyBuffer.new( self.nvim, { @@ -36,3 +37,7 @@ def vsplit(self): def chat(self, prompt: str, filetype: str, code: str = ""): super().chat(prompt, filetype, code, self.nvim.current.window.handle) + + def reset_buffer(self): + """Reset the chat buffer.""" + self.buffer.clear() diff --git a/rplugin/python3/mypynvim/core/autocmdmapper.py b/rplugin/python3/CopilotChat/mypynvim/core/autocmdmapper.py similarity index 95% rename from rplugin/python3/mypynvim/core/autocmdmapper.py rename to rplugin/python3/CopilotChat/mypynvim/core/autocmdmapper.py index 7ba731b8..3bb152fb 100644 --- a/rplugin/python3/mypynvim/core/autocmdmapper.py +++ b/rplugin/python3/CopilotChat/mypynvim/core/autocmdmapper.py @@ -3,7 +3,7 @@ from typing import TYPE_CHECKING, Callable, Union if TYPE_CHECKING: - from .nvim import MyNvim + from CopilotChat.mypynvim.core.nvim import MyNvim class AutocmdMapper: diff --git a/rplugin/python3/mypynvim/core/buffer.py b/rplugin/python3/CopilotChat/mypynvim/core/buffer.py similarity index 98% rename from rplugin/python3/mypynvim/core/buffer.py rename to rplugin/python3/CopilotChat/mypynvim/core/buffer.py index c11db7f7..983709bb 100644 --- a/rplugin/python3/mypynvim/core/buffer.py +++ b/rplugin/python3/CopilotChat/mypynvim/core/buffer.py @@ -5,7 +5,7 @@ from pynvim.api import Buffer if TYPE_CHECKING: - from .nvim import MyNvim + from Copilotchat.mypynvim.core.nvim import MyNvim class MyBuffer(Buffer): diff --git a/rplugin/python3/mypynvim/core/keymapper.py b/rplugin/python3/CopilotChat/mypynvim/core/keymapper.py similarity index 95% rename from rplugin/python3/mypynvim/core/keymapper.py rename to rplugin/python3/CopilotChat/mypynvim/core/keymapper.py index 4c93ee6c..2a111d4e 100644 --- a/rplugin/python3/mypynvim/core/keymapper.py +++ b/rplugin/python3/CopilotChat/mypynvim/core/keymapper.py @@ -3,7 +3,7 @@ from typing import TYPE_CHECKING, Callable, Union if TYPE_CHECKING: - from .nvim import MyNvim + from CopilotChat.mypynvim.core.nvim import MyNvim class Keymapper: diff --git a/rplugin/python3/mypynvim/core/nvim.py b/rplugin/python3/CopilotChat/mypynvim/core/nvim.py similarity index 92% rename from rplugin/python3/mypynvim/core/nvim.py rename to rplugin/python3/CopilotChat/mypynvim/core/nvim.py index 4eeba15d..36be4f8e 100644 --- a/rplugin/python3/mypynvim/core/nvim.py +++ b/rplugin/python3/CopilotChat/mypynvim/core/nvim.py @@ -1,13 +1,12 @@ from typing import Iterable, Union +from CopilotChat.mypynvim.core.autocmdmapper import AutocmdMapper +from CopilotChat.mypynvim.core.buffer import MyBuffer +from CopilotChat.mypynvim.core.keymapper import Keymapper +from CopilotChat.mypynvim.core.window import MyWindow from pynvim import Nvim from pynvim.api.nvim import Current -from .autocmdmapper import AutocmdMapper -from .buffer import MyBuffer -from .keymapper import Keymapper -from .window import MyWindow - class MyNvim(Nvim): def __init__(self, nvim: Nvim, mapping_command: str, autocmd_command: str): diff --git a/rplugin/python3/mypynvim/core/window.py b/rplugin/python3/CopilotChat/mypynvim/core/window.py similarity index 88% rename from rplugin/python3/mypynvim/core/window.py rename to rplugin/python3/CopilotChat/mypynvim/core/window.py index 0aadfc4f..b9fb8e77 100644 --- a/rplugin/python3/mypynvim/core/window.py +++ b/rplugin/python3/CopilotChat/mypynvim/core/window.py @@ -2,12 +2,11 @@ from typing import TYPE_CHECKING +from CopilotChat.mypynvim.core.buffer import MyBuffer from pynvim.api import Window -from .buffer import MyBuffer - if TYPE_CHECKING: - from .nvim import MyNvim + from CopilotChat.mypynvim.core.nvim import MyNvim class MyWindow(Window): diff --git a/rplugin/python3/mypynvim/ui_components/calculator.py b/rplugin/python3/CopilotChat/mypynvim/ui_components/calculator.py similarity index 95% rename from rplugin/python3/mypynvim/ui_components/calculator.py rename to rplugin/python3/CopilotChat/mypynvim/ui_components/calculator.py index 1f19d4ab..ac6ecaa7 100644 --- a/rplugin/python3/mypynvim/ui_components/calculator.py +++ b/rplugin/python3/CopilotChat/mypynvim/ui_components/calculator.py @@ -3,10 +3,10 @@ from dataclasses import dataclass from typing import TYPE_CHECKING, Literal, Union -from mypynvim.core.nvim import MyNvim +from CopilotChat.mypynvim.core.nvim import MyNvim if TYPE_CHECKING: - from .popup import PopUpConfiguration + from CopilotChat.mypynvim.ui_components.popup import PopUpConfiguration @dataclass diff --git a/rplugin/python3/mypynvim/ui_components/layout.py b/rplugin/python3/CopilotChat/mypynvim/ui_components/layout.py similarity index 96% rename from rplugin/python3/mypynvim/ui_components/layout.py rename to rplugin/python3/CopilotChat/mypynvim/ui_components/layout.py index dfea8c87..c61ddda5 100644 --- a/rplugin/python3/mypynvim/ui_components/layout.py +++ b/rplugin/python3/CopilotChat/mypynvim/ui_components/layout.py @@ -1,11 +1,10 @@ from dataclasses import dataclass from typing import Callable, Literal, Optional, Union, cast -from mypynvim.core.nvim import MyNvim - -from .calculator import Calculator -from .popup import PopUp -from .types import PopUpConfiguration, Relative +from CopilotChat.mypynvim.core.nvim import MyNvim +from CopilotChat.mypynvim.ui_components.calculator import Calculator +from CopilotChat.mypynvim.ui_components.popup import PopUp +from CopilotChat.mypynvim.ui_components.types import PopUpConfiguration, Relative class Box: diff --git a/rplugin/python3/mypynvim/ui_components/popup.py b/rplugin/python3/CopilotChat/mypynvim/ui_components/popup.py similarity index 92% rename from rplugin/python3/mypynvim/ui_components/popup.py rename to rplugin/python3/CopilotChat/mypynvim/ui_components/popup.py index 9040b452..1f52cbe9 100644 --- a/rplugin/python3/mypynvim/ui_components/popup.py +++ b/rplugin/python3/CopilotChat/mypynvim/ui_components/popup.py @@ -2,19 +2,21 @@ from copy import deepcopy from dataclasses import dataclass -from typing import TYPE_CHECKING, Any, Callable, Dict, Optional, Union, Unpack +from typing import TYPE_CHECKING, Any, Callable, Dict, Optional, Union if TYPE_CHECKING: - from mypynvim.core.nvim import MyNvim + from CopilotChat.mypynvim.core.nvim import MyNvim - from .layout import Layout + from CopilotChat.mypynvim.ui_components.layout import Layout - -from mypynvim.core.buffer import MyBuffer -from mypynvim.core.window import MyWindow - -from .calculator import Calculator -from .types import PaddingKeys, PopUpArgs, PopUpConfiguration, Relative +from CopilotChat.mypynvim.core.buffer import MyBuffer +from CopilotChat.mypynvim.core.window import MyWindow +from CopilotChat.mypynvim.ui_components.calculator import Calculator +from CopilotChat.mypynvim.ui_components.types import ( + PaddingKeys, + PopUpConfiguration, + Relative, +) @dataclass @@ -33,7 +35,7 @@ def __init__( padding: PaddingKeys = {}, enter: bool = False, opts={}, - **kwargs: Unpack[PopUpArgs], + **kwargs, ): self.nvim: MyNvim = nvim self.calculator: Calculator = Calculator(self.nvim) diff --git a/rplugin/python3/mypynvim/ui_components/types.py b/rplugin/python3/CopilotChat/mypynvim/ui_components/types.py similarity index 100% rename from rplugin/python3/mypynvim/ui_components/types.py rename to rplugin/python3/CopilotChat/mypynvim/ui_components/types.py diff --git a/rplugin/python3/prompts.py b/rplugin/python3/CopilotChat/prompts.py similarity index 100% rename from rplugin/python3/prompts.py rename to rplugin/python3/CopilotChat/prompts.py diff --git a/rplugin/python3/typings.py b/rplugin/python3/CopilotChat/typings.py similarity index 100% rename from rplugin/python3/typings.py rename to rplugin/python3/CopilotChat/typings.py diff --git a/rplugin/python3/utilities.py b/rplugin/python3/CopilotChat/utilities.py similarity index 97% rename from rplugin/python3/utilities.py rename to rplugin/python3/CopilotChat/utilities.py index bc0540a7..fbc418e3 100644 --- a/rplugin/python3/utilities.py +++ b/rplugin/python3/CopilotChat/utilities.py @@ -2,8 +2,8 @@ import os import random -import prompts -import typings +import CopilotChat.prompts as prompts +import CopilotChat.typings as typings def random_hex(length: int = 65): diff --git a/version.txt b/version.txt new file mode 100644 index 00000000..f0bb29e7 --- /dev/null +++ b/version.txt @@ -0,0 +1 @@ +1.3.0