Skip to content

Send buffer code to REPL #962

Answered by LiadOz
zippeurfou asked this question in Q&A
May 31, 2023 · 3 comments · 3 replies
Discussion options

You must be logged in to vote

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.
you could play with it to achieve more complex operations.

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by zippeurfou
Comment options

You must be logged in to vote
2 replies
@LiadOz
Comment options

@zippeurfou
Comment options

Comment options

You must be logged in to vote
1 reply
@wilsonchen719
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants