diff --git a/flake.lock b/flake.lock index 109e37c..e7d4b27 100644 --- a/flake.lock +++ b/flake.lock @@ -68,6 +68,22 @@ "type": "github" } }, + "codecompanion-nvim": { + "flake": false, + "locked": { + "lastModified": 1726570621, + "narHash": "sha256-LeHopERAqK0YStQ4/RlnRwG+VPFGFgXaZW2apENbG8w=", + "owner": "olimorris", + "repo": "codecompanion.nvim", + "rev": "3422b1ccd8bed844c25965de8428c05581bdfc2f", + "type": "github" + }, + "original": { + "owner": "olimorris", + "repo": "codecompanion.nvim", + "type": "github" + } + }, "darwin": { "inputs": { "nixpkgs": [ @@ -89,6 +105,22 @@ "type": "github" } }, + "dressing-nvim": { + "flake": false, + "locked": { + "lastModified": 1723846795, + "narHash": "sha256-6T2p0hI7/WqaDFQodaDq7uiyuplVqeekayQ2equ/mC0=", + "owner": "stevearc", + "repo": "dressing.nvim", + "rev": "c5775a888adbc50652cb370073fcfec963eca93e", + "type": "github" + }, + "original": { + "owner": "stevearc", + "repo": "dressing.nvim", + "type": "github" + } + }, "flake-compat": { "flake": false, "locked": { @@ -200,11 +232,11 @@ ] }, "locked": { - "lastModified": 1726298287, - "narHash": "sha256-wvtyOH5X2euU7CISBg2jNVpc2cGP1rJ2bsatBLDwjGc=", + "lastModified": 1726440980, + "narHash": "sha256-ChhIrjtdu5d83W+YDRH+Ec5g1MmM0xk6hJnkz15Ot7M=", "owner": "nix-community", "repo": "home-manager", - "rev": "7edf6ccaec8001cb20368bf1bf6a677178cae07b", + "rev": "a9c9cc6e50f7cbd2d58ccb1cd46a1e06e9e445ff", "type": "github" }, "original": { @@ -217,11 +249,11 @@ "homebrew-bundle": { "flake": false, "locked": { - "lastModified": 1725921911, - "narHash": "sha256-YuAQf3IP3eTITYrptapH8xeU9aHkN0ncNnUnWtHg3Zk=", + "lastModified": 1726531370, + "narHash": "sha256-y2qkcaISsExNdXdUsXgxCn9oLGGfjf9XmzKlS5rgCZk=", "owner": "homebrew", "repo": "homebrew-bundle", - "rev": "acfb8210d4366ff63fa23d6a7a8ddbacd0234532", + "rev": "413f755db611ad088024fd206dd9f0e44818574c", "type": "github" }, "original": { @@ -250,11 +282,11 @@ "homebrew-core": { "flake": false, "locked": { - "lastModified": 1726306519, - "narHash": "sha256-uCBnEnJTGaOCHBoh1HNLYbMWhrIguoC0MwdIGdg0M9c=", + "lastModified": 1726583512, + "narHash": "sha256-XY9jnOukBujdKrw/DzkwJ9QuOuAvNhflqeW/bAT8FPo=", "owner": "homebrew", "repo": "homebrew-core", - "rev": "0f23f45c4d933e0b7e16a9fd95540bc34df2ad51", + "rev": "4e2da021cdded193a82b968d540084905ef48519", "type": "github" }, "original": { @@ -300,6 +332,22 @@ "type": "github" } }, + "mini-diff": { + "flake": false, + "locked": { + "lastModified": 1725613926, + "narHash": "sha256-OYwBALQ+qmuky1SC1mMKqXHNnZlYQwoyxEapcrQZeUE=", + "owner": "echasnovski", + "repo": "mini.diff", + "rev": "24d46798be8a358d38d3adc92c7ebcbb2d6f67e0", + "type": "github" + }, + "original": { + "owner": "echasnovski", + "repo": "mini.diff", + "type": "github" + } + }, "nix-darwin": { "inputs": { "nixpkgs": "nixpkgs_3" @@ -344,11 +392,11 @@ "nixpkgs": "nixpkgs_5" }, "locked": { - "lastModified": 1725925707, - "narHash": "sha256-AT9tKu3wbUyWCw+FoaP/sxpvGj1rQ0q3V9bdARVw2Ts=", + "lastModified": 1726523552, + "narHash": "sha256-RqOJeQlX2+H5j+RdFzTc7QSf4/qK4Oe01KpE2713Cws=", "owner": "BirdeeHub", "repo": "nixCats-nvim", - "rev": "bec49a10a76ceeaa93dfaa29d49104822232caf9", + "rev": "2b455dab0eee7484ce7c956dccda0a7c2111c18b", "type": "github" }, "original": { @@ -405,11 +453,11 @@ }, "nixpkgs-stable": { "locked": { - "lastModified": 1726062281, - "narHash": "sha256-PyFVySdGj3enKqm8RQuo4v1KLJLmNLOq2yYOHsI6e2Q=", + "lastModified": 1726447378, + "narHash": "sha256-2yV8nmYE1p9lfmLHhOCbYwQC/W8WYfGQABoGzJOb1JQ=", "owner": "nixos", "repo": "nixpkgs", - "rev": "e65aa8301ba4f0ab8cb98f944c14aa9da07394f8", + "rev": "086b448a5d54fd117f4dc2dee55c9f0ff461bdc1", "type": "github" }, "original": { @@ -482,11 +530,11 @@ }, "nixpkgs_6": { "locked": { - "lastModified": 1726062873, - "narHash": "sha256-IiA3jfbR7K/B5+9byVi9BZGWTD4VSbWe8VLpp9B/iYk=", + "lastModified": 1726463316, + "narHash": "sha256-gI9kkaH0ZjakJOKrdjaI/VbaMEo9qBbSUl93DnU7f4c=", "owner": "nixos", "repo": "nixpkgs", - "rev": "4f807e8940284ad7925ebd0a0993d2a1791acb2f", + "rev": "99dc8785f6a0adac95f5e2ab05cc2e1bf666d172", "type": "github" }, "original": { @@ -544,26 +592,12 @@ "type": "github" } }, - "parrot-nvim": { - "flake": false, - "locked": { - "lastModified": 1726302691, - "narHash": "sha256-mwkgRRW3KUNJ5NaGe92cKfOe3eLs1sVwfdNY3/SmWXA=", - "owner": "frankroeder", - "repo": "parrot.nvim", - "rev": "0db1e3beff0c434fec13c809bd105a4485946ece", - "type": "github" - }, - "original": { - "owner": "frankroeder", - "repo": "parrot.nvim", - "type": "github" - } - }, "root": { "inputs": { "alacritty-theme": "alacritty-theme", + "codecompanion-nvim": "codecompanion-nvim", "darwin": "darwin", + "dressing-nvim": "dressing-nvim", "gx-nvim": "gx-nvim", "home-manager": "home-manager", "homebrew-bundle": "homebrew-bundle", @@ -571,13 +605,13 @@ "homebrew-core": "homebrew-core", "mac-app-util": "mac-app-util", "macos-keyboard-layout-german-programming": "macos-keyboard-layout-german-programming", + "mini-diff": "mini-diff", "nix-homebrew": "nix-homebrew", "nixCats": "nixCats", "nixpkgs": "nixpkgs_6", "nixpkgs-stable": "nixpkgs-stable", "nvim-nio": "nvim-nio", "nvim-tmux-navigation": "nvim-tmux-navigation", - "parrot-nvim": "parrot-nvim", "talhelper": "talhelper" } }, @@ -617,11 +651,11 @@ "nixpkgs": "nixpkgs_7" }, "locked": { - "lastModified": 1726284843, - "narHash": "sha256-cPhG4Bmm598L9eJdD5QFXP1l6aoXQejYzH9IXclWSwo=", + "lastModified": 1726535407, + "narHash": "sha256-Qg6aCVBpi18RHu9tnwxN2cbVFa9dh6EKe4+15rnq2NE=", "owner": "budimanjojo", "repo": "talhelper", - "rev": "bec22d82701096b4cba908ce0cf39fd6e5a58c3f", + "rev": "9f73b7729388b825bdf90c631a7ee53e53ced4ec", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 5e97398..112e5c5 100644 --- a/flake.nix +++ b/flake.nix @@ -60,8 +60,16 @@ url = "github:nvim-neotest/nvim-nio"; flake = false; }; - parrot-nvim = { - url = "github:frankroeder/parrot.nvim"; + codecompanion-nvim = { + url = "github:olimorris/codecompanion.nvim"; + flake = false; + }; + dressing-nvim = { + url = "github:stevearc/dressing.nvim"; + flake = false; + }; + mini-diff = { + url = "github:echasnovski/mini.diff"; flake = false; }; diff --git a/modules/common/nvim/default.nix b/modules/common/nvim/default.nix index 079a5b6..b124ca2 100644 --- a/modules/common/nvim/default.nix +++ b/modules/common/nvim/default.nix @@ -93,8 +93,10 @@ let nvim-nio ]; ai = with pkgs.vimPlugins; [ - parrot-nvim - fzf-lua + codecompanion-nvim + dressing-nvim + mini-diff + copilot-lua ]; general = with pkgs.vimPlugins; { theme = builtins.getAttr packageDef.categories.colorscheme { diff --git a/modules/common/nvim/lua/chrishrb/lsp/handlers.lua b/modules/common/nvim/lua/chrishrb/lsp/handlers.lua index 8561593..5fb508a 100644 --- a/modules/common/nvim/lua/chrishrb/lsp/handlers.lua +++ b/modules/common/nvim/lua/chrishrb/lsp/handlers.lua @@ -115,7 +115,7 @@ local function lsp_keymaps(bufnr) end M.on_attach = function(client, bufnr) - if client.name == "tsserver" then + if client.name == "ts_ls" then client.server_capabilities.document_formatting = false end lsp_keymaps(bufnr) diff --git a/modules/common/nvim/lua/chrishrb/lsp/mason.lua b/modules/common/nvim/lua/chrishrb/lsp/mason.lua index 39b6b1e..d4d5419 100644 --- a/modules/common/nvim/lua/chrishrb/lsp/mason.lua +++ b/modules/common/nvim/lua/chrishrb/lsp/mason.lua @@ -53,7 +53,7 @@ if nixCats("php") then end if nixCats("web") then - servers[#servers + 1] = "tsserver" + servers[#servers + 1] = "ts_ls" servers[#servers + 1] = "tailwindcss" servers[#servers + 1] = "volar" end diff --git a/modules/common/nvim/lua/chrishrb/plugins/config/codecompanion-lualine.lua b/modules/common/nvim/lua/chrishrb/plugins/config/codecompanion-lualine.lua new file mode 100644 index 0000000..86c779e --- /dev/null +++ b/modules/common/nvim/lua/chrishrb/plugins/config/codecompanion-lualine.lua @@ -0,0 +1,49 @@ +local M = require("lualine.component"):extend() + +M.processing = false +M.spinner_index = 1 + +local spinner_symbols = { + "⠋", + "⠙", + "⠹", + "⠸", + "⠼", + "⠴", + "⠦", + "⠧", + "⠇", + "⠏", +} +local spinner_symbols_len = 10 + +-- Initializer +function M:init(options) + M.super.init(self, options) + + local group = vim.api.nvim_create_augroup("CodeCompanionHooks", {}) + + vim.api.nvim_create_autocmd({ "User" }, { + pattern = "CodeCompanionRequest*", + group = group, + callback = function(request) + if request.match == "CodeCompanionRequestStarted" then + self.processing = true + elseif request.match == "CodeCompanionRequestFinished" then + self.processing = false + end + end, + }) +end + +-- Function that runs every time statusline is updated +function M:update_status() + if self.processing then + self.spinner_index = (self.spinner_index % spinner_symbols_len) + 1 + return spinner_symbols[self.spinner_index] + else + return nil + end +end + +return M diff --git a/modules/common/nvim/lua/chrishrb/plugins/config/codecompanion.lua b/modules/common/nvim/lua/chrishrb/plugins/config/codecompanion.lua new file mode 100644 index 0000000..f46b7fc --- /dev/null +++ b/modules/common/nvim/lua/chrishrb/plugins/config/codecompanion.lua @@ -0,0 +1,48 @@ +require("dressing").setup({ + input = { + enabled = false + }, + select = { + enabled = true + } +}) + +require("codecompanion").setup({ + display = { + action_palette = { + prompt = "🤖 ~ " + } + }, + strategies = { + chat = { + adapter = "copilot", + }, + inline = { + adapter = "copilot", + }, + agent = { + adapter = "copilot", + }, + }, +}) + +-- setup which-key mappings +local which_key = require("which-key") +which_key.add({ + { + { "c", group = "CodeCompanion (AI)", nowait = true, remap = false }, + { "cc", "CodeCompanion", desc = "Quick chat", nowait = true, remap = false }, + { "ca", "CodeCompanionActions", desc = "Actions", nowait = true, remap = false }, + { "co", "CodeCompanionChat", desc = "New Chat", nowait = true, remap = false }, + { "ct", "CodeCompanionToggle", desc = "Toggle chat", nowait = true, remap = false }, + { + mode = { "v" }, + { "c", group = "CodeCompanion (AI)", nowait = true, remap = false }, + { "cc", ":CodeCompanion", desc = "Quick chat", nowait = true, remap = false }, + { "ca", ":CodeCompanionActions", desc = "Actions", nowait = true, remap = false }, + }, + } +}) + +-- Expand 'cc' into 'CodeCompanion' in the command line +vim.cmd([[cab cc CodeCompanion]]) diff --git a/modules/common/nvim/lua/chrishrb/plugins/config/lualine.lua b/modules/common/nvim/lua/chrishrb/plugins/config/lualine.lua index 6c46435..caa0856 100644 --- a/modules/common/nvim/lua/chrishrb/plugins/config/lualine.lua +++ b/modules/common/nvim/lua/chrishrb/plugins/config/lualine.lua @@ -122,6 +122,12 @@ local lsp = { color = { bg = "#f38ba8", fg = "#1e1e2e" }, } +local codecompanion = { + require('chrishrb.plugins.config.codecompanion-lualine'), + color = { bg = "#b4befe", fg = "#313244" }, + separator = { left = icons.ui.HalfCircleLeft }, +} + require('lualine').setup { options = { @@ -165,6 +171,7 @@ require('lualine').setup { space, }, lualine_y = { + codecompanion, encoding, fileformat, space, diff --git a/modules/common/nvim/lua/chrishrb/plugins/init.lua b/modules/common/nvim/lua/chrishrb/plugins/init.lua index 9379876..e707ff9 100644 --- a/modules/common/nvim/lua/chrishrb/plugins/init.lua +++ b/modules/common/nvim/lua/chrishrb/plugins/init.lua @@ -228,12 +228,27 @@ local plugins = { ----------------------------------------------------------------------------- -- AI ----------------------------------------------------------------------------- - { - "frankroeder/parrot.nvim", - dependencies = { 'ibhagwan/fzf-lua', 'nvim-lua/plenary.nvim' }, - -- optionally include "rcarriga/nvim-notify" for beautiful notifications - config = function() require("chrishrb.plugins.config.parrot") end, + "olimorris/codecompanion.nvim", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-treesitter/nvim-treesitter", + "hrsh7th/nvim-cmp", -- Optional: For using slash commands and variables in the chat buffer + "echasnovski/mini.diff", + { + "zbirenbaum/copilot.lua", + cmd = "Copilot", + config = function () + require("copilot").setup({}) + end + }, + { + "stevearc/dressing.nvim", -- Optional: Improves the default Neovim UI + opts = {}, + }, + "nvim-telescope/telescope.nvim", -- Optional: For using slash commands + }, + config = function() require("chrishrb.plugins.config.codecompanion") end, }, ----------------------------------------------------------------------------- diff --git a/modules/common/nvim/overlays/default.nix b/modules/common/nvim/overlays/default.nix index 0889270..b3c5074 100644 --- a/modules/common/nvim/overlays/default.nix +++ b/modules/common/nvim/overlays/default.nix @@ -1,10 +1,20 @@ inputs: _final: prev: { vimPlugins = prev.vimPlugins.extend (final': prev': { - # parrot ai - parrot-nvim = prev.vimUtils.buildVimPlugin { - pname = "parrot.nvim"; + # codecompanion ai + codecompanion-nvim = prev.vimUtils.buildVimPlugin { + pname = "codecompanion.nvim"; + version = "2024-09-16"; + src = inputs.codecompanion-nvim; + }; + dressing-nvim = prev.vimUtils.buildVimPlugin { + pname = "dressing.nvim"; + version = "2024-09-13"; + src = inputs.dressing-nvim; + }; + mini-diff = prev.vimUtils.buildVimPlugin { + pname = "mini.diff"; version = "2024-09-13"; - src = inputs.parrot-nvim; + src = inputs.mini-diff; }; # gx.nvim diff --git a/modules/darwin/homebrew.nix b/modules/darwin/homebrew.nix index 15b7396..a879253 100644 --- a/modules/darwin/homebrew.nix +++ b/modules/darwin/homebrew.nix @@ -25,7 +25,6 @@ }; brews = [ #"grip" # open readme files - "gdal" ]; casks = [ # Communication Tools