mirror of
https://github.com/don-philipe/dotfiles.git
synced 2025-11-08 22:57:03 +01:00
Add run and paste mapping to neovim
This commit is contained in:
@@ -14,3 +14,12 @@ vim.keymap.set("n", "<Up>", ":resize -1<CR>")
|
||||
vim.keymap.set("n", "<Down>", ":resize +1<CR>")
|
||||
vim.keymap.set("n", "<Left>", ":vertical resize -1<CR>")
|
||||
vim.keymap.set("n", "<Right>", ":vertical resize +1<CR>")
|
||||
|
||||
-- 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", "<C-c>", run_and_paste)
|
||||
|
||||
Reference in New Issue
Block a user