Use Gp chat plug-in.

main
felixm 2024-03-29 14:46:59 -04:00
parent 0071a636cc
commit 61d3be927d
4 changed files with 24 additions and 39 deletions

View File

@ -4,7 +4,6 @@ require('config_mappings')
require('config_telescope')
require('config_treesitter')
require('config_lspconfig')
require('plugin_gpt')
require('plugin_votion')
-- Global options
@ -29,4 +28,4 @@ vim.api.nvim_set_keymap('v', '<C-c>', '"+y', {noremap = true, silent = true})
vim.api.nvim_set_keymap('i', '<C-v>', '<Esc>"+pa', {noremap = true, silent = true})
vim.api.nvim_set_keymap('n', '<C-S-v>', '"+p', {noremap = true, silent = true})
vim.api.nvim_set_keymap('n', '<f5>', ':belowright split | terminal python %<cr>', {noremap = true, silent = true})
vim.api.nvim_set_keymap('n', '<C-p>', ':Telescope commands<cr>', {noremap = true, silent = true})

View File

@ -1,35 +0,0 @@
function gpt_complete_file()
-- Store the current buffer name and escape special characters
local buf_name = vim.api.nvim_buf_get_name(0):gsub(' ', '\\ ')
local on_complete = function(err, exit_code, pid)
-- Check for errors and display the resulting message if any
if tonumber(err) ~= 0 then
print("Error executing gpt-md:", err)
return
end
-- Reload the current buffer to load the updated content from gpt-md
vim.api.nvim_command('edit')
-- Print the gpt-md result
print("Buffer completed by gpt-md with exit code: " .. exit_code)
end
local handle, pid
handle, pid = vim.loop.spawn('gpt-md', {
args = {buf_name},
stdio = {nil, nil, vim.loop.new_pipe(false)},
cwd = vim.fn.getcwd(),
}, vim.schedule_wrap(on_complete))
-- Check if the command has started correctly
if not handle then
print("Failed to run gpt-md on the current file")
end
end
vim.api.nvim_command('command! GptCompleteFile lua gpt_complete_file()')

View File

@ -21,6 +21,17 @@ return require('packer').startup(function(use)
end
}
-- packer.nvim
use {
"robitx/gp.nvim",
config = function()
local config = {
openai_api_key = { "keyring", "get", "openai-api-key", "felixm" },
}
require("gp").setup(config)
end
}
use {
'numToStr/Comment.nvim',
config = function()

View File

@ -49,8 +49,8 @@ local function save_profiles(threshold)
end
time([[Luarocks path setup]], true)
local package_path_str = "/home/felixm/.cache/nvim/packer_hererocks/2.1.1700008891/share/lua/5.1/?.lua;/home/felixm/.cache/nvim/packer_hererocks/2.1.1700008891/share/lua/5.1/?/init.lua;/home/felixm/.cache/nvim/packer_hererocks/2.1.1700008891/lib/luarocks/rocks-5.1/?.lua;/home/felixm/.cache/nvim/packer_hererocks/2.1.1700008891/lib/luarocks/rocks-5.1/?/init.lua"
local install_cpath_pattern = "/home/felixm/.cache/nvim/packer_hererocks/2.1.1700008891/lib/lua/5.1/?.so"
local package_path_str = "/home/felixm/.cache/nvim/packer_hererocks/2.1.1702233742/share/lua/5.1/?.lua;/home/felixm/.cache/nvim/packer_hererocks/2.1.1702233742/share/lua/5.1/?/init.lua;/home/felixm/.cache/nvim/packer_hererocks/2.1.1702233742/lib/luarocks/rocks-5.1/?.lua;/home/felixm/.cache/nvim/packer_hererocks/2.1.1702233742/lib/luarocks/rocks-5.1/?/init.lua"
local install_cpath_pattern = "/home/felixm/.cache/nvim/packer_hererocks/2.1.1702233742/lib/lua/5.1/?.so"
if not string.find(package.path, package_path_str, 1, true) then
package.path = package.path .. ';' .. package_path_str
end
@ -80,6 +80,12 @@ _G.packer_plugins = {
path = "/home/felixm/.local/share/nvim/site/pack/packer/start/Comment.nvim",
url = "https://github.com/numToStr/Comment.nvim"
},
["gp.nvim"] = {
config = { "\27LJ\2\nx\0\0\4\0\6\0\n5\0\1\0005\1\0\0=\1\2\0006\1\3\0'\3\4\0B\1\2\0029\1\5\1\18\3\0\0B\1\2\1K\0\1\0\nsetup\agp\frequire\19openai_api_key\1\0\0\1\5\0\0\fkeyring\bget\19openai-api-key\vfelixm\0" },
loaded = true,
path = "/home/felixm/.local/share/nvim/site/pack/packer/start/gp.nvim",
url = "https://github.com/robitx/gp.nvim"
},
["lualine.nvim"] = {
loaded = true,
path = "/home/felixm/.local/share/nvim/site/pack/packer/start/lualine.nvim",
@ -152,6 +158,10 @@ time([[Config for Comment.nvim]], false)
time([[Config for oil.nvim]], true)
try_loadstring("\27LJ\2\n1\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\boil\frequire\0", "config", "oil.nvim")
time([[Config for oil.nvim]], false)
-- Config for: gp.nvim
time([[Config for gp.nvim]], true)
try_loadstring("\27LJ\2\nx\0\0\4\0\6\0\n5\0\1\0005\1\0\0=\1\2\0006\1\3\0'\3\4\0B\1\2\0029\1\5\1\18\3\0\0B\1\2\1K\0\1\0\nsetup\agp\frequire\19openai_api_key\1\0\0\1\5\0\0\fkeyring\bget\19openai-api-key\vfelixm\0", "config", "gp.nvim")
time([[Config for gp.nvim]], false)
_G._packer.inside_compile = false
if _G._packer.needs_bufread == true then