From b2214571048854dbed7f8660cfbce77470c96689 Mon Sep 17 00:00:00 2001 From: pika Date: Mon, 24 Mar 2025 15:41:29 +0100 Subject: [PATCH] feat: inline insert if only one line --- lua/pika/core/keymaps.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lua/pika/core/keymaps.lua b/lua/pika/core/keymaps.lua index 6f205cd..69fc905 100644 --- a/lua/pika/core/keymaps.lua +++ b/lua/pika/core/keymaps.lua @@ -77,6 +77,13 @@ vim.keymap.set({ "n", "i" }, "tt", function() -- Insert at cursor position local row, col = unpack(vim.api.nvim_win_get_cursor(0)) - vim.api.nvim_buf_set_lines(0, row, row, false, lines) + if #lines == 1 then + -- Insert inline if the result is a single line + local current_line = vim.api.nvim_get_current_line() + local new_line = current_line:sub(1, col) .. lines[1] .. current_line:sub(col + 1) + vim.api.nvim_set_current_line(new_line) + else + vim.api.nvim_buf_set_lines(0, row, row, false, lines) + end end) end, { desc = "Insert Shell Output at Cursor" })