mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-11-07 22:55:58 +01:00
Compare commits
2 commits
736daeb7b4
...
5b8ef42453
Author | SHA1 | Date | |
---|---|---|---|
|
5b8ef42453 | ||
|
f9cec7b4cc |
6 changed files with 84 additions and 0 deletions
|
@ -222,6 +222,7 @@ inputs: let
|
|||
};
|
||||
|
||||
assistant = {
|
||||
chatgpt.enable = isMaximal;
|
||||
copilot = {
|
||||
enable = isMaximal;
|
||||
cmp.enable = isMaximal;
|
||||
|
|
|
@ -550,6 +550,11 @@
|
|||
};
|
||||
|
||||
# Assistant
|
||||
plugin-chatgpt = {
|
||||
url = "github:jackMort/ChatGPT.nvim";
|
||||
flake = false;
|
||||
};
|
||||
|
||||
plugin-copilot-lua = {
|
||||
url = "github:zbirenbaum/copilot.lua";
|
||||
flake = false;
|
||||
|
|
25
modules/plugins/assistant/chatgpt/chatgpt.nix
Normal file
25
modules/plugins/assistant/chatgpt/chatgpt.nix
Normal file
|
@ -0,0 +1,25 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkEnableOption;
|
||||
inherit (lib.nvim.binds) mkMappingOption;
|
||||
inherit (lib.nvim.types) mkPluginSetupOption;
|
||||
in {
|
||||
options.vim.assistant.chatgpt = {
|
||||
enable = mkEnableOption "ChatGPT AI assistant. Requires the environment variable OPENAI_API_KEY to be set";
|
||||
setupOpts = mkPluginSetupOption "chatgpt" {};
|
||||
mappings = {
|
||||
chatGpt = mkMappingOption "ChatGPT" "<leader>ac";
|
||||
editWithInstructions = mkMappingOption "[ChatGPT] Edit with instructions" "<leader>ae";
|
||||
grammarCorrection = mkMappingOption "[ChatGPT] Grammar correction" "<leader>ag";
|
||||
translate = mkMappingOption "[ChatGPT] Translate" "<leader>at";
|
||||
keyword = mkMappingOption "[ChatGPT] Keywords" "<leader>ak";
|
||||
docstring = mkMappingOption "[ChatGPT] Docstring" "<leader>ad";
|
||||
addTests = mkMappingOption "[ChatGPT] Add tests" "<leader>aa";
|
||||
optimize = mkMappingOption "[ChatGPT] Optimize code" "<leader>ao";
|
||||
summarize = mkMappingOption "[ChatGPT] Summarize" "<leader>as";
|
||||
fixBugs = mkMappingOption "[ChatGPT] Fix bugs" "<leader>af";
|
||||
explain = mkMappingOption "[ChatGPT] Explain code" "<leader>ax";
|
||||
roxygenEdit = mkMappingOption "[ChatGPT] Roxygen edit" "<leader>ar";
|
||||
readabilityanalysis = mkMappingOption "[ChatGPT] Code reability analysis" "<leader>al";
|
||||
};
|
||||
};
|
||||
}
|
46
modules/plugins/assistant/chatgpt/config.nix
Normal file
46
modules/plugins/assistant/chatgpt/config.nix
Normal file
|
@ -0,0 +1,46 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetBinding;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
|
||||
cfg = config.vim.assistant.chatgpt;
|
||||
|
||||
self = import ./chatgpt.nix {inherit lib;};
|
||||
mappingDefinitions = self.options.vim.assistant.chatgpt.mappings;
|
||||
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
|
||||
maps = mkMerge [
|
||||
(mkSetBinding mappings.editWithInstructions "<cmd>ChatGPTEditWithInstruction<CR>")
|
||||
(mkSetBinding mappings.grammarCorrection "<cmd>ChatGPTRun grammar_correction<CR>")
|
||||
(mkSetBinding mappings.translate "<cmd>ChatGPTRun translate<CR>")
|
||||
(mkSetBinding mappings.keyword "<cmd>ChatGPTRun keywords<CR>")
|
||||
(mkSetBinding mappings.docstring "<cmd>ChatGPTRun docstring<CR>")
|
||||
(mkSetBinding mappings.addTests "<cmd>ChatGPTRun add_tests<CR>")
|
||||
(mkSetBinding mappings.optimize "<cmd>ChatGPTRun optimize_code<CR>")
|
||||
(mkSetBinding mappings.summarize "<cmd>ChatGPTRun summarize<CR>")
|
||||
(mkSetBinding mappings.fixBugs "<cmd>ChatGPTRun fix_bugs<CR>")
|
||||
(mkSetBinding mappings.explain "<cmd>ChatGPTRun explain_code<CR>")
|
||||
(mkSetBinding mappings.roxygenEdit "<cmd>ChatGPTRun roxygen_edit<CR>")
|
||||
(mkSetBinding mappings.readabilityanalysis "<cmd>ChatGPTRun code_readability_analysis<CR>")
|
||||
];
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim = {
|
||||
startPlugins = [
|
||||
"chatgpt"
|
||||
];
|
||||
luaConfigRC.chagpt = entryAnywhere ''
|
||||
require("chatgpt").setup(${toLuaObject cfg.setupOpts})
|
||||
'';
|
||||
maps.normal = mkMerge [
|
||||
(mkSetBinding mappings.chatGpt "<cmd>ChatGPT<CR>")
|
||||
maps
|
||||
];
|
||||
maps.visual = maps;
|
||||
};
|
||||
};
|
||||
}
|
6
modules/plugins/assistant/chatgpt/default.nix
Normal file
6
modules/plugins/assistant/chatgpt/default.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./chatgpt.nix
|
||||
./config.nix
|
||||
];
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./chatgpt
|
||||
./copilot
|
||||
];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue