feat: inline insert if only one line
This commit is contained in:
parent
cc73f3754d
commit
b221457104
1 changed files with 8 additions and 1 deletions
|
@ -77,6 +77,13 @@ vim.keymap.set({ "n", "i" }, "<leader>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" })
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue