Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yank expression's evalname automatically to e register on regular yank #1391

Merged
merged 1 commit into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions lua/dap/_cmds.lua
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,21 @@ function M.newlaunchjson(args)
end


function M.yank_evalname()
if vim.v.event.operator ~= "y" or vim.v.event.visual == true then
return
end
local buf = api.nvim_get_current_buf()
local layer = require("dap.ui").get_layer(buf)
if not layer then
return
end
local lnum = api.nvim_win_get_cursor(0)[1] - 1
local item = (layer.get(lnum) or {}).item
if item and item.evaluateName then
vim.fn.setreg("e", item.evaluateName)
end
end


return M
6 changes: 6 additions & 0 deletions lua/dap/repl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ local function new_buf()
api.nvim_buf_set_keymap(buf, 'n', 'o', "<Cmd>lua require('dap.ui').trigger_actions()<CR>", {})
api.nvim_buf_set_keymap(buf, 'i', '<up>', "<Cmd>lua require('dap.repl').on_up()<CR>", {})
api.nvim_buf_set_keymap(buf, 'i', '<down>', "<Cmd>lua require('dap.repl').on_down()<CR>", {})
api.nvim_create_autocmd("TextYankPost", {
buffer = buf,
callback = function()
require("dap._cmds").yank_evalname()
end,
})
vim.fn.prompt_setprompt(buf, 'dap> ')
vim.fn.prompt_setcallback(buf, execute)
if vim.fn.has('nvim-0.7') == 1 then
Expand Down
12 changes: 12 additions & 0 deletions lua/dap/ui/widgets.lua
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ M.scopes = {
dap.listeners.after['event_terminated'][view] = reset_tree
dap.listeners.after['event_exited'][view] = reset_tree
local buf = new_buf()
api.nvim_create_autocmd("TextYankPost", {
buffer = buf,
callback = function()
require("dap._cmds").yank_evalname()
end,
})
vim.bo[buf].tagfunc = "v:lua.require'dap'._tagfunc"
api.nvim_buf_attach(buf, false, {
on_detach = function()
Expand Down Expand Up @@ -376,6 +382,12 @@ do
new_buf = function()
local buf = new_buf()
vim.bo[buf].tagfunc = "v:lua.require'dap'._tagfunc"
api.nvim_create_autocmd("TextYankPost", {
buffer = buf,
callback = function()
require("dap._cmds").yank_evalname()
end,
})
return buf
end,
before_open = function(view)
Expand Down
Loading