Fitten Code AI Programming Assistant for Neovim, helps you to use AI for automatic completion in Neovim, with support for functions like login, logout, shortcut key completion.
- π Fast completion thanks to
Fitten Code
- π Asynchronous I/O for improved performance
- π£ Support for
Actions
- 1οΈβ£ Document code
- 2οΈβ£ Edit code
- 3οΈβ£ Explain code
- 4οΈβ£ Find bugs
- 5οΈβ£ Generate unit test
- 6οΈβ£ Implement features
- 7οΈβ£ Improve code
- 8οΈβ£ Refactor code
- 9οΈβ£ Start chat
- βοΈ Accept all suggestions with
Tab
- π§ͺ Accept line with
Ctrl + π‘«
- π Accept word with
Ctrl + π‘ͺ
- βοΈ Undo accepted text
- 𧨠Automatic scrolling when previewing or completing code
- π Multiple HTTP/REST backends such as
curl
,libcurl
(WIP) - π°οΈ Run as a
coc.nvim
(WIP) source ornvim-cmp
source
- Neovim >= 0.8.0
- curl
Install the plugin with your preferred package manager:
{
'luozhiya/fittencode.nvim',
config = function()
require('fittencode').setup()
end,
}
use {
'luozhiya/fittencode.nvim',
config = function()
require('fittencode').setup()
end,
}
fittencode.nvim comes with the following defaults:
{
action = {
document_code = {
-- Show "Fitten Code - Document Code" in the editor context menu, when you right-click on the code.
show_in_editor_context_menu = true,
},
edit_code = {
-- Show "Fitten Code - Edit Code" in the editor context menu, when you right-click on the code.
show_in_editor_context_menu = true,
},
explain_code = {
-- Show "Fitten Code - Explain Code" in the editor context menu, when you right-click on the code.
show_in_editor_context_menu = true,
},
find_bugs = {
-- Show "Fitten Code - Find Bugs" in the editor context menu, when you right-click on the code.
show_in_editor_context_menu = true,
},
generate_unit_test = {
-- Show "Fitten Code - Generate UnitTest" in the editor context menu, when you right-click on the code.
show_in_editor_context_menu = true,
},
start_chat = {
-- Show "Fitten Code - Start Chat" in the editor context menu, when you right-click on the code.
show_in_editor_context_menu = true,
},
},
disable_specific_inline_completion = {
-- Disable auto-completion for some specific file suffixes by entering them below
-- For example, `suffixes = {'lua', 'cpp'}`
suffixes = {},
},
inline_completion = {
-- Enable inline code completion.
---@type boolean
enable = true,
-- Disable auto completion when the cursor is within the line.
---@type boolean
disable_completion_within_the_line = false,
-- Disable auto completion when pressing Backspace or Delete.
---@type boolean
disable_completion_when_delete = false,
},
delay_completion = {
-- Delay time for inline completion (in milliseconds).
---@type integer
delaytime = 0,
},
-- Enable/Disable the default keymaps in inline completion.
use_default_keymaps = true,
-- Setting for source completion.
source_completion = {
-- Enable source completion.
enable = true,
},
-- Set the mode of the completion.
-- Available options:
-- - 'inline' (default)
-- - 'source'
completion_mode = 'inline',
---@class LogOptions
log = {
-- Log level.
level = vim.log.levels.WARN,
-- Max log file size in MB, default is 10MB
max_size = 10,
},
}
Set updatetime
to a lower value to improve performance:
-- Neovim default updatetime is 4000
vim.opt.updatetime = 200
require('fittencode').setup({
completion_mode ='source',
})
require('cmp').setup({
sources = { name = 'fittencode', group_index = 1 },
mapping = {
['<cr>'] = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = false }),
}
})
Command | Description |
---|---|
Fitten register |
If you haven't registered yet, please run the command to register. |
Fitten login |
Try the command Fitten login <user> <password> to login. |
Fitten logout |
Logout account |
- Try the command
Fitten generate_unit_test <test_framework> <language>
to generate unit test with specific test framework and language.
Command | Description |
---|---|
Fitten document_code |
Document code |
Fitten edit_code |
Edit code |
Fitten explain_code |
Explain code |
Fitten find_bugs |
Find bugs |
Fitten generate_unit_test |
Generate unit test |
Fitten implement_features |
Implement features |
Fitten improve_code |
Improve code |
Fitten refactor_code |
Refactor code |
Fitten guess_programming_language |
Guess programming language |
Fitten analyze_data |
Analyze data |
Fitten start_chat |
Start chat |
Mappings | Action |
---|---|
Tab |
Accept all suggestions |
Ctrl + π‘« |
Accept line |
Ctrl + π‘ͺ |
Accept word |
Alt + \ |
Manually triggering completion |
fittencode.nvim
provides a set of APIs to help you integrate it with other plugins or scripts.
- Access the APIs by calling
require('fittencode').<api_name>()
.
-- Log levels
vim.log = {
levels = {
TRACE = 0,
DEBUG = 1,
INFO = 2,
WARN = 3,
ERROR = 4,
OFF = 5,
},
}
---@class ActionOptions
---@field prompt? string
---@field content? string
---@field language? string
---@class GenerateUnitTestOptions : ActionOptions
---@field test_framework string
---@class ImplementFeaturesOptions : ActionOptions
---@field feature_type string
API Prototype | Description |
---|---|
login(username, password) |
Login to Fitten Code AI |
logout() |
Logout from Fitten Code AI |
register() |
Register to Fitten Code AI |
set_log_level(level) |
Set the log level |
get_current_status() |
Get the current status of the InlineEngine and ActionEngine |
triggering_completion() |
Manually triggering completion |
has_suggestion() |
Check if there is a suggestion |
accept_all_suggestions() |
Accept all suggestions |
accept_line() |
Accept line |
accept_word() |
Accept word |
document_code(ActionOptions) |
Document code |
edit_code(ActionOptions) |
Edit code |
explain_code(ActionOptions) |
Explain code |
find_bugs(ActionOptions) |
Find bugs |
generate_unit_test(GenerateUnitTestOptions) |
Generate unit test |
implement_features(ImplementFeaturesOptions) |
Implement features |
improve_code(ActionOptions) |
Improve code |
refactor_code(ActionOptions) |
Refactor code |
guess_programming_language(ActionOptions) |
Guess programming language |
analyze_data(ActionOptions) |
Analyze data |
start_chat(ActionOptions) |
Start chat |
stop_eval() |
Stop the evaluation |