mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-22 21:30:51 +00:00
assistant/chatgpt: Add jackMort/ChatGPT.nvim
This commit is contained in:
parent
50609c731e
commit
140ed6daa8
6 changed files with 84 additions and 0 deletions
|
@ -227,6 +227,7 @@ inputs: let
|
||||||
};
|
};
|
||||||
|
|
||||||
assistant = {
|
assistant = {
|
||||||
|
chatgpt.enable = isMaximal;
|
||||||
copilot = {
|
copilot = {
|
||||||
enable = isMaximal;
|
enable = isMaximal;
|
||||||
cmp.enable = isMaximal;
|
cmp.enable = isMaximal;
|
||||||
|
|
|
@ -550,6 +550,11 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
# Assistant
|
# Assistant
|
||||||
|
plugin-chatgpt = {
|
||||||
|
url = "github:jackMort/ChatGPT.nvim";
|
||||||
|
flake = false;
|
||||||
|
};
|
||||||
|
|
||||||
plugin-copilot-lua = {
|
plugin-copilot-lua = {
|
||||||
url = "github:zbirenbaum/copilot.lua";
|
url = "github:zbirenbaum/copilot.lua";
|
||||||
flake = false;
|
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 = [
|
imports = [
|
||||||
|
./chatgpt
|
||||||
./copilot
|
./copilot
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue