Send buffer code to REPL #962
-
Hi there,
One issue I have is that the REPL somehow does not allow me to:
I mostly use nvim-dap-python with debugpy. Let me know if this is not the right place for it. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
Here is a snippet that allows you to add lines to the current prompt buffer, create a file called dap-repl.lua in your ftplugin folder: local function add_line(line)
local lnum = vim.fn.line('$')
line = string.gsub(line, "\n", "")
vim.api.nvim_buf_set_lines(0, lnum - 1, lnum, true, {'dap> ' .. line})
vim.cmd('startinsert!')
end
vim.keymap.set('n', 'p', function() add_line(vim.fn.getreg('"')) end, {buffer = 0}) this will allow you to use p in the dap repl buffer. |
Beta Was this translation helpful? Give feedback.
-
Thanks! |
Beta Was this translation helpful? Give feedback.
-
With local dap = require("dap")
vim.keymap.set("x", "<leader>di", function()
local lines = vim.fn.getregion(vim.fn.getpos("."), vim.fn.getpos("v"))
dap.repl.open()
dap.repl.execute(table.concat(lines, "\n"))
end) |
Beta Was this translation helpful? Give feedback.
Here is a snippet that allows you to add lines to the current prompt buffer, create a file called dap-repl.lua in your ftplugin folder:
this will allow you to use p in the dap repl buffer.
you could play with it to achieve more complex operations.