Add gpt support
parent
1dc6f38f0f
commit
90e87635b1
|
@ -1,6 +1,7 @@
|
|||
require('plugins')
|
||||
require('mappings')
|
||||
require('telescope_config')
|
||||
require('gpt')
|
||||
|
||||
-- Misc commands similar to my vimrc
|
||||
vim.g.mapleader = ","
|
||||
|
@ -12,6 +13,3 @@ vim.opt.relativenumber = true
|
|||
vim.api.nvim_set_keymap('i', 'jk', '<Esc>', {noremap = true})
|
||||
vim.cmd.colorscheme "catppuccin-frappe"
|
||||
|
||||
-- We don't need these two because we have oil
|
||||
vim.g.loaded_netrw = 1
|
||||
vim.g.loaded_netrwPlugin = 1
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
function gpt_complete_buffer()
|
||||
-- Store the current buffer name and escape special characters
|
||||
local buf_name = vim.api.nvim_buf_get_name(0):gsub(' ', '\\ ')
|
||||
|
||||
-- Call gpt-md on the current file and capture output
|
||||
local result = vim.fn.system('gpt-md ' .. buf_name)
|
||||
|
||||
-- Check for errors and display the resulting message if any
|
||||
if vim.v.shell_error ~= 0 then
|
||||
print("Error executing gpt-md: " .. result)
|
||||
return
|
||||
end
|
||||
|
||||
-- Reload the current buffer to load the updated content from gpt-md
|
||||
vim.api.nvim_command('edit')
|
||||
|
||||
-- Print the gpt-md result (or a success message if gpt-md doesn't return anything)
|
||||
local message = (#result > 0) and result or "Buffer successfully completed by gpt-md"
|
||||
print(message)
|
||||
end
|
||||
|
||||
|
||||
vim.api.nvim_command('command! GptComplete lua gpt_complete_buffer()')
|
|
@ -23,6 +23,7 @@ wk.register({
|
|||
a = { "<cmd>unhide<cr>", "Show All" },
|
||||
o = { "<cmd>Telescope buffers<cr>", "Open" },
|
||||
e = { "<cmd>Oil<cr>", "Explorer" },
|
||||
g = { "<cmd>GptComplete<cr>", "Call GPT" },
|
||||
},
|
||||
}, { prefix = "<leader>" })
|
||||
|
||||
|
@ -38,6 +39,12 @@ wk.register({
|
|||
h = { "<cmd>SplitOrMove h<cr>", "Split or move left" },
|
||||
j = { "<cmd>SplitOrMove j<cr>", "Split or move down" },
|
||||
k = { "<cmd>SplitOrMove k<cr>", "Split or move up" },
|
||||
s = {
|
||||
name = "resize", -- this does not stay open which makes it useless
|
||||
k = { "<cmd>horizontal resize +5<cr>", "Resize up" },
|
||||
j = { "<cmd>horizontal resize -5<cr>", "Resize down" },
|
||||
h = { "<cmd>vertical resize +5<cr>", "Resize right" },
|
||||
l = { "<cmd>vertical resize -5<cr>", "Resize left" },
|
||||
}
|
||||
},
|
||||
}, { prefix = "<leader>" })
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
-- Declare the function in the _G table to make it globally available
|
||||
_G.SplitOrMove = function(direction)
|
||||
if vim.fn.winnr() ~= vim.fn.winnr(direction) then
|
||||
vim.api.nvim_err_writeln('normal! <c-w>' .. direction)
|
||||
vim.cmd(":wincmd " .. direction)
|
||||
else
|
||||
if direction == 'l' then
|
||||
|
|
|
@ -119,14 +119,14 @@ _G.packer_plugins = {
|
|||
}
|
||||
|
||||
time([[Defining packer_plugins]], false)
|
||||
-- Config for: which-key.nvim
|
||||
time([[Config for which-key.nvim]], true)
|
||||
try_loadstring("\27LJ\2\nD\0\0\2\0\4\0\t6\0\0\0009\0\1\0+\1\2\0=\1\2\0006\0\0\0009\0\1\0)\1,\1=\1\3\0K\0\1\0\15timeoutlen\ftimeout\6o\bvim\0", "config", "which-key.nvim")
|
||||
time([[Config for which-key.nvim]], false)
|
||||
-- Config for: oil.nvim
|
||||
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: which-key.nvim
|
||||
time([[Config for which-key.nvim]], true)
|
||||
try_loadstring("\27LJ\2\nD\0\0\2\0\4\0\t6\0\0\0009\0\1\0+\1\2\0=\1\2\0006\0\0\0009\0\1\0)\1,\1=\1\3\0K\0\1\0\15timeoutlen\ftimeout\6o\bvim\0", "config", "which-key.nvim")
|
||||
time([[Config for which-key.nvim]], false)
|
||||
|
||||
_G._packer.inside_compile = false
|
||||
if _G._packer.needs_bufread == true then
|
||||
|
|
Loading…
Reference in New Issue