Skip to content

Commit

Permalink
feat: integrate chatgpt
Browse files Browse the repository at this point in the history
  • Loading branch information
yetone committed Aug 12, 2024
1 parent a5d705f commit ef46765
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
1 change: 1 addition & 0 deletions lazy-lock.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"AnsiEsc.vim": { "branch": "master", "commit": "d2bb7878622e4c16203acf1c92a0f4bc7ac58003" },
"ChatGPT.nvim": { "branch": "main", "commit": "f081338f07216a46d3915ce46c1fcb083bcb5016" },
"Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" },
"LuaSnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" },
"beacon.nvim": { "branch": "master", "commit": "a786c9a89b2c739c69f9500a2f70f2586c06ec27" },
Expand Down
51 changes: 51 additions & 0 deletions lua/layers/completion/configs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,55 @@ function configs.luasnip()
require('luasnip.loaders.from_vscode').lazy_load()
end

function configs.chatgpt()
require('chatgpt').setup({
openai_params = {
-- NOTE: model can be a function returning the model name
-- this is useful if you want to change the model on the fly
-- using commands
-- Example:
-- model = function()
-- if some_condition() then
-- return "gpt-4-1106-preview"
-- else
-- return "gpt-3.5-turbo"
-- end
-- end,
model = 'gpt-4-turbo',
frequency_penalty = 0,
presence_penalty = 0,
max_tokens = 4095,
temperature = 0.2,
top_p = 0.1,
n = 1,
},
chat = {
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>',
},
},
})
end

return configs
11 changes: 11 additions & 0 deletions lua/layers/completion/plugins.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,14 @@ cosmos.add_plugin('hrsh7th/cmp-cmdline', { dependencies = { 'hrsh7th/nvim-cmp' }
cosmos.add_plugin('dmitmel/cmp-cmdline-history', { dependencies = { 'hrsh7th/nvim-cmp' }, event = 'BufRead' })

cosmos.add_plugin('saadparwaiz1/cmp_luasnip', { dependencies = { 'hrsh7th/nvim-cmp' }, event = 'BufRead' })

cosmos.add_plugin('jackMort/ChatGPT.nvim', {
event = 'VeryLazy',
config = configs.chatgpt,
dependencies = {
'MunifTanjim/nui.nvim',
'nvim-lua/plenary.nvim',
'folke/trouble.nvim',
'nvim-telescope/telescope.nvim',
},
})

0 comments on commit ef46765

Please sign in to comment.