diff --git a/chezmoi/dot_config/nvim/lua/aleidk/keymaps.lua b/chezmoi/dot_config/nvim/lua/aleidk/keymaps.lua index 75b54d7..fde7c73 100644 --- a/chezmoi/dot_config/nvim/lua/aleidk/keymaps.lua +++ b/chezmoi/dot_config/nvim/lua/aleidk/keymaps.lua @@ -4,6 +4,11 @@ function MAP(mode, l, r, desc) vim.keymap.set(mode, l, r, { desc = desc, silent = true }) end +function ReloadModule(module) + package.loaded[module] = nil + require(module) +end + local function default(desc) return { silent = true, @@ -59,10 +64,14 @@ vim.keymap.set("v", "p", [["_dP]], default("Paste without lossing yanked text")) vim.keymap.set("v", "J", ":m '>+1gv=gv", default("Move selection down")) vim.keymap.set("v", "K", ":m '<-2gv=gv", default("Move selection up")) vim.keymap.set("n", "uI", fixIndentation, default("Fix indentation")) +vim.keymap.set("n", "uO", function() ReloadModule('aleidk.options') end, + default("Reload the options configuration")) vim.keymap.set("n", "uh", ":nohl", default("Remove search highlight")) vim.keymap.set("t", "", "", default("Exit insert mode on terminal")) vim.keymap.set("n", "bc", "bd", default("Close buffer")) +vim.keymap.set("n", "bh", "bp", default("Prev buffer")) +vim.keymap.set("n", "bl", "bn", default("Next buffer")) vim.keymap.set("n", "bA", "bufdo bd", default("Close all buffers")) diff --git a/chezmoi/dot_config/nvim/lua/aleidk/plugins/ai.lua b/chezmoi/dot_config/nvim/lua/aleidk/plugins/ai.lua index db4d307..c7afdbe 100644 --- a/chezmoi/dot_config/nvim/lua/aleidk/plugins/ai.lua +++ b/chezmoi/dot_config/nvim/lua/aleidk/plugins/ai.lua @@ -1,208 +1,78 @@ return { - "jackMort/ChatGPT.nvim", - opts = { - api_key_cmd = nil, - yank_register = "+", - edit_with_instructions = { - diff = false, - keymaps = { - -- close = "", - -- accept = "", - -- toggle_diff = "", - -- toggle_settings = "", - -- toggle_help = "", - -- cycle_windows = "", - -- use_output_as_input = "", - submit = "", - }, - }, - chat = { - -- welcome_message = WELCOME_MESSAGE, - loading_text = "Loading, please wait ...", - question_sign = "", -- 🙂 - answer_sign = "ﮧ", -- 🤖 - border_left_sign = "", - border_right_sign = "", - max_line_length = 120, - sessions_window = { - active_sign = "  ", - inactive_sign = "  ", - current_line_sign = "", - border = { - style = "rounded", - text = { - top = " Sessions ", - }, - }, - win_options = { - winhighlight = "Normal:Normal,FloatBorder:FloatBorder", - }, - }, - keymaps = { - -- close = "", - -- yank_last = "", - -- yank_last_code = "", - -- scroll_up = "", - -- scroll_down = "", - -- new_session = "", - -- cycle_windows = "", - -- cycle_modes = "", - -- next_message = "", - -- prev_message = "", - -- select_session = "", - -- rename_session = "r", - -- delete_session = "d", - -- draft_message = "", - -- edit_message = "e", - -- delete_message = "d", - -- toggle_settings = "", - -- toggle_sessions = "", - -- toggle_help = "", - -- toggle_message_role = "", - -- toggle_system_role_open = "", - -- stop_generating = "", - submit = "", - }, - }, - popup_layout = { - default = "center", - center = { - width = "80%", - height = "80%", - }, - right = { - width = "30%", - width_settings_open = "50%", - }, - }, - popup_window = { - border = { - highlight = "FloatBorder", - style = "rounded", - text = { - top = " ChatGPT ", - }, - }, - win_options = { - wrap = true, - linebreak = true, - foldcolumn = "1", - winhighlight = "Normal:Normal,FloatBorder:FloatBorder", - }, - buf_options = { - filetype = "markdown", - }, - }, - system_window = { - border = { - highlight = "FloatBorder", - style = "rounded", - text = { - top = " SYSTEM ", - }, - }, - win_options = { - wrap = true, - linebreak = true, - foldcolumn = "2", - winhighlight = "Normal:Normal,FloatBorder:FloatBorder", - }, - }, - popup_input = { - prompt = "  ", - border = { - highlight = "FloatBorder", - style = "rounded", - text = { - top_align = "center", - top = " Prompt ", - }, - }, - win_options = { - winhighlight = "Normal:Normal,FloatBorder:FloatBorder", - }, - submit = "", - submit_n = "", - max_visible_lines = 20, - }, - settings_window = { - setting_sign = "  ", - border = { - style = "rounded", - text = { - top = " Settings ", - }, - }, - win_options = { - winhighlight = "Normal:Normal,FloatBorder:FloatBorder", - }, - }, - help_window = { - setting_sign = "  ", - border = { - style = "rounded", - text = { - top = " Help ", - }, - }, - win_options = { - winhighlight = "Normal:Normal,FloatBorder:FloatBorder", - }, - }, - openai_params = { - model = "gpt-3.5-turbo", - frequency_penalty = 0, - presence_penalty = 0, - max_tokens = 300, - temperature = 0, - top_p = 1, - n = 1, - }, - openai_edit_params = { - model = "gpt-3.5-turbo", - frequency_penalty = 0, - presence_penalty = 0, - temperature = 0, - top_p = 1, - n = 1, - }, - use_openai_functions_for_edits = false, - actions_paths = {}, - show_quickfixes_cmd = "Trouble quickfix", - predefined_chat_gpt_prompts = "https://raw.githubusercontent.com/f/awesome-chatgpt-prompts/main/prompts.csv", - highlights = { - help_key = "@symbol", - help_description = "@comment", - }, - }, - config = function() - require("chatgpt").setup() - end, + "olimorris/codecompanion.nvim", dependencies = { - "MunifTanjim/nui.nvim", "nvim-lua/plenary.nvim", - "folke/trouble.nvim", - "nvim-telescope/telescope.nvim", + "nvim-treesitter/nvim-treesitter", + { + "zbirenbaum/copilot.lua", + cmd = "Copilot", + event = "InsertEnter", + config = function() + require("copilot").setup({ + suggestion = { enabled = false }, + panel = { enabled = false }, + }) + end, + }, + "hrsh7th/nvim-cmp", -- Optional: For using slash commands and variables in the chat buffer + "nvim-telescope/telescope.nvim", -- Optional: For using slash commands + { "stevearc/dressing.nvim", opts = {} }, -- Optional: Improves `vim.ui.select` + }, + opts = { + strategies = { + chat = { + adapter = "copilot", + }, + inline = { + adapter = "copilot", + }, + agent = { adapter = "copilot" }, + }, + display = { + action_palette = { + prompt = " " + } + } }, keys = { - { "ap", "ChatGPT", desc = "ChatGPT" }, - { "ae", "ChatGPTEditWithInstruction", desc = "Edit with instruction", mode = { "n", "v" } }, - { "aa", "ChatGPTActAs", desc = "Act as", mode = { "n", "v" } }, - { "ag", "ChatGPTRun grammar_correction", desc = "Grammar Correction", mode = { "n", "v" } }, - { "aT", "ChatGPTRun translate", desc = "Translate", mode = { "n", "v" } }, - { "ak", "ChatGPTRun keywords", desc = "Keywords", mode = { "n", "v" } }, - { "ad", "ChatGPTRun docstring", desc = "Docstring", mode = { "n", "v" } }, - { "at", "ChatGPTRun add_tests", desc = "Add Tests", mode = { "n", "v" } }, - { "ao", "ChatGPTRun optimize_code", desc = "Optimize Code", mode = { "n", "v" } }, - { "as", "ChatGPTRun summarize", desc = "Summarize", mode = { "n", "v" } }, - { "af", "ChatGPTRun fix_bugs", desc = "Fix Bugs", mode = { "n", "v" } }, - { "ax", "ChatGPTRun explain_code", desc = "Explain Code", mode = { "n", "v" } }, - { "ar", "ChatGPTRun roxygen_edit", desc = "Roxygen Edit", mode = { "n", "v" } }, { - "al", - "ChatGPTRun code_readability_analysis", - desc = "Code Readability Analysis", - mode = { "n", "v" }, + "at", + function() + require("codecompanion").toggle() + end, + desc = "Toggle AI chat", + mode = { "n", "v" } }, - }, + { + "aa", + "CodeCompanion", + desc = "Run an inline prompt", + mode = { "n", "v" } + }, + { + "aA", + function() + require("codecompanion").actions() + end, + desc = "Open AI actions", + mode = { "n", "v" } + }, + { + "av", + function() + require("codecompanion").add() + end, + desc = "Add visual selection to chat", + mode = "v" + }, + { + "ae", + function() + require("codecompanion").prompt("explain") + end, + desc = "Explain code", + mode = "v" + }, + } } + diff --git a/chezmoi/dot_config/nvim/lua/aleidk/plugins/completion.lua b/chezmoi/dot_config/nvim/lua/aleidk/plugins/completion.lua index def7cac..a267bfd 100644 --- a/chezmoi/dot_config/nvim/lua/aleidk/plugins/completion.lua +++ b/chezmoi/dot_config/nvim/lua/aleidk/plugins/completion.lua @@ -13,6 +13,12 @@ return { "petertriho/cmp-git", "saadparwaiz1/cmp_luasnip", "windwp/nvim-autopairs", + { + "zbirenbaum/copilot-cmp", + config = function() + require("copilot_cmp").setup() + end + }, }, config = function() vim.api.nvim_set_hl(0, "CmpGhostText", { link = "Comment", default = true }) @@ -64,6 +70,7 @@ return { }), sources = cmp.config.sources({ { name = "conventionalcommits" }, + { name = "copilot" }, { name = "nvim_lsp" }, { name = "luasnip" }, { name = "buffer" }, @@ -88,7 +95,24 @@ return { hl_group = "CmpGhostText", }, }, - sorting = defaults.sorting, + sorting = { + priority_weight = 2, + comparators = { + require("copilot_cmp.comparators").prioritize, + + -- Below is the default comparitor list and order for nvim-cmp + cmp.config.compare.offset, + -- cmp.config.compare.scopes, --this is commented in nvim-cmp too + cmp.config.compare.exact, + cmp.config.compare.score, + cmp.config.compare.recently_used, + cmp.config.compare.locality, + cmp.config.compare.kind, + cmp.config.compare.sort_text, + cmp.config.compare.length, + cmp.config.compare.order, + }, + }, } cmp.setup(opts) diff --git a/chezmoi/dot_config/nvim/lua/aleidk/plugins/key-help.lua b/chezmoi/dot_config/nvim/lua/aleidk/plugins/key-help.lua index 5914f0c..b9c705f 100644 --- a/chezmoi/dot_config/nvim/lua/aleidk/plugins/key-help.lua +++ b/chezmoi/dot_config/nvim/lua/aleidk/plugins/key-help.lua @@ -61,11 +61,10 @@ return { { mode = "n", keys = "un", desc = "+Noice" }, { mode = "n", keys = "w", desc = "+Workspace" }, { mode = "n", keys = "p", desc = "+Run stuff" }, - { mode = "n", keys = "a", desc = "+ChatGPT" }, { mode = "n", keys = "z", desc = "+ZK" }, { mode = "v", keys = "z", desc = "+ZK" }, - { mode = "v", keys = "a", desc = "+ChatGPT" }, - { mode = "n", keys = "a", desc = "+ChatGPT" }, + { mode = "v", keys = "a", desc = "+AI" }, + { mode = "n", keys = "a", desc = "+AI" }, { mode = "n", keys = "g?", desc = "+Print Debug" }, }, diff --git a/chezmoi/dot_config/nvim/lua/aleidk/plugins/lsp.lua b/chezmoi/dot_config/nvim/lua/aleidk/plugins/lsp.lua index dec3af2..8512c8d 100644 --- a/chezmoi/dot_config/nvim/lua/aleidk/plugins/lsp.lua +++ b/chezmoi/dot_config/nvim/lua/aleidk/plugins/lsp.lua @@ -82,6 +82,7 @@ return { }, }, html = {}, + ["nil_ls"] = {}, marksman = {}, pyright = {}, phpactor = {}, diff --git a/chezmoi/dot_config/nvim/lua/aleidk/plugins/lualine.lua b/chezmoi/dot_config/nvim/lua/aleidk/plugins/lualine.lua index e12fff4..0e79c78 100644 --- a/chezmoi/dot_config/nvim/lua/aleidk/plugins/lualine.lua +++ b/chezmoi/dot_config/nvim/lua/aleidk/plugins/lualine.lua @@ -4,9 +4,11 @@ return { dependencies = { "nvim-tree/nvim-web-devicons", "cbochs/grapple.nvim", + { 'AndreM222/copilot-lualine' } }, opts = function() local icons = require("aleidk.constants").icons + local palete = require("catppuccin.palettes").get_palette "macchiato" local function diff_source() local gitsigns = vim.b.gitsigns_status_dict @@ -28,9 +30,45 @@ return { return str .. " " .. sbar[i] end + local codecompanion_status = require("lualine.component"):extend() + + codecompanion_status.processing = false + codecompanion_status.spinner_index = 1 + + local spinner_symbols = require("copilot-lualine.spinners").bouncing_bar + + -- Initializer + function codecompanion_status:init(options) + codecompanion_status.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 codecompanion_status:update_status() + if self.processing then + self.spinner_index = (self.spinner_index % #spinner_symbols) + 1 + return spinner_symbols[self.spinner_index] + else + return nil + end + end + return { options = { - theme = "auto", + theme = "catppuccin", globalstatus = true, disabled_filetypes = { statusline = { "dashboard", "alpha" } }, component_separators = "", @@ -48,7 +86,35 @@ return { }, lualine_b = {}, lualine_c = { - { "branch", icon = icons.git.branch }, + { "branch", icon = icons.git.branch }, + { + "copilot", + cond = function() + return vim.bo.filetype ~= "codecompanion" + end, + show_colors = true, + symbols = { + status = { + icons = { + enabled = " ", + sleep = " ", -- auto-trigger disabled + disabled = " ", + warning = " ", + unknown = " " + }, + hl = { + enabled = palete.teal, + sleep = palete.lavender, + disabled = palete.subtext0, + warning = palete.peach, + unknown = palete.red + } + }, + spinners = spinner_symbols, + spinner_color = palete.mauve + }, + }, + { codecompanion_status }, { "overseer", }, diff --git a/chezmoi/dot_config/nvim/lua/aleidk/plugins/pretty-fold.lua b/chezmoi/dot_config/nvim/lua/aleidk/plugins/pretty-fold.lua index d87ab95..665525c 100644 --- a/chezmoi/dot_config/nvim/lua/aleidk/plugins/pretty-fold.lua +++ b/chezmoi/dot_config/nvim/lua/aleidk/plugins/pretty-fold.lua @@ -1,4 +1,5 @@ return { + enabled = false, "anuvyklack/pretty-fold.nvim", opts = { sections = { @@ -32,7 +33,7 @@ return { }, matchup_patterns = { - { "{", "}" }, + { "{", "}" }, { "%(", ")" }, -- % to escape lua pattern char { "%[", "]" }, -- % to escape lua pattern char }, diff --git a/chezmoi/dot_config/nvim/original_lazy-lock.json b/chezmoi/dot_config/nvim/original_lazy-lock.json index 76b32ee..11840da 100644 --- a/chezmoi/dot_config/nvim/original_lazy-lock.json +++ b/chezmoi/dot_config/nvim/original_lazy-lock.json @@ -1,8 +1,10 @@ { - "ChatGPT.nvim": { "branch": "main", "commit": "f081338f07216a46d3915ce46c1fcb083bcb5016" }, "LuaSnip": { "branch": "master", "commit": "ce0a05ab4e2839e1c48d072c5236cce846a387bc" }, "alpha-nvim": { "branch": "main", "commit": "41283fb402713fc8b327e60907f74e46166f4cfd" }, "auto-session": { "branch": "main", "commit": "4b0728715e674ad9c18f1519127dcaed59f9981b" }, + "ccc.nvim": { "branch": "main", "commit": "4fb5abaef2f2e0540fe22d4d74a9841205fff9e4" }, + "chezmoi.nvim": { "branch": "main", "commit": "faf61465718424696269b2647077331b3e4605f1" }, + "chezmoi.vim": { "branch": "main", "commit": "10f2692791b5e512a2c1bb4dc560b42ca5bf71fd" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, "cmp-conventionalcommits": { "branch": "master", "commit": "a4dfacf0601130b7f8afa7c948d735c27802fb7f" }, @@ -10,14 +12,19 @@ "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, + "codecompanion.nvim": { "branch": "main", "commit": "ade8d29c94f6ad3c5b4ccf38517cec13126a6f0d" }, "comment-box.nvim": { "branch": "main", "commit": "06bb771690bc9df0763d14769b779062d8f12bc5" }, - "conform.nvim": { "branch": "master", "commit": "cd75be867f2331b22905f47d28c0c270a69466aa" }, + "conform.nvim": { "branch": "master", "commit": "0ebe875d9c306f5fc829db38492ffff2a70d8e9d" }, + "copilot-cmp": { "branch": "master", "commit": "b6e5286b3d74b04256d0a7e3bd2908eabec34b44" }, + "copilot-lualine": { "branch": "main", "commit": "f40450c3e138766026327e7807877ea860618258" }, + "copilot.lua": { "branch": "master", "commit": "f8d8d872bb319f640d5177dad5fbf01f7a16d7d0" }, "debugprint.nvim": { "branch": "main", "commit": "8f2a335fb0e6ebf0291a3551e0198363437e3a38" }, "diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" }, "dressing.nvim": { "branch": "master", "commit": "6741f1062d3dc6e4755367a7e9b347b553623f04" }, "flash.nvim": { "branch": "main", "commit": "d0799ae43a581d9f190e182e2a1f389d2887c42a" }, "friendly-snippets": { "branch": "main", "commit": "45a1b96e46efe5fce8af325d4bed45feb9d29d0f" }, "gitsigns.nvim": { "branch": "main", "commit": "e9c4187c3774a46df2d086a66cf3a7e6bea4c432" }, + "gopher.nvim": { "branch": "main", "commit": "f55c15ada8e02398000c04a96ef44d986cd01051" }, "grapple.nvim": { "branch": "main", "commit": "7aedc261b05a6c030397c4bc26416efbe746ebf1" }, "hurl.nvim": { "branch": "main", "commit": "d708158dda9a175c0f83cd106ea232301f4317cb" }, "indent-blankline.nvim": { "branch": "master", "commit": "65e20ab94a26d0e14acac5049b8641336819dfc7" }, @@ -61,9 +68,13 @@ "trouble.nvim": { "branch": "main", "commit": "03c1fbf518bef683422a3be9643c3da190903488" }, "ts-node-action": { "branch": "master", "commit": "6d3b60754fd87963d70eadaa2f77873b447eac26" }, "twilight.nvim": { "branch": "main", "commit": "2b632c169a4b51b1eba5be90fde22a80c51c990e" }, + "typescript-tools.nvim": { "branch": "master", "commit": "5da4d695d66f676eb6ea766b946e86f93baaafe7" }, + "undotree": { "branch": "master", "commit": "56c684a805fe948936cda0d1b19505b84ad7e065" }, "vim-dadbod": { "branch": "master", "commit": "7888cb7164d69783d3dce4e0283decd26b82538b" }, "vim-dadbod-completion": { "branch": "master", "commit": "8c9051c1cfc73fcf5bfe9a84db7097e4f7c0180d" }, "vim-dadbod-ui": { "branch": "master", "commit": "f74a31e8c6c5a9dccc63450a09d5cd64a9294330" }, + "vim-illuminate": { "branch": "master", "commit": "5eeb7951fc630682c322e88a9bbdae5c224ff0aa" }, + "vim-sleuth": { "branch": "master", "commit": "1cc4557420f215d02c4d2645a748a816c220e99b" }, "zen-mode.nvim": { "branch": "main", "commit": "2694c5a2bc4dc26c7a9e74b9e2b812920c90a830" }, "zk-nvim": { "branch": "main", "commit": "dbf4eeab55b08856c9d6b6722dbff39630bb35eb" } } diff --git a/chezmoi/dot_config/zed/private_settings.json b/chezmoi/dot_config/zed/private_settings.json index 8657fd3..b0308e0 100644 --- a/chezmoi/dot_config/zed/private_settings.json +++ b/chezmoi/dot_config/zed/private_settings.json @@ -7,6 +7,13 @@ // custom settings, run `zed: open default settings` from the // command palette (cmd-shift-p / ctrl-shift-p) { + "assistant": { + "default_model": { + "provider": "copilot_chat", + "model": "gpt-4o" + }, + "version": "2" + }, "vim_mode": true, "ui_font_size": 16, "buffer_font_size": 16,