summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-04-25 15:44:37 +0300
committerPaul Buetow <paul@buetow.org>2025-04-25 15:44:37 +0300
commitbde6ebc424a5953ea777fdae1aedbfaa940866aa (patch)
treeb6fe68171f1fce1fd955c434733e412944ba2342
parent9d49c21dc973e4cb88d716b83b6b50db1e574649 (diff)
better
-rw-r--r--dotfiles/nvim/init.lua23
-rwxr-xr-xdotfiles/scripts/hx.nvim-prompt4
2 files changed, 16 insertions, 11 deletions
diff --git a/dotfiles/nvim/init.lua b/dotfiles/nvim/init.lua
index ae4ab5d..4a437e8 100644
--- a/dotfiles/nvim/init.lua
+++ b/dotfiles/nvim/init.lua
@@ -1,3 +1,4 @@
+
require("CopilotChat").setup {
-- See Configuration section for options
}
@@ -20,16 +21,20 @@ vim.api.nvim_create_autocmd("BufEnter", {
local lines = vim.api.nvim_buf_get_lines(copilot_chat_buf, 0, -1, false)
-- Check for the stopping condition
+ local user_line_count = 0
for _, line in ipairs(lines) do
- if line:find("^COPILOT_END") then
- print("Stopping write process: 'COPILOT_END' detected.")
- timer:stop()
- -- Write the buffer content to the file
- vim.api.nvim_buf_call(copilot_chat_buf, function()
- vim.cmd("write! " .. file_path)
- end)
- vim.cmd("qa!")
- return
+ if line:find("^## User") then
+ user_line_count = user_line_count + 1
+ if user_line_count >= 2 then
+ print("Stopping write process: Two '## User' lines detected.")
+ timer:stop()
+ -- Write the buffer content to the file
+ vim.api.nvim_buf_call(copilot_chat_buf, function()
+ vim.cmd("write! " .. file_path)
+ end)
+ vim.cmd("qa!")
+ return
+ end
end
end
diff --git a/dotfiles/scripts/hx.nvim-prompt b/dotfiles/scripts/hx.nvim-prompt
index 05ad1a3..09230ae 100755
--- a/dotfiles/scripts/hx.nvim-prompt
+++ b/dotfiles/scripts/hx.nvim-prompt
@@ -9,9 +9,9 @@ if [ -f $REPLY_FILE.done ]; then
rm $REPLY_FILE.done
fi
-tmux split-window -v "nvim +':CopilotChat $PROMPT for the following: $(cat $STDIN_FILE). If the result is code, code only without code-block at the beginning and the end. End the output with COPILOT_END.'; mv $REPLY_FILE $REPLY_FILE.done"
+tmux split-window -v "nvim +':CopilotChat $PROMPT for the following: $(cat $STDIN_FILE). If the result is code, code only without \`\`\`-markers at the beginning and the end.'; mv $REPLY_FILE $REPLY_FILE.done"
while [ ! -f "$REPLY_FILE.done" ]; do
sleep 0.2
done
-sed -n '/## Copilot/,/^COPILOT_END/ { /^## Copilot/d; /\[file:/d; /^COPILOT_END/d; p; }' $REPLY_FILE.done
+sed -n '/^## Copilot/,/^## User/ { /^## Copilot/d; /\[file:/d; /^## User/d; p; }' $REPLY_FILE.done