companion config

This commit is contained in:
m3tam3re 2024-10-14 13:57:17 +02:00
parent 8adc1cd5a4
commit 57a6ddd5de
4 changed files with 102 additions and 295 deletions

View File

@ -855,103 +855,6 @@ require('lazy').setup({
vim.keymap.set('n', '<leader>g', '<cmd>LazyGit<cr>', { 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', '<leader>lc', vim.cmd.CodeCompanion, { desc = '[C]ode Companion' })
vim.keymap.set('n', '<leader>lca', '<cmd>CodeCompanionActions<CR>', { desc = 'ChatGPT [D]ocstring' })
vim.keymap.set('v', '<leader>lca', '<cmd>CodeCompanionActions<CR>', { desc = 'ChatGPT [D]ocstring' })
vim.keymap.set('n', '<leader>lct', '<cmd>CodeCompanionChat Toggle<CR>',
{ desc = 'ChatGPT [T]oggle Companion Chat' })
vim.keymap.set('v', '<leader>lct', '<cmd>CodeCompanionChat Toggle<CR>',
{ desc = 'ChatGPT [T]oggle Companion Chat' })
vim.keymap.set('n', '<leader>lca', '<cmd>CodeCompanionChat Add<CR>', { 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 = "<leader>n_", hidden = true },
{ "", group = "[N]oice" },
},
vim.keymap.set('n', '<leader>nl', function()
require('noice').cmd 'last'
end, { desc = 'Noice [l]ast' }),
vim.keymap.set('n', '<leader>nh', function()
require('noice').cmd 'history'
end, { desc = 'Noice [history]' }),
vim.keymap.set('n', '<leader>nt', function()
require('noice').cmd 'telescope'
end, { desc = 'Noice [t]elescope' }),
vim.keymap.set('n', '<leader>ne', function()
require('noice').cmd 'enable'
end, { desc = 'Noice [e]nable' }),
vim.keymap.set('n', '<leader>nd', function()
require('noice').cmd 'enable'
end, { desc = 'Noice [d]isable' }),
}
end,
},
{
'nvim-lualine/lualine.nvim',
dependencies = { 'nvim-tree/nvim-web-devicons' },

View File

@ -1,198 +0,0 @@
-- File: lua/custom/plugins/chatgpt.lua
return {
'jackMort/ChatGPT.nvim',
event = 'VeryLazy',
config = function()
vim.keymap.set('n', '<leader>lg', vim.cmd.ChatGPT, { desc = 'Chat[G]PT' })
vim.keymap.set('n', '<leader>lga', vim.cmd.ChatGPTActAs, { desc = 'ChatGPT [A]ct As' })
vim.keymap.set('n', '<leader>lgc', vim.cmd.ChatGPTCompleteCode, { desc = 'ChatGPT [C]omplete Code' })
vim.keymap.set('n', '<leader>lge', vim.cmd.ChatGPTEditWithInstructions,
{ desc = 'ChatGPT [E]dit With Instructions' })
vim.keymap.set('v', '<leader>lge', vim.cmd.ChatGPTEditWithInstructions,
{ desc = 'ChatGPT [E]dit With Instructions' })
vim.keymap.set('n', '<leader>lgd', '<cmd>ChatGPTRun docstring<CR>', { desc = 'ChatGPT [D]ocstring' })
vim.keymap.set('n', '<leader>lgo', '<cmd>ChatGPTRun optimize_code<CR>', { desc = 'ChatGPT [o]ptimize code' })
vim.keymap.set('n', '<leader>lge', '<cmd>ChatGPTRun explain_code<CR>', { desc = 'ChatGPT [e]xplain code' })
vim.keymap.set('n', '<leader>lgs', '<cmd>ChatGPTRun summarize<CR>', { desc = 'ChatGPT [s]ummarize' })
vim.keymap.set('n', '<leader>lgt', '<cmd>ChatGPTRun translate<CR>', { desc = 'ChatGPT [t]ranslate' })
require('chatgpt').setup {
yank_register = '+',
edit_with_instructions = {
diff = false,
keymaps = {
close = '<C-c>',
accept = '<C-y>',
toggle_diff = '<C-d>',
toggle_settings = '<C-o>',
toggle_help = '<C-h>',
cycle_windows = '<Tab>',
use_output_as_input = '<C-i>',
},
},
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 = '<C-c>',
yank_last = '<C-y>',
yank_last_code = '<C-k>',
scroll_up = '<C-u>',
scroll_down = '<C-d>',
new_session = '<C-n>',
cycle_windows = '<Tab>',
cycle_modes = '<C-f>',
next_message = '<C-j>',
prev_message = '<C-k>',
select_session = '<Space>',
rename_session = 'r',
delete_session = 'd',
draft_message = '<C-r>',
edit_message = 'e',
delete_message = 'd',
toggle_settings = '<C-o>',
toggle_sessions = '<C-p>',
toggle_help = '<C-h>',
toggle_message_role = '<C-r>',
toggle_system_role_open = '<C-s>',
stop_generating = '<C-x>',
},
},
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 = '<C-Enter>',
submit_n = '<Enter>',
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',
},
}

View File

@ -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', '<leader>lc', vim.cmd.CodeCompanion, { desc = '[C]ode Companion' })
vim.keymap.set('n', '<leader>lca', '<cmd>CodeCompanionActions<CR>', { desc = 'ChatGPT [D]ocstring' })
vim.keymap.set('v', '<leader>lca', '<cmd>CodeCompanionActions<CR>', { desc = 'ChatGPT [D]ocstring' })
vim.keymap.set('n', '<leader>lct', '<cmd>CodeCompanionChat Toggle<CR>',
{ desc = 'ChatGPT [T]oggle Companion Chat' })
vim.keymap.set('v', '<leader>lct', '<cmd>CodeCompanionChat Toggle<CR>',
{ desc = 'ChatGPT [T]oggle Companion Chat' })
vim.keymap.set('n', '<leader>lca', '<cmd>CodeCompanionChat Add<CR>', { 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,
}

View File

@ -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 = "<leader>n_", hidden = true },
{ "", group = "[N]oice" },
},
vim.keymap.set('n', '<leader>nl', function()
require('noice').cmd 'last'
end, { desc = 'Noice [l]ast' }),
vim.keymap.set('n', '<leader>nh', function()
require('noice').cmd 'history'
end, { desc = 'Noice [history]' }),
vim.keymap.set('n', '<leader>nt', function()
require('noice').cmd 'telescope'
end, { desc = 'Noice [t]elescope' }),
vim.keymap.set('n', '<leader>ne', function()
require('noice').cmd 'enable'
end, { desc = 'Noice [e]nable' }),
vim.keymap.set('n', '<leader>nd', function()
require('noice').cmd 'enable'
end, { desc = 'Noice [d]isable' }),
}
end,
}