From bec8e6fb6b21f773f6d19c6e3c6ecc96786eaac9 Mon Sep 17 00:00:00 2001 From: Robert Boyd III Date: Thu, 25 Jan 2024 11:09:02 -0500 Subject: [PATCH 1/3] feat(config): allow turning off G in GpChats --- lua/gp/config.lua | 2 ++ lua/gp/init.lua | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lua/gp/config.lua b/lua/gp/config.lua index 2c426905..a87dd09a 100644 --- a/lua/gp/config.lua +++ b/lua/gp/config.lua @@ -121,6 +121,8 @@ local config = { chat_finder_pattern = "topic ", -- if true, finished ChatResponder won't move the cursor to the end of the buffer chat_free_cursor = false, + -- control whether to type G whenever the chat buffer is focused + jump_to_bottom = true, -- how to display GpChatToggle or GpContext: popup / split / vsplit / tabnew toggle_target = "vsplit", diff --git a/lua/gp/init.lua b/lua/gp/init.lua index 567e95ff..91cbbef2 100644 --- a/lua/gp/init.lua +++ b/lua/gp/init.lua @@ -1366,7 +1366,9 @@ M.prep_md = function(buf) buf = buf or vim.api.nvim_get_current_buf() -- move cursor to a new line at the end of the file - M._H.feedkeys("G", "x") + if M.config.jump_to_bottom then + M._H.feedkeys("G", "x") + end -- ensure normal mode vim.api.nvim_command("stopinsert") From a78d82bbeb6304b602fc1729ec3b7c791dddd0d8 Mon Sep 17 00:00:00 2001 From: "Schmidt, Tibor" Date: Thu, 25 Jan 2024 21:15:13 +0100 Subject: [PATCH 2/3] feat: remove auto bottom jumps --- lua/gp/config.lua | 2 -- lua/gp/init.lua | 5 ----- 2 files changed, 7 deletions(-) diff --git a/lua/gp/config.lua b/lua/gp/config.lua index a87dd09a..2c426905 100644 --- a/lua/gp/config.lua +++ b/lua/gp/config.lua @@ -121,8 +121,6 @@ local config = { chat_finder_pattern = "topic ", -- if true, finished ChatResponder won't move the cursor to the end of the buffer chat_free_cursor = false, - -- control whether to type G whenever the chat buffer is focused - jump_to_bottom = true, -- how to display GpChatToggle or GpContext: popup / split / vsplit / tabnew toggle_target = "vsplit", diff --git a/lua/gp/init.lua b/lua/gp/init.lua index 91cbbef2..d9fb9011 100644 --- a/lua/gp/init.lua +++ b/lua/gp/init.lua @@ -1365,11 +1365,6 @@ M.prep_md = function(buf) -- register shortcuts local to this buffer buf = buf or vim.api.nvim_get_current_buf() - -- move cursor to a new line at the end of the file - if M.config.jump_to_bottom then - M._H.feedkeys("G", "x") - end - -- ensure normal mode vim.api.nvim_command("stopinsert") M._H.feedkeys("", "x") From 6812976dac45430b48d21940ffa395cdffe85d14 Mon Sep 17 00:00:00 2001 From: "Schmidt, Tibor" Date: Thu, 25 Jan 2024 21:49:11 +0100 Subject: [PATCH 3/3] feat: chat buftype=prompt option (resolve: #94) --- lua/gp/config.lua | 2 ++ lua/gp/init.lua | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/lua/gp/config.lua b/lua/gp/config.lua index 2c426905..a120c29d 100644 --- a/lua/gp/config.lua +++ b/lua/gp/config.lua @@ -121,6 +121,8 @@ local config = { chat_finder_pattern = "topic ", -- if true, finished ChatResponder won't move the cursor to the end of the buffer chat_free_cursor = false, + -- use prompt buftype for chats (:h prompt-buffer) + chat_prompt_buf_type = false, -- how to display GpChatToggle or GpContext: popup / split / vsplit / tabnew toggle_target = "vsplit", diff --git a/lua/gp/init.lua b/lua/gp/init.lua index d9fb9011..b734f902 100644 --- a/lua/gp/init.lua +++ b/lua/gp/init.lua @@ -1401,6 +1401,14 @@ M.prep_chat = function(buf, file_name) M.prep_md(buf) + if M.config.chat_prompt_buf_type then + vim.api.nvim_buf_set_option(buf, "buftype", "prompt") + vim.fn.prompt_setprompt(buf, "") + vim.fn.prompt_setcallback(buf, function() + M.cmd.ChatRespond({ args = "" }) + end) + end + -- setup chat specific commands local range_commands = { {