diff --git a/flake.lock b/flake.lock deleted file mode 100644 index e523825..0000000 --- a/flake.lock +++ /dev/null @@ -1,657 +0,0 @@ -{ - "nodes": { - "arion": { - "inputs": { - "flake-parts": "flake-parts", - "haskell-flake": "haskell-flake", - "hercules-ci-effects": "hercules-ci-effects", - "nixpkgs": "nixpkgs" - }, - "locked": { - "lastModified": 1720147808, - "narHash": "sha256-hlWEQGUbIwYb+vnd8egzlW/P++yKu3HjV/rOdOPVank=", - "owner": "hercules-ci", - "repo": "arion", - "rev": "236f9dd82d6ef6a2d9987c7a7df3e75f1bc8b318", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "arion", - "rev": "236f9dd82d6ef6a2d9987c7a7df3e75f1bc8b318", - "type": "github" - } - }, - "base16-schemes": { - "flake": false, - "locked": { - "lastModified": 1696158499, - "narHash": "sha256-5yIHgDTPjoX/3oDEfLSQ0eJZdFL1SaCfb9d6M0RmOTM=", - "owner": "tinted-theming", - "repo": "base16-schemes", - "rev": "a9112eaae86d9dd8ee6bb9445b664fba2f94037a", - "type": "github" - }, - "original": { - "owner": "tinted-theming", - "repo": "base16-schemes", - "type": "github" - } - }, - "devshell": { - "inputs": { - "nixpkgs": [ - "nixvim", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1728330715, - "narHash": "sha256-xRJ2nPOXb//u1jaBnDP56M7v5ldavjbtR6lfGqSvcKg=", - "owner": "numtide", - "repo": "devshell", - "rev": "dd6b80932022cea34a019e2bb32f6fa9e494dfef", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "devshell", - "type": "github" - } - }, - "disko": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1715070411, - "narHash": "sha256-5CNvkH0Nf7yMwgKhjUNg/lUK40C7DXB4zKOuA2jVO90=", - "owner": "nix-community", - "repo": "disko", - "rev": "4677f6c53482a8b01ee93957e3bdd569d51261d6", - "type": "github" - }, - "original": { - "owner": "nix-community", - "ref": "v1.6.1", - "repo": "disko", - "type": "github" - } - }, - "extra-container": { - "inputs": { - "flake-utils": [ - "nix-bitcoin", - "flake-utils" - ], - "nixpkgs": [ - "nix-bitcoin", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1722175938, - "narHash": "sha256-HKyB4HD+NdX3T233bY31hm76v3/tdQBNeLLvopKbZeY=", - "owner": "erikarvstedt", - "repo": "extra-container", - "rev": "37e7207ac9f857eedb58b208b9dc91cd6b24e651", - "type": "github" - }, - "original": { - "owner": "erikarvstedt", - "repo": "extra-container", - "type": "github" - } - }, - "flake-compat": { - "locked": { - "lastModified": 1696426674, - "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", - "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", - "revCount": 57, - "type": "tarball", - "url": "https://api.flakehub.com/f/pinned/edolstra/flake-compat/1.0.1/018afb31-abd1-7bff-a5e4-cff7e18efb7a/source.tar.gz" - }, - "original": { - "type": "tarball", - "url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz" - } - }, - "flake-compat_2": { - "flake": false, - "locked": { - "lastModified": 1696426674, - "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", - "type": "github" - }, - "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, - "flake-parts": { - "inputs": { - "nixpkgs-lib": [ - "arion", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1719994518, - "narHash": "sha256-pQMhCCHyQGRzdfAkdJ4cIWiw+JNuWsTX7f0ZYSyz0VY=", - "owner": "hercules-ci", - "repo": "flake-parts", - "rev": "9227223f6d922fee3c7b190b2cc238a99527bbb7", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "flake-parts", - "type": "github" - } - }, - "flake-parts_2": { - "inputs": { - "nixpkgs-lib": [ - "arion", - "hercules-ci-effects", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1712014858, - "narHash": "sha256-sB4SWl2lX95bExY2gMFG5HIzvva5AVMJd4Igm+GpZNw=", - "owner": "hercules-ci", - "repo": "flake-parts", - "rev": "9126214d0a59633752a136528f5f3b9aa8565b7d", - "type": "github" - }, - "original": { - "id": "flake-parts", - "type": "indirect" - } - }, - "flake-parts_3": { - "inputs": { - "nixpkgs-lib": [ - "nixvim", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1727826117, - "narHash": "sha256-K5ZLCyfO/Zj9mPFldf3iwS6oZStJcU4tSpiXTMYaaL0=", - "owner": "hercules-ci", - "repo": "flake-parts", - "rev": "3d04084d54bedc3d6b8b736c70ef449225c361b1", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "flake-parts", - "type": "github" - } - }, - "flake-utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1726560853, - "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "git-hooks": { - "inputs": { - "flake-compat": "flake-compat_2", - "gitignore": "gitignore", - "nixpkgs": [ - "nixvim", - "nixpkgs" - ], - "nixpkgs-stable": [ - "nixvim", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1729087992, - "narHash": "sha256-u9bQsT6G/yzDVQ7xCcudnKXkS4ZR240Y4Cd9BmrKejc=", - "owner": "cachix", - "repo": "git-hooks.nix", - "rev": "43983c5976fef25e774e3f1c9bd04f658e9481c3", - "type": "github" - }, - "original": { - "owner": "cachix", - "repo": "git-hooks.nix", - "type": "github" - } - }, - "gitignore": { - "inputs": { - "nixpkgs": [ - "nixvim", - "git-hooks", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1709087332, - "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", - "owner": "hercules-ci", - "repo": "gitignore.nix", - "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "gitignore.nix", - "type": "github" - } - }, - "haskell-flake": { - "locked": { - "lastModified": 1675296942, - "narHash": "sha256-u1X1sblozi5qYEcLp1hxcyo8FfDHnRUVX3dJ/tW19jY=", - "owner": "srid", - "repo": "haskell-flake", - "rev": "c2cafce9d57bfca41794dc3b99c593155006c71e", - "type": "github" - }, - "original": { - "owner": "srid", - "ref": "0.1.0", - "repo": "haskell-flake", - "type": "github" - } - }, - "hercules-ci-effects": { - "inputs": { - "flake-parts": "flake-parts_2", - "nixpkgs": [ - "arion", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1719226092, - "narHash": "sha256-YNkUMcCUCpnULp40g+svYsaH1RbSEj6s4WdZY/SHe38=", - "owner": "hercules-ci", - "repo": "hercules-ci-effects", - "rev": "11e4b8dc112e2f485d7c97e1cee77f9958f498f5", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "hercules-ci-effects", - "type": "github" - } - }, - "home-manager": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1726989464, - "narHash": "sha256-Vl+WVTJwutXkimwGprnEtXc/s/s8sMuXzqXaspIGlwM=", - "owner": "nix-community", - "repo": "home-manager", - "rev": "2f23fa308a7c067e52dfcc30a0758f47043ec176", - "type": "github" - }, - "original": { - "owner": "nix-community", - "ref": "release-24.05", - "repo": "home-manager", - "type": "github" - } - }, - "home-manager_2": { - "inputs": { - "nixpkgs": [ - "nixvim", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1726989464, - "narHash": "sha256-Vl+WVTJwutXkimwGprnEtXc/s/s8sMuXzqXaspIGlwM=", - "owner": "nix-community", - "repo": "home-manager", - "rev": "2f23fa308a7c067e52dfcc30a0758f47043ec176", - "type": "github" - }, - "original": { - "owner": "nix-community", - "ref": "release-24.05", - "repo": "home-manager", - "type": "github" - } - }, - "impermanence": { - "locked": { - "lastModified": 1729068498, - "narHash": "sha256-C2sGRJl1EmBq0nO98TNd4cbUy20ABSgnHWXLIJQWRFA=", - "owner": "nix-community", - "repo": "impermanence", - "rev": "e337457502571b23e449bf42153d7faa10c0a562", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "impermanence", - "type": "github" - } - }, - "nix-bitcoin": { - "inputs": { - "extra-container": "extra-container", - "flake-utils": "flake-utils", - "nixpkgs": [ - "nixpkgs" - ], - "nixpkgs-unstable": "nixpkgs-unstable" - }, - "locked": { - "lastModified": 1727247704, - "narHash": "sha256-Jl1CYXNIdJ4Ac0MK15e8+vflFOgPxZZNw24CKfLC6QY=", - "owner": "fort-nix", - "repo": "nix-bitcoin", - "rev": "a0d36d59248ac54f1b42a668326346a77640c7f5", - "type": "github" - }, - "original": { - "owner": "fort-nix", - "ref": "nixos-24.05", - "repo": "nix-bitcoin", - "type": "github" - } - }, - "nix-colors": { - "inputs": { - "base16-schemes": "base16-schemes", - "nixpkgs-lib": "nixpkgs-lib" - }, - "locked": { - "lastModified": 1707825078, - "narHash": "sha256-hTfge2J2W+42SZ7VHXkf4kjU+qzFqPeC9k66jAUBMHk=", - "owner": "misterio77", - "repo": "nix-colors", - "rev": "b01f024090d2c4fc3152cd0cf12027a7b8453ba1", - "type": "github" - }, - "original": { - "owner": "misterio77", - "repo": "nix-colors", - "type": "github" - } - }, - "nix-darwin": { - "inputs": { - "nixpkgs": [ - "nixvim", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1728901530, - "narHash": "sha256-I9Qd0LnAsEGHtKE9+uVR0iDFmsijWSy7GT0g3jihG4Q=", - "owner": "lnl7", - "repo": "nix-darwin", - "rev": "a60ac02f9466f85f092e576fd8364dfc4406b5a6", - "type": "github" - }, - "original": { - "owner": "lnl7", - "repo": "nix-darwin", - "type": "github" - } - }, - "nix-secrets": { - "locked": { - "lastModified": 1729849584, - "narHash": "sha256-byrCBtIcqFLEUoLCAli5g4w1allf4kPrxFV7+3jenCI=", - "ref": "refs/heads/master", - "rev": "97c60da5f7e750b8d4cdcaacee4dfab393cabb94", - "revCount": 187, - "type": "git", - "url": "ssh://git@git.bitlab21.com/sam/nix-secrets.git" - }, - "original": { - "type": "git", - "url": "ssh://git@git.bitlab21.com/sam/nix-secrets.git" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 1720031269, - "narHash": "sha256-rwz8NJZV+387rnWpTYcXaRNvzUSnnF9aHONoJIYmiUQ=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "9f4128e00b0ae8ec65918efeba59db998750ead6", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs-lib": { - "locked": { - "lastModified": 1697935651, - "narHash": "sha256-qOfWjQ2JQSQL15KLh6D7xQhx0qgZlYZTYlcEiRuAMMw=", - "owner": "nix-community", - "repo": "nixpkgs.lib", - "rev": "e1e11fdbb01113d85c7f41cada9d2847660e3902", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "nixpkgs.lib", - "type": "github" - } - }, - "nixpkgs-stable": { - "locked": { - "lastModified": 1729357638, - "narHash": "sha256-66RHecx+zohbZwJVEPF7uuwHeqf8rykZTMCTqIrOew4=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "bb8c2cf7ea0dd2e18a52746b2c3a5b0c73b93c22", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "release-24.05", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs-unstable": { - "locked": { - "lastModified": 1726871744, - "narHash": "sha256-V5LpfdHyQkUF7RfOaDPrZDP+oqz88lTJrMT1+stXNwo=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "a1d92660c6b3b7c26fb883500a80ea9d33321be2", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs-unstable_2": { - "locked": { - "lastModified": 1729665710, - "narHash": "sha256-AlcmCXJZPIlO5dmFzV3V2XF6x/OpNWUV8Y/FMPGd8Z4=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "2768c7d042a37de65bb1b5b3268fc987e534c49d", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_2": { - "locked": { - "lastModified": 1729805696, - "narHash": "sha256-FArm/EIAbykrhtWxWKT1QXIg+dD44joehXZWdY12WKc=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "50286248f2d7283682bdd47ba14af33a9233b88b", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "release-24.05", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixvim": { - "inputs": { - "devshell": "devshell", - "flake-compat": "flake-compat", - "flake-parts": "flake-parts_3", - "git-hooks": "git-hooks", - "home-manager": "home-manager_2", - "nix-darwin": "nix-darwin", - "nixpkgs": [ - "nixpkgs" - ], - "treefmt-nix": "treefmt-nix" - }, - "locked": { - "lastModified": 1729100089, - "narHash": "sha256-B44+e/cYjrzgaDvCNz9TyHQy0q9Q6WaDISV57jxejJ8=", - "owner": "nix-community", - "repo": "nixvim", - "rev": "341dbb1b5867adb95d75e6dabef6627eb0eae38e", - "type": "github" - }, - "original": { - "owner": "nix-community", - "ref": "nixos-24.05", - "repo": "nixvim", - "type": "github" - } - }, - "nur": { - "locked": { - "lastModified": 1729849610, - "narHash": "sha256-JFv2KC4LIqVFbHIlvWmNbp4lFcejMKINlpEUspOO10k=", - "owner": "nix-community", - "repo": "NUR", - "rev": "5a807a981707c8bdea38a643b499a9ac4d493132", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "NUR", - "type": "github" - } - }, - "root": { - "inputs": { - "arion": "arion", - "disko": "disko", - "home-manager": "home-manager", - "impermanence": "impermanence", - "nix-bitcoin": "nix-bitcoin", - "nix-colors": "nix-colors", - "nix-secrets": "nix-secrets", - "nixpkgs": "nixpkgs_2", - "nixpkgs-unstable": "nixpkgs-unstable_2", - "nixvim": "nixvim", - "nur": "nur", - "sops-nix": "sops-nix" - } - }, - "sops-nix": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ], - "nixpkgs-stable": "nixpkgs-stable" - }, - "locked": { - "lastModified": 1729775275, - "narHash": "sha256-J2vtHq9sw1wWm0aTMXpEEAzsVCUMZDTEe5kiBYccpLE=", - "owner": "mic92", - "repo": "sops-nix", - "rev": "78a0e634fc8981d6b564f08b6715c69a755c4c7d", - "type": "github" - }, - "original": { - "owner": "mic92", - "repo": "sops-nix", - "type": "github" - } - }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - }, - "treefmt-nix": { - "inputs": { - "nixpkgs": [ - "nixvim", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1729077719, - "narHash": "sha256-zayHqZO9gA1U85c4CPvVSnLV8/cBgc2yVrSKWaKeBUs=", - "owner": "numtide", - "repo": "treefmt-nix", - "rev": "5307ba60125bb024d7e52d71d582eafd511f3fee", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "treefmt-nix", - "type": "github" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/home/common/core/default.nix b/home/common/core/default.nix index db9a86f..31a09bb 100644 --- a/home/common/core/default.nix +++ b/home/common/core/default.nix @@ -1,4 +1,4 @@ -{ pkgs, inputs, outputs, ... }: +{ pkgs, inputs, outputs, lib, ... }: { imports = [ inputs.nix-colors.homeManagerModules.default diff --git a/home/common/core/nixvim/default.nix b/home/common/core/nixvim/default.nix index 80d1209..d0f9db2 100644 --- a/home/common/core/nixvim/default.nix +++ b/home/common/core/nixvim/default.nix @@ -28,6 +28,7 @@ ]; programs.nixvim = { enable = true; + package = pkgs.unstable.neovim-unwrapped; enableMan = true; # install man pages for nixvim options clipboard.register = "unnamedplus"; # use system clipboard instead of internal registers globals.mapleader = " "; diff --git a/home/common/core/nixvim/plugins/default.nix b/home/common/core/nixvim/plugins/default.nix index 348b687..fe13b79 100644 --- a/home/common/core/nixvim/plugins/default.nix +++ b/home/common/core/nixvim/plugins/default.nix @@ -1,10 +1,18 @@ { pkgs, config, + lib, + inputs, ... }: let user = config.home.username; + mistralAPIKey = lib.optionalString (lib.hasAttr "sops-nix" inputs) config.sops.secrets."mistral-api-key".path; in { + sops.secrets = { + "mistral-api-key" = { + }; + }; + imports = [ ./cmp.nix ./colorizer.nix @@ -32,6 +40,18 @@ in { pkgs.vimPlugins.vim-dadbod-ui pkgs.vimPlugins.vim-dadbod-completion pkgs.vimPlugins.fugitive + + (pkgs.vimUtils.buildVimPlugin + { + name = "parrot.nvim"; + src = pkgs.fetchFromGitHub { + owner = "frankroeder"; + repo = "parrot.nvim"; + rev = "c992483"; + sha256 = "sha256-P899qNY/h5LTW0pp3sAmcSDsDGWQedXa20J7EggL7F8="; + }; + }) + (pkgs.vimUtils.buildVimPlugin { name = "buffer_manager.nvim"; @@ -58,6 +78,18 @@ in { pkgs.vimPlugins.vim-devicons ]; programs.nixvim.extraConfigLua = '' + -- function to read api key from secrets file + local function read_api_key(file_path) + local file = io.open(file_path, "r") + if file then + local api_key = file:read("*all") + file:close() + return api_key + else + error("Failed to open file: " .. file_path) + end + end + -- buffer_manager.nvim local opts = {noremap = true} @@ -123,5 +155,71 @@ in { end require("conform").format({ async = true, lsp_format = "fallback", range = range }) end, { range = true }) + + -- parrot.nvim setup + require("parrot").setup { + toggle_target = "popup", + providers = { + mistral = { + api_key = read_api_key("${mistralAPIKey}"), + params = { + chat = { temperature = 0, top_p = 1, max_tokens = 16384 }, + command = { temperature = 0, top_p = 1, max_tokens = 16384 }, + }, + -- api_key = os.getenv "MISTRAL_API_KEY", + }, + }, + hooks = { + AskCoder = function(prt, params) + local prompt = [[ + You are a code assistent. Answer my question carefully and concisely. + Answer with code snippets only. Do not give a summary or include any + code comments in your response. Never repeate code from a prevous + response or write obvious or unnecessary code, instead refer to such + code like: "**rest of code here**", or something to that effect. + Tokens are expensive, to we need to be very consice. If you uses + excessive tokens, then I will send you the invoice to pay the bill. + Question: {{command}} + ``` + ]] + prt.ChatNew(params, prompt) + end, + + AskCoderSel = function(parrot, params) + local template = [[ + You are an expert programmer. Here is a code snippet along with a + question. Give me a short, accurate and consice answer. + + ```{{filetype}} + {{selection}} + ``` + ]] + local model_obj = parrot.get_model("command") + parrot.logger.info("Asking model: " .. model_obj.name) + parrot.Prompt(params, parrot.ui.Target.popup, model_obj, "🤖 Ask ~ ", template) + end, + + GitCommit = function(parrot, params) + local template = [[ + You are a git commit generator. You will be provided with a git diff file. + Your role is to create a concise commit message that outlines all of the + most relevant and impactful changes in the diff. You only output a commit + message, do not write anything else not related to the commit. Use + imperative mood for you writing style. Your message should include a + short summary in the first line followed by more detailed descriptions of + the changes on subsequent lines. The first line summary should be no more + than 70 characters, not end with a period, and a blank line should + separate the summary from the body of the message. There should only be 1 + summary line, and 1 body with the description. The body should include no + more than 3 bullet points with more detailed descriptions of the files + and functions that have been modified. Do not output any code. + Diff: {{selection}} + ]] + local model_obj = parrot.get_model("command") + parrot.logger.info("Asking model: " .. model_obj.name) + parrot.Prompt(params, parrot.ui.Target.popup, model_obj, nil, template) + end, + } + } ''; }