From 57a6ddd5dee78519aa7469d1d31abce8830e5a17 Mon Sep 17 00:00:00 2001 From: m3tam3re Date: Mon, 14 Oct 2024 13:57:17 +0200 Subject: [PATCH] companion config --- nvim/init.lua | 97 ----------- nvim/lua/custom/plugins/chatgpt.lua | 198 ---------------------- nvim/lua/custom/plugins/codecompanion.lua | 40 +++++ nvim/lua/custom/plugins/noice.lua | 62 +++++++ 4 files changed, 102 insertions(+), 295 deletions(-) delete mode 100644 nvim/lua/custom/plugins/chatgpt.lua create mode 100644 nvim/lua/custom/plugins/codecompanion.lua create mode 100644 nvim/lua/custom/plugins/noice.lua diff --git a/nvim/init.lua b/nvim/init.lua index b237b46..40ec88b 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -855,103 +855,6 @@ require('lazy').setup({ vim.keymap.set('n', 'g', 'LazyGit', { desc = 'LazyGit' }) } }, - { - "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 - "nvim-telescope/telescope.nvim", -- Optional: For using slash commands - { "stevearc/dressing.nvim", opts = {} }, -- Optional: Improves `vim.ui.select` - }, - config = function() - vim.keymap.set('n', 'lc', vim.cmd.CodeCompanion, { desc = '[C]ode Companion' }) - vim.keymap.set('n', 'lca', 'CodeCompanionActions', { desc = 'ChatGPT [D]ocstring' }) - vim.keymap.set('v', 'lca', 'CodeCompanionActions', { desc = 'ChatGPT [D]ocstring' }) - vim.keymap.set('n', 'lct', 'CodeCompanionChat Toggle', - { desc = 'ChatGPT [T]oggle Companion Chat' }) - vim.keymap.set('v', 'lct', 'CodeCompanionChat Toggle', - { desc = 'ChatGPT [T]oggle Companion Chat' }) - vim.keymap.set('n', 'lca', 'CodeCompanionChat Add', { desc = '[A]dd Companion Chat' }) - - require("codecompanion").setup({ - strategies = { - chat = { - adapter = "anthropic", - }, - inline = { - adapter = "anthropic", - }, - agent = { - adapter = "anthropic", - }, - }, - - }) - end, - }, - { - 'folke/noice.nvim', - event = 'VeryLazy', - opts = { - -- add any options here - }, - dependencies = { - -- if you lazy-load any plugin below, make sure to add proper `module="..."` entries - 'MunifTanjim/nui.nvim', - -- OPTIONAL: - -- `nvim-notify` is only needed, if you want to use the notification view. - -- If not available, we use `mini` as the fallback - 'rcarriga/nvim-notify', - }, - config = function() - require('noice').setup { - lsp = { - -- override markdown rendering so that **cmp** and other plugins use **Treesitter** - override = { - ['vim.lsp.util.convert_input_to_markdown_lines'] = true, - ['vim.lsp.util.stylize_markdown'] = true, - ['cmp.entry.get_documentation'] = true, -- requires hrsh7th/nvim-cmp - }, - }, - -- you can enable a preset for easier configuration - presets = { - bottom_search = true, -- use a classic bottom cmdline for search - command_palette = true, -- position the cmdline and popupmenu together - long_message_to_split = true, -- long messages will be sent to a split - inc_rename = false, -- enables an input dialog for inc-rename.nvim - lsp_doc_border = false, -- add a border to hover docs and signature help - }, - - routes = { - { - view = 'notify', - filter = { event = 'msg_showmode' }, - }, - }, - - require('which-key').add { - { "", desc = "n_", hidden = true }, - { "", group = "[N]oice" }, - }, - vim.keymap.set('n', 'nl', function() - require('noice').cmd 'last' - end, { desc = 'Noice [l]ast' }), - vim.keymap.set('n', 'nh', function() - require('noice').cmd 'history' - end, { desc = 'Noice [history]' }), - vim.keymap.set('n', 'nt', function() - require('noice').cmd 'telescope' - end, { desc = 'Noice [t]elescope' }), - vim.keymap.set('n', 'ne', function() - require('noice').cmd 'enable' - end, { desc = 'Noice [e]nable' }), - vim.keymap.set('n', 'nd', function() - require('noice').cmd 'enable' - end, { desc = 'Noice [d]isable' }), - } - end, - }, { 'nvim-lualine/lualine.nvim', dependencies = { 'nvim-tree/nvim-web-devicons' }, diff --git a/nvim/lua/custom/plugins/chatgpt.lua b/nvim/lua/custom/plugins/chatgpt.lua deleted file mode 100644 index 001fdb0..0000000 --- a/nvim/lua/custom/plugins/chatgpt.lua +++ /dev/null @@ -1,198 +0,0 @@ --- File: lua/custom/plugins/chatgpt.lua - -return { - 'jackMort/ChatGPT.nvim', - event = 'VeryLazy', - config = function() - vim.keymap.set('n', 'lg', vim.cmd.ChatGPT, { desc = 'Chat[G]PT' }) - vim.keymap.set('n', 'lga', vim.cmd.ChatGPTActAs, { desc = 'ChatGPT [A]ct As' }) - vim.keymap.set('n', 'lgc', vim.cmd.ChatGPTCompleteCode, { desc = 'ChatGPT [C]omplete Code' }) - vim.keymap.set('n', 'lge', vim.cmd.ChatGPTEditWithInstructions, - { desc = 'ChatGPT [E]dit With Instructions' }) - vim.keymap.set('v', 'lge', vim.cmd.ChatGPTEditWithInstructions, - { desc = 'ChatGPT [E]dit With Instructions' }) - vim.keymap.set('n', 'lgd', 'ChatGPTRun docstring', { desc = 'ChatGPT [D]ocstring' }) - vim.keymap.set('n', 'lgo', 'ChatGPTRun optimize_code', { desc = 'ChatGPT [o]ptimize code' }) - vim.keymap.set('n', 'lge', 'ChatGPTRun explain_code', { desc = 'ChatGPT [e]xplain code' }) - vim.keymap.set('n', 'lgs', 'ChatGPTRun summarize', { desc = 'ChatGPT [s]ummarize' }) - vim.keymap.set('n', 'lgt', 'ChatGPTRun translate', { desc = 'ChatGPT [t]ranslate' }) - require('chatgpt').setup { - yank_register = '+', - edit_with_instructions = { - diff = false, - keymaps = { - close = '', - accept = '', - toggle_diff = '', - toggle_settings = '', - toggle_help = '', - cycle_windows = '', - use_output_as_input = '', - }, - }, - chat = { - welcome_message = 'Welcome Human!', - 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 = '', - }, - }, - 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-0125', - frequency_penalty = 0, - presence_penalty = 0, - max_tokens = 1000, - temperature = 0, - top_p = 1, - n = 1, - }, - openai_edit_params = { - model = 'gpt-3.5-turbo-0125', - 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', - }, - } - end, - dependencies = { - 'MunifTanjim/nui.nvim', - 'nvim-lua/plenary.nvim', - 'folke/trouble.nvim', - 'nvim-telescope/telescope.nvim', - }, -} diff --git a/nvim/lua/custom/plugins/codecompanion.lua b/nvim/lua/custom/plugins/codecompanion.lua new file mode 100644 index 0000000..149445a --- /dev/null +++ b/nvim/lua/custom/plugins/codecompanion.lua @@ -0,0 +1,40 @@ +return { + "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 + "nvim-telescope/telescope.nvim", -- Optional: For using slash commands + { "stevearc/dressing.nvim", opts = {} }, -- Optional: Improves `vim.ui.select` + }, + config = function() + vim.keymap.set('n', 'lc', vim.cmd.CodeCompanion, { desc = '[C]ode Companion' }) + vim.keymap.set('n', 'lca', 'CodeCompanionActions', { desc = 'ChatGPT [D]ocstring' }) + vim.keymap.set('v', 'lca', 'CodeCompanionActions', { desc = 'ChatGPT [D]ocstring' }) + vim.keymap.set('n', 'lct', 'CodeCompanionChat Toggle', + { desc = 'ChatGPT [T]oggle Companion Chat' }) + vim.keymap.set('v', 'lct', 'CodeCompanionChat Toggle', + { desc = 'ChatGPT [T]oggle Companion Chat' }) + vim.keymap.set('n', 'lca', 'CodeCompanionChat Add', { desc = '[A]dd Companion Chat' }) + + require("codecompanion").setup({ + display = { + chat = { + window = { width = 0.25 } + }, + }, + strategies = { + chat = { + adapter = "anthropic", + }, + inline = { + adapter = "anthropic", + }, + agent = { + adapter = "anthropic", + }, + }, + + }) + end, +} diff --git a/nvim/lua/custom/plugins/noice.lua b/nvim/lua/custom/plugins/noice.lua new file mode 100644 index 0000000..b8776af --- /dev/null +++ b/nvim/lua/custom/plugins/noice.lua @@ -0,0 +1,62 @@ +return { + 'folke/noice.nvim', + event = 'VeryLazy', + opts = { + -- add any options here + }, + dependencies = { + -- if you lazy-load any plugin below, make sure to add proper `module="..."` entries + 'MunifTanjim/nui.nvim', + -- OPTIONAL: + -- `nvim-notify` is only needed, if you want to use the notification view. + -- If not available, we use `mini` as the fallback + 'rcarriga/nvim-notify', + }, + config = function() + require('noice').setup { + lsp = { + -- override markdown rendering so that **cmp** and other plugins use **Treesitter** + override = { + ['vim.lsp.util.convert_input_to_markdown_lines'] = true, + ['vim.lsp.util.stylize_markdown'] = true, + ['cmp.entry.get_documentation'] = true, -- requires hrsh7th/nvim-cmp + }, + }, + -- you can enable a preset for easier configuration + presets = { + bottom_search = true, -- use a classic bottom cmdline for search + command_palette = true, -- position the cmdline and popupmenu together + long_message_to_split = true, -- long messages will be sent to a split + inc_rename = false, -- enables an input dialog for inc-rename.nvim + lsp_doc_border = false, -- add a border to hover docs and signature help + }, + + routes = { + { + view = 'notify', + filter = { event = 'msg_showmode' }, + }, + }, + + require('which-key').add { + { "", desc = "n_", hidden = true }, + { "", group = "[N]oice" }, + }, + vim.keymap.set('n', 'nl', function() + require('noice').cmd 'last' + end, { desc = 'Noice [l]ast' }), + vim.keymap.set('n', 'nh', function() + require('noice').cmd 'history' + end, { desc = 'Noice [history]' }), + vim.keymap.set('n', 'nt', function() + require('noice').cmd 'telescope' + end, { desc = 'Noice [t]elescope' }), + vim.keymap.set('n', 'ne', function() + require('noice').cmd 'enable' + end, { desc = 'Noice [e]nable' }), + vim.keymap.set('n', 'nd', function() + require('noice').cmd 'enable' + end, { desc = 'Noice [d]isable' }), + } + end, +}