diff options
| author | Paul Buetow <paul@buetow.org> | 2026-02-08 09:10:32 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-02-08 09:10:32 +0200 |
| commit | f6d2c92703ca4479871a716507a63cb706b14b21 (patch) | |
| tree | d45b950a8b0b90d174e5b37d5085569503459af9 /nvim | |
| parent | 88d2c9ac867e92d482dbeea5e5fc759b1f195cdf (diff) | |
cleanup
Diffstat (limited to 'nvim')
| -rw-r--r-- | nvim/init.lua | 70 |
1 files changed, 0 insertions, 70 deletions
diff --git a/nvim/init.lua b/nvim/init.lua deleted file mode 100644 index c3b8701..0000000 --- a/nvim/init.lua +++ /dev/null @@ -1,70 +0,0 @@ - -require("CopilotChat").setup { - -- See Configuration section for options -} - -local timer = vim.loop.new_timer() -- Initialize the timer - -vim.api.nvim_create_autocmd("BufEnter", { - pattern = "*", - callback = function() - if vim.bo.filetype == "copilot-chat" then - local copilot_chat_buf = vim.api.nvim_get_current_buf() - vim.cmd("wincmd _") -- Maximize height - vim.cmd("wincmd |") -- Maximize width - local file_path = vim.fn.expand("~/.copilot_chat_output.txt") - - -- Start the timer with a 2-second interval - timer:start(1000, 1000, vim.schedule_wrap(function() - if copilot_chat_buf and vim.api.nvim_buf_is_valid(copilot_chat_buf) then - -- Get all lines in the buffer - 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("^## 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 - - -- Write the buffer content to the file - vim.api.nvim_buf_call(copilot_chat_buf, function() - vim.cmd("write! " .. file_path) - end) - end - end)) - end - end, -}) - -vim.api.nvim_create_user_command('CopilotAsk', function(args) - local chat = require("CopilotChat") - local input - if args.args and args.args ~= "" then - input = args.args - else - local input_file = os.getenv("HOME") .. "/.copilot_chat_input.txt" - local file = io.open(input_file, "r") - if file then - input = file:read("*all") - file:close() - else - print("Error: Unable to open input file.") - return - end - end - chat.ask(input) -end, { force = true, range = true, nargs = "?" }) - - |
