diff --git a/.config/nvim/lua/config/remap.lua b/.config/nvim/lua/config/remap.lua index 038ed82..f1fb84c 100644 --- a/.config/nvim/lua/config/remap.lua +++ b/.config/nvim/lua/config/remap.lua @@ -14,3 +14,12 @@ vim.keymap.set("n", "", ":resize -1") vim.keymap.set("n", "", ":resize +1") vim.keymap.set("n", "", ":vertical resize -1") vim.keymap.set("n", "", ":vertical resize +1") + +-- prompt user for command, run it and put it's output at cursor position +local function run_and_paste() + local out_raw = vim.fn.system(vim.fn.input('Command: ')) + local out = string.gsub(out_raw, "\n", "") + local row, col = unpack(vim.api.nvim_win_get_cursor(0)) + vim.api.nvim_buf_set_text(0, row - 1, col, row - 1, col, { out }) +end +vim.keymap.set("n", "", run_and_paste)