Skip to content

Commit

Permalink
Merge branch 'main' of github.com:Robitx/gp.nvim into lsp
Browse files Browse the repository at this point in the history
  • Loading branch information
Robitx committed Jan 14, 2024
2 parents 2ff9db3 + 62254bd commit 2e1048f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion doc/gp.nvim.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*gp.nvim.txt* For NVIM v0.8.0 Last change: 2024 January 04
*gp.nvim.txt* For NVIM v0.8.0 Last change: 2024 January 14

==============================================================================
Table of Contents *gp.nvim-table-of-contents*
Expand Down
25 changes: 19 additions & 6 deletions lua/gp/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,9 @@ M.setup = function(opts)
local dir = v:gsub("/$", "")
M.config[k] = dir
if vim.fn.isdirectory(dir) == 0 then
M.info("creating directory " .. dir)
if k ~= "whisper_dir" and k ~= "image_dir" then
M.info("creating directory " .. dir)
end
vim.fn.mkdir(dir, "p")
end
end
Expand Down Expand Up @@ -2715,14 +2717,25 @@ M.Prompt = function(params, target, prompt, model, template, system_template, wh
vim.cmd("tabnew")
win = vim.api.nvim_get_current_win()
end
-- create a new buffer
buf = vim.api.nvim_create_buf(true, false)
-- set the created buffer as the current buffer

buf = vim.api.nvim_create_buf(true, true)
vim.api.nvim_set_current_buf(buf)
-- set the filetype

local group = M._H.create_augroup("GpScratchSave" .. _H.uuid(), { clear = true })
vim.api.nvim_create_autocmd({ "BufWritePre" }, {
buffer = buf,
group = group,
callback = function(ctx)
vim.api.nvim_buf_set_option(ctx.buf, "buftype", "")
vim.api.nvim_buf_set_name(ctx.buf, ctx.file)
vim.api.nvim_command("w!")
vim.api.nvim_del_augroup_by_id(ctx.group)
end,
})

local ft = target.filetype or filetype
vim.api.nvim_buf_set_option(buf, "filetype", ft)
-- prepare handler

handler = M.create_handler(buf, win, 0, false, "", cursor)
end

Expand Down

0 comments on commit 2e1048f

Please sign in to comment.