From 140ed6daa8b7592cb5a046c94652ca96220c10a3 Mon Sep 17 00:00:00 2001 From: Kalle Jepsen Date: Sat, 20 Apr 2024 17:21:40 +0300 Subject: [PATCH 1/2] assistant/chatgpt: Add jackMort/ChatGPT.nvim --- configuration.nix | 1 + flake.nix | 5 ++ modules/plugins/assistant/chatgpt/chatgpt.nix | 25 ++++++++++ modules/plugins/assistant/chatgpt/config.nix | 46 +++++++++++++++++++ modules/plugins/assistant/chatgpt/default.nix | 6 +++ modules/plugins/assistant/default.nix | 1 + 6 files changed, 84 insertions(+) create mode 100644 modules/plugins/assistant/chatgpt/chatgpt.nix create mode 100644 modules/plugins/assistant/chatgpt/config.nix create mode 100644 modules/plugins/assistant/chatgpt/default.nix diff --git a/configuration.nix b/configuration.nix index b0e7baa..f77345e 100644 --- a/configuration.nix +++ b/configuration.nix @@ -227,6 +227,7 @@ inputs: let }; assistant = { + chatgpt.enable = isMaximal; copilot = { enable = isMaximal; cmp.enable = isMaximal; diff --git a/flake.nix b/flake.nix index 78c3447..eed650e 100644 --- a/flake.nix +++ b/flake.nix @@ -550,6 +550,11 @@ }; # Assistant + plugin-chatgpt = { + url = "github:jackMort/ChatGPT.nvim"; + flake = false; + }; + plugin-copilot-lua = { url = "github:zbirenbaum/copilot.lua"; flake = false; diff --git a/modules/plugins/assistant/chatgpt/chatgpt.nix b/modules/plugins/assistant/chatgpt/chatgpt.nix new file mode 100644 index 0000000..95dde39 --- /dev/null +++ b/modules/plugins/assistant/chatgpt/chatgpt.nix @@ -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" "ac"; + editWithInstructions = mkMappingOption "[ChatGPT] Edit with instructions" "ae"; + grammarCorrection = mkMappingOption "[ChatGPT] Grammar correction" "ag"; + translate = mkMappingOption "[ChatGPT] Translate" "at"; + keyword = mkMappingOption "[ChatGPT] Keywords" "ak"; + docstring = mkMappingOption "[ChatGPT] Docstring" "ad"; + addTests = mkMappingOption "[ChatGPT] Add tests" "aa"; + optimize = mkMappingOption "[ChatGPT] Optimize code" "ao"; + summarize = mkMappingOption "[ChatGPT] Summarize" "as"; + fixBugs = mkMappingOption "[ChatGPT] Fix bugs" "af"; + explain = mkMappingOption "[ChatGPT] Explain code" "ax"; + roxygenEdit = mkMappingOption "[ChatGPT] Roxygen edit" "ar"; + readabilityanalysis = mkMappingOption "[ChatGPT] Code reability analysis" "al"; + }; + }; +} diff --git a/modules/plugins/assistant/chatgpt/config.nix b/modules/plugins/assistant/chatgpt/config.nix new file mode 100644 index 0000000..79db0d9 --- /dev/null +++ b/modules/plugins/assistant/chatgpt/config.nix @@ -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 "ChatGPTEditWithInstruction") + (mkSetBinding mappings.grammarCorrection "ChatGPTRun grammar_correction") + (mkSetBinding mappings.translate "ChatGPTRun translate") + (mkSetBinding mappings.keyword "ChatGPTRun keywords") + (mkSetBinding mappings.docstring "ChatGPTRun docstring") + (mkSetBinding mappings.addTests "ChatGPTRun add_tests") + (mkSetBinding mappings.optimize "ChatGPTRun optimize_code") + (mkSetBinding mappings.summarize "ChatGPTRun summarize") + (mkSetBinding mappings.fixBugs "ChatGPTRun fix_bugs") + (mkSetBinding mappings.explain "ChatGPTRun explain_code") + (mkSetBinding mappings.roxygenEdit "ChatGPTRun roxygen_edit") + (mkSetBinding mappings.readabilityanalysis "ChatGPTRun code_readability_analysis") + ]; +in { + config = mkIf cfg.enable { + vim = { + startPlugins = [ + "chatgpt" + ]; + luaConfigRC.chagpt = entryAnywhere '' + require("chatgpt").setup(${toLuaObject cfg.setupOpts}) + ''; + maps.normal = mkMerge [ + (mkSetBinding mappings.chatGpt "ChatGPT") + maps + ]; + maps.visual = maps; + }; + }; +} diff --git a/modules/plugins/assistant/chatgpt/default.nix b/modules/plugins/assistant/chatgpt/default.nix new file mode 100644 index 0000000..0f23771 --- /dev/null +++ b/modules/plugins/assistant/chatgpt/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./chatgpt.nix + ./config.nix + ]; +} diff --git a/modules/plugins/assistant/default.nix b/modules/plugins/assistant/default.nix index 3521c52..5b5cf32 100644 --- a/modules/plugins/assistant/default.nix +++ b/modules/plugins/assistant/default.nix @@ -1,5 +1,6 @@ { imports = [ + ./chatgpt ./copilot ]; } From 56012ea8f954c0c721f57a9961c9ee8b8b82a3aa Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 21 Apr 2024 05:27:08 +0300 Subject: [PATCH 2/2] docs: update v0.6 release notes --- docs/release-notes/rl-0.6.md | 44 ++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/docs/release-notes/rl-0.6.md b/docs/release-notes/rl-0.6.md index 09df20a..0c46886 100644 --- a/docs/release-notes/rl-0.6.md +++ b/docs/release-notes/rl-0.6.md @@ -41,23 +41,26 @@ vim.api.nvim_set_keymap('n', 'a', ':lua camelToSnake()', { noremap = [ksonj](https://github.com/ksonj): -- Add Terraform language support +- Added Terraform language support. + +- Added `ChatGPT.nvim`, which can be enabled with [`vim.assistant.chatgpt`](vim.assistant.chatgpt). Do + keep in mind that this option requires `OPENAI_API_KEY` environment variable to be set. [donnerinoern](https://github.com/donnerinoern): -- Added Gruvbox theme +- Added Gruvbox theme. -- Added marksman LSP for Markdown +- Added marksman LSP for Markdown. -- Fixed markdown preview with Glow not working and added an option for changing the preview keybind +- Fixed markdown preview with Glow not working and added an option for changing the preview keybind. -- colorizer.nvim: switched to a maintained fork +- colorizer.nvim: switched to a maintained fork. - Added `markdown-preview.nvim`, moved `glow.nvim` to a brand new `vim.utility.preview` category. [elijahimmer](https://github.com/elijahimmer) -- Added rose-pine theme +- Added rose-pine theme. [jacekpoz](https://github.com/jacekpoz): @@ -65,13 +68,13 @@ vim.api.nvim_set_keymap('n', 'a', ':lua camelToSnake()', { noremap = [horriblename](https://github.com/horriblename): -- Fixed empty winbar when breadcrumbs are disabled +- Fixed empty winbar when breadcrumbs are disabled. -- Added custom `setupOpts` for various plugins +- Added custom `setupOpts` for various plugins. -- Removed support for deprecated plugin "nvim-compe" +- Removed support for deprecated plugin "nvim-compe". -- Moved most plugins to `setupOpts` method +- Moved most plugins to `setupOpts` method. [frothymarrow](https://github.com/frothymarrow): @@ -81,35 +84,36 @@ vim.api.nvim_set_keymap('n', 'a', ':lua camelToSnake()', { noremap = been removed in favor of [vim.fidget-nvim.notification.window.align](vim.fidget-nvim.notification.window.align), which now supports `top` and `bottom` values. `vim.fidget-nvim.align.right` has no longer any equivalent and also has been removed. -- `which-key.nvim` categories can now be customized through [vim.binds.whichKey.register](vim.binds.whichKey.register). +- `which-key.nvim` categories can now be customized through [vim.binds.whichKey.register](vim.binds.whichKey.register) -- Added `magick` to `vim.luaPackages` for `image.nvim` +- Added `magick` to `vim.luaPackages` for `image.nvim`. - Added `alejandra` to the default devShell. -- Migrated neovim-flake to `makeNeovimUnstable` wrapper +- Migrated neovim-flake to `makeNeovimUnstable` wrapper. [notashelf](https://github.com/notashelf): -- Finished moving to `nixosOptionsDoc` in the documentation and changelog. We are fully free of asciidoc now +- Finished moving to `nixosOptionsDoc` in the documentation and changelog. All documentation options + and files are fully free of Asciidoc, and will now use Nixpkgs flavored markdown. -- Bumped plugin inputs to their latest versions +- Bumped plugin inputs to their latest versions. - Deprecated `presence.nvim` in favor of `neocord`. This means `vim.rich-presence.presence-nvim` is removed and will throw - a warning if used. You are recommended to rewrite your neocord configuration from scratch based on the + a warning if used. You are recommended to rewrite your neocord configuration from scratch based on the. [official documentation](https://github.com/IogaMaster/neocord) -- Removed Tabnine plugin due to the usage of imperative tarball downloads. If you'd like to see it back, please make an issue. +- Removed Tabnine plugin due to the usage of imperative tarball downloads. If you'd like to see it back, please create an issue. - Added support for css and tailwindcss through vscode-language-servers-extracted & tailwind-language-server. - Those can be enabled through `vim.languages.css` and `vim.languages.tailwind` + Those can be enabled through `vim.languages.css` and `vim.languages.tailwind`. - Lualine module now allows customizing `always_divide_middle`, `ignore_focus` and `disabled_filetypes` through the new options: [vim.statusline.lualine.alwaysDivideMiddle](vim.statusline.lualine.alwaysDivideMiddle), [vim.statusline.lualine.ignoreFocus](vim.statusline.lualine.ignoreFocus) and - [vim.statusline.lualine.disabledFiletypes](vim.statusline.lualine.disabledFiletypes) + [vim.statusline.lualine.disabledFiletypes](vim.statusline.lualine.disabledFiletypes). -- Updated all plugin inputs to their latest versions (**14.04.2024**) - this brought minor color changes to the Catppuccin +- Updated all plugin inputs to their latest versions (**21.04.2024**) - this brought minor color changes to the Catppuccin theme. - Moved home-manager module entrypoint to `flake/modules` and added an experimental Nixos module. This requires further testing