mirror of
https://github.com/NotAShelf/nvf.git
synced 2026-01-02 00:55:54 +00:00
assistant/chatgpt: Add jackMort/ChatGPT.nvim
This commit is contained in:
parent
9cb7239085
commit
a6dc729e90
8 changed files with 100 additions and 0 deletions
|
|
@ -221,6 +221,7 @@ inputs: let
|
|||
enable = isMaximal;
|
||||
cmp.enable = isMaximal;
|
||||
};
|
||||
chatgpt.enable = isMaximal;
|
||||
};
|
||||
|
||||
vim.session = {
|
||||
|
|
|
|||
17
flake.lock
generated
17
flake.lock
generated
|
|
@ -80,6 +80,22 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"chatgpt": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1709721561,
|
||||
"narHash": "sha256-vD3NEsYmPRWlxBSOxyIMIQiJXQXxx0hhsw4zIxxXB3o=",
|
||||
"owner": "jackMort",
|
||||
"repo": "ChatGPT.nvim",
|
||||
"rev": "df53728e05129278d6ea26271ec086aa013bed90",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "jackMort",
|
||||
"repo": "ChatGPT.nvim",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"cheatsheet-nvim": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
|
|
@ -1488,6 +1504,7 @@
|
|||
"catppuccin": "catppuccin",
|
||||
"ccc": "ccc",
|
||||
"cellular-automaton": "cellular-automaton",
|
||||
"chatgpt": "chatgpt",
|
||||
"cheatsheet-nvim": "cheatsheet-nvim",
|
||||
"cinnamon-nvim": "cinnamon-nvim",
|
||||
"cmp-buffer": "cmp-buffer",
|
||||
|
|
|
|||
|
|
@ -545,6 +545,11 @@
|
|||
flake = false;
|
||||
};
|
||||
|
||||
chatgpt = {
|
||||
url = "github:jackMort/ChatGPT.nvim";
|
||||
flake = false;
|
||||
};
|
||||
|
||||
# Session management
|
||||
nvim-session-manager = {
|
||||
url = "github:Shatur/neovim-session-manager";
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ with lib; let
|
|||
"noice-nvim"
|
||||
"nui-nvim"
|
||||
"copilot-lua"
|
||||
"chatgpt"
|
||||
"tabnine-nvim"
|
||||
"nvim-session-manager"
|
||||
"gesture-nvim"
|
||||
|
|
|
|||
23
modules/assistant/chatgpt/chatgpt.nix
Normal file
23
modules/assistant/chatgpt/chatgpt.nix
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkEnableOption;
|
||||
inherit (lib) mkMappingOption;
|
||||
in {
|
||||
options.vim.assistant.chatgpt = {
|
||||
enable = mkEnableOption "ChatGPT AI assistant. Requires the environment variable OPENAI_API_KEY to be set";
|
||||
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/assistant/chatgpt/config.nix
Normal file
46
modules/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) addDescriptionsToMappings mkSetBinding;
|
||||
|
||||
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({
|
||||
})
|
||||
'';
|
||||
maps.normal = mkMerge [
|
||||
(mkSetBinding mappings.chatGpt "<cmd>ChatGPT<CR>")
|
||||
maps
|
||||
];
|
||||
maps.visual = maps;
|
||||
};
|
||||
};
|
||||
}
|
||||
6
modules/assistant/chatgpt/default.nix
Normal file
6
modules/assistant/chatgpt/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./chatgpt.nix
|
||||
./config.nix
|
||||
];
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
_: {
|
||||
imports = [
|
||||
./copilot
|
||||
./chatgpt
|
||||
# ./tabnine.nix # removed until I find a way around the initialisation script the plugin requires
|
||||
];
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue