|
1 | 1 | # fittencode.nvim |
2 | 2 |
|
| 3 | +The refactored `fittencode.nvim` is ready. |
| 4 | + |
| 5 | +## ✨ Features |
| 6 | +- 🚀 Fast completion thanks to Fitten Code |
| 7 | +- ⚡️ Asynchronous I/O for enhanced performance |
| 8 | +- ✏️ Enhanced inline completion |
| 9 | + - ✨ Inline completion |
| 10 | + - ✂️ Edit completion |
| 11 | +- 🔄 Accept/Revoke by range |
| 12 | + - 📝 Char |
| 13 | + - 📖 Word |
| 14 | + - 📜 Line |
| 15 | + - 📋 All |
| 16 | +- 🀄️ Enhanced Chinese completion with support for character segmentation |
| 17 | +- 🔌 Sources for `blink.cmp` and native Neovim LSP server |
| 18 | + |
| 19 | +## ⚡️ Requirements |
| 20 | +- Neovim 0.11+ |
| 21 | +- curl |
| 22 | + |
| 23 | +## 📦 Installation |
| 24 | + |
| 25 | +Install the plugin with your preferred package manager: |
| 26 | + |
| 27 | +For example with `lazy.nvim`: |
| 28 | + |
| 29 | +```lua |
| 30 | +{ |
| 31 | + 'luozhiya/fittencode.nvim', |
| 32 | + opts = {}, |
| 33 | +} |
| 34 | +``` |
| 35 | + |
| 36 | +## ⚙️ Configuration |
| 37 | + |
| 38 | +> This version does not support chat functionality. |
| 39 | +
|
| 40 | +```lua |
| 41 | + server = { |
| 42 | + -- Avaiable options: |
| 43 | + -- * 'default' |
| 44 | + -- * 'standard' |
| 45 | + -- * 'enterprise' |
| 46 | + fitten_version = 'default', |
| 47 | + -- The server URL for Fitten Code. |
| 48 | + -- You can also change it to your own server URL if you have a private server. |
| 49 | + -- Default server URL: 'https://api.fittentech.com' |
| 50 | + server_url = '', |
| 51 | + }, |
| 52 | + action = { |
| 53 | + document_code = { |
| 54 | + -- Show "Fitten Code - Document Code" in the editor context menu, when you right-click on the code. |
| 55 | + show_in_editor_context_menu = true, |
| 56 | + }, |
| 57 | + edit_code = { |
| 58 | + -- Show "Fitten Code - Edit Code" in the editor context menu, when you right-click on the code. |
| 59 | + show_in_editor_context_menu = true, |
| 60 | + }, |
| 61 | + explain_code = { |
| 62 | + -- Show "Fitten Code - Explain Code" in the editor context menu, when you right-click on the code. |
| 63 | + show_in_editor_context_menu = true, |
| 64 | + }, |
| 65 | + find_bugs = { |
| 66 | + -- Show "Fitten Code - Find Bugs" in the editor context menu, when you right-click on the code. |
| 67 | + show_in_editor_context_menu = true, |
| 68 | + }, |
| 69 | + generate_unit_test = { |
| 70 | + -- Show "Fitten Code - Generate UnitTest" in the editor context menu, when you right-click on the code. |
| 71 | + show_in_editor_context_menu = true, |
| 72 | + }, |
| 73 | + optimize_code = { |
| 74 | + -- Show "Fitten Code - Optimize Code" in the editor context menu, when you right-click on the code. |
| 75 | + show_in_editor_context_menu = true, |
| 76 | + }, |
| 77 | + start_chat = { |
| 78 | + -- Show "Fitten Code - Start Chat" in the editor context menu, when you right-click on the code. |
| 79 | + show_in_editor_context_menu = true, |
| 80 | + }, |
| 81 | + }, |
| 82 | + -- Add Certain Type to Commit Message |
| 83 | + add_type_to_commit_message = { |
| 84 | + -- Avaiable options: |
| 85 | + -- * 'auto' |
| 86 | + -- * 'concise' Concise Commit Message |
| 87 | + -- * 'detailed' Detailed Commit Message |
| 88 | + open = 'auto', |
| 89 | + }, |
| 90 | + agent = { |
| 91 | + -- Simplify Agent's Thinking Output |
| 92 | + -- Avaiable options: |
| 93 | + -- * 'auto' |
| 94 | + -- * 'on' |
| 95 | + -- * 'off' |
| 96 | + simple_thinking = 'auto', |
| 97 | + }, |
| 98 | + delay_completion = { |
| 99 | + -- Delay time for inline completion (in milliseconds). |
| 100 | + ---@type integer |
| 101 | + delaytime = 0, |
| 102 | + }, |
| 103 | + disable_specific_inline_completion = { |
| 104 | + -- Disable auto-completion for some specific file suffixes by entering them below |
| 105 | + -- For instances, `suffixes = {'lua', 'cpp'}` |
| 106 | + suffixes = {}, |
| 107 | + }, |
| 108 | + inline_completion = { |
| 109 | + -- Enable inline code completion. |
| 110 | + ---@type boolean |
| 111 | + enable = true, |
| 112 | + -- Auto triggering completion |
| 113 | + ---@type boolean |
| 114 | + auto_triggering_completion = true, |
| 115 | + -- Disable auto completion when the cursor is within the line. |
| 116 | + ---@type boolean |
| 117 | + disable_completion_within_the_line = false, |
| 118 | + -- Disable auto completion when pressing Backspace or Delete. |
| 119 | + ---@type boolean |
| 120 | + disable_completion_when_delete = false, |
| 121 | + -- Disable auto completion when entering Insert mode `InsertEnter`. |
| 122 | + disable_completion_when_insert_enter = true, |
| 123 | + -- Disable auto completion when the popup menu is changed `CompleteChanged`. |
| 124 | + disable_completion_when_pumcmp_changed = false, |
| 125 | + -- Disable auto completion when the buffer is not a file. |
| 126 | + disable_completion_when_nofile_buffer = true, |
| 127 | + }, |
| 128 | + integrations = { |
| 129 | + completion = { |
| 130 | + -- Enable completion as an LSP server. |
| 131 | + ---@type boolean |
| 132 | + lsp_server = false, |
| 133 | + -- Enable completion as an `blink.cmp` source |
| 134 | + blink = false |
| 135 | + }, |
| 136 | + commit_message = false, |
| 137 | + filetype = false, |
| 138 | + }, |
| 139 | + language_preference = { |
| 140 | + -- Language preference for display and responses in Fitten Code (excluding "Fitten Code - Document Code" function). |
| 141 | + -- Lower case of the BCP 47 language tag. |
| 142 | + -- Avaiable options: |
| 143 | + -- * 'en' |
| 144 | + -- * 'zh-cn' |
| 145 | + -- * 'auto' |
| 146 | + display_preference = 'zh-cn', |
| 147 | + -- Language preference when using function "Fitten Code - Document Code". |
| 148 | + -- Lower case of the BCP 47 language tag. |
| 149 | + -- Avaiable options: |
| 150 | + -- * 'en' |
| 151 | + -- * 'zh-cn' |
| 152 | + -- * 'auto' |
| 153 | + comment_preference = 'auto', |
| 154 | + -- Language preference for commit message. |
| 155 | + -- Lower case of the BCP 47 language tag. |
| 156 | + -- Avaiable options: |
| 157 | + -- * 'en' |
| 158 | + -- * 'zh-cn' |
| 159 | + -- * 'auto' |
| 160 | + commit_message_preference = 'auto', |
| 161 | + }, |
| 162 | + -- Show menu as submenu in the editor context menu, when you right-click on the code. |
| 163 | + show_submenu = false, |
| 164 | + snippet = { |
| 165 | + -- The comment / document snippet as the style reference for Fitten Code's Document Code function. |
| 166 | + comment = '', |
| 167 | + }, |
| 168 | + unit_test_framework = { |
| 169 | + -- Unit Test Framework for C/C++ |
| 170 | + -- Avaiable options: |
| 171 | + -- * 'gmock', |
| 172 | + -- * 'gtest' |
| 173 | + ['C/C++'] = 'Not specified', |
| 174 | + -- Unit Test Framework for Go |
| 175 | + -- Avaiable options: |
| 176 | + -- * 'gomock' |
| 177 | + -- * 'gotests' |
| 178 | + -- * 'testify' |
| 179 | + -- * 'monkey' |
| 180 | + -- * 'sqlmock' |
| 181 | + -- * 'httptest' |
| 182 | + ['Go'] = 'Not specified', |
| 183 | + -- Unit Test Framework for Java |
| 184 | + -- Avaiable options: |
| 185 | + -- * 'mockito' |
| 186 | + -- * 'junit4' |
| 187 | + -- * 'junit5' |
| 188 | + -- * 'testNG' |
| 189 | + -- * 'spock' |
| 190 | + -- * 'jmockit' |
| 191 | + ['Java'] = 'Not specified', |
| 192 | + -- Unit Test Framework for JavaScript/TypeScript |
| 193 | + -- Avaiable options: |
| 194 | + -- * 'mock' |
| 195 | + -- * 'jest' |
| 196 | + -- * 'tape' |
| 197 | + -- * 'mocha' |
| 198 | + ['JavaScript/Typescript'] = 'Not specified', |
| 199 | + -- Unit Test Framework for Python |
| 200 | + -- Avaiable options: |
| 201 | + -- * 'mock' |
| 202 | + -- * 'pytest' |
| 203 | + -- * 'doctest' |
| 204 | + -- * 'unittest' |
| 205 | + ['Python'] = 'Not specified', |
| 206 | + }, |
| 207 | + -- Intelligent Triggered Edit Completion |
| 208 | + use_auto_edit_completion = { |
| 209 | + -- Avaiable options: |
| 210 | + -- * 'auto' |
| 211 | + -- * 'on' |
| 212 | + -- * 'off' |
| 213 | + open = 'auto', |
| 214 | + }, |
| 215 | + -- Automatic Project Index Creation |
| 216 | + use_auto_upload_project = { |
| 217 | + -- Avaiable options: |
| 218 | + -- * 'auto' |
| 219 | + -- * 'on' |
| 220 | + -- * 'off' |
| 221 | + open = 'auto', |
| 222 | + }, |
| 223 | + -- Entire Project Perception based Completion |
| 224 | + use_project_completion = { |
| 225 | + -- Avaiable options: |
| 226 | + -- * 'auto' |
| 227 | + -- * 'on' |
| 228 | + -- * 'off' |
| 229 | + open = 'auto', |
| 230 | + }, |
| 231 | + -- Use default keymaps for Fitten Code. |
| 232 | + -- If set to false, all defaults keymaps will be removed. |
| 233 | + use_default_keymaps = true, |
| 234 | + -- Default keymaps for Fitten Code. |
| 235 | + keymaps = { |
| 236 | + inline = { |
| 237 | + inccmp = { |
| 238 | + ['inline_completion'] = '<A-\\>', |
| 239 | + ['accept_all'] = '<Tab>', |
| 240 | + ['accept_next_line'] = '<C-Down>', |
| 241 | + ['accept_next_word'] = '<C-Right>', |
| 242 | + ['revoke'] = { '<C-Left>', '<C-Up>' }, |
| 243 | + -- ['cancel'] = '<Esc>', |
| 244 | + }, |
| 245 | + editcmp = { |
| 246 | + ['edit_completion'] = '<A-o>', |
| 247 | + ['accept_all'] = '<Tab>', |
| 248 | + ['accept_next_hunk'] = '<C-Down>', |
| 249 | + ['revoke'] = { '<C-Left>', '<C-Up>' }, |
| 250 | + ['cancel'] = '<Esc>', |
| 251 | + } |
| 252 | + }, |
| 253 | + chat = { |
| 254 | + ['add_selection_context_to_input'] = 'A-X', |
| 255 | + ['document_code'] = '', |
| 256 | + ['edit_code'] = '', |
| 257 | + ['explain_code'] = '', |
| 258 | + ['find_bugs'] = '', |
| 259 | + ['generate_unit_test'] = '', |
| 260 | + ['optimize_code'] = '', |
| 261 | + ['start_chat'] = '', |
| 262 | + } |
| 263 | + }, |
| 264 | + log = { |
| 265 | + level = vim.log.levels.WARN, |
| 266 | + -- Notify when log errors occur. |
| 267 | + notify_on_errors = false, |
| 268 | + trace = false, |
| 269 | + }, |
| 270 | + colors = { |
| 271 | + -- { fg = '#ffffff', bg = '#000000', style = 'bold' } |
| 272 | + ['Suggestion'] = {}, |
| 273 | + ['InfoNotify'] = {}, |
| 274 | + ['Commit'] = {}, |
| 275 | + }, |
| 276 | +``` |
| 277 | + |
| 278 | +## 🚀 Usage |
| 279 | + |
| 280 | +| Command Name | Description | |
| 281 | +|-------------------|-----------------------| |
| 282 | +| register | Register account | |
| 283 | +| login | Login account | |
| 284 | +| login3rd | Third-party login | |
| 285 | +| logout | Logout account | |
| 286 | +| ask_question | Ask question | |
| 287 | +| user_guide | User guide | |
| 288 | +| enable_completions| Enable completions | |
| 289 | +| disable_completions| Disable completions | |
| 290 | +| onlyenable_completions| Enable completions for specific files| |
| 291 | +| onlydisable_completions| Disable completions for specific files| |
| 292 | + |
| 293 | +## ✏️ API |
| 294 | + |
| 295 | +| Function | Description | |
| 296 | +|----------|-------------| |
| 297 | +| `has_completions()` | Check if there are completion suggestions available | |
| 298 | +| `accept(scope)` | Accept the current completion suggestion | |
| 299 | +| `revoke()` | Undo the last completion operation | |
| 300 | +| `completion_cancel()` | Cancel the current completion suggestion | |
| 301 | +| `get_status()` | Get the current status of the completion system | |
| 302 | + |
| 303 | +## 🎉 Special Thanks |
| 304 | + |
| 305 | +https://github.com/FittenTech/fittencode.vim |
| 306 | + |
0 commit comments