Skip to content

[feature] Added silent parameter to the dap.repl.execute function to not repeat the command after execution.#1566

Open
banana59 wants to merge 3 commits into
mfussenegger:masterfrom
banana59:feature/silent_parameter_dap_repl_execute
Open

[feature] Added silent parameter to the dap.repl.execute function to not repeat the command after execution.#1566
banana59 wants to merge 3 commits into
mfussenegger:masterfrom
banana59:feature/silent_parameter_dap_repl_execute

Conversation

@banana59
Copy link
Copy Markdown

@banana59 banana59 commented Oct 23, 2025

Example for Python

local repl = require('dap.repl')

repl.commands = vim.tbl_extend('force', repl.commands, {
    custom_commands = {
        ["."] = function(expr)
            if not expr or expr:match("^%s*$") then
                repl.append('Usage: . <expression>')
                return
            end

            local wrapped = 'repr(' .. expr .. ')'
            repl.execute(wrapped, {context='repl', silent=true})
        end,
    }
})

Execution in the repl:

. <variable>

to show a variable without meta information.

I have tested this in python for the nvim-dap commit 6782b09.

This is related to these issues:

repeat the command after execution. Example:
    local repl = require('dap.repl')

    repl.commands = vim.tbl_extend('force', repl.commands, {
        custom_commands = {
            ["."] = function(expr)
                if not expr or expr:match("^%s*$") then
                    repl.append('Usage: . <expression>')
                    return
                end

                local wrapped = 'repr(' .. expr .. ')'
                repl.execute(wrapped, {context='repl', silent=true})
            end,
        }
    })

Execution in the repl:

    . <variable>
@banana59 banana59 force-pushed the feature/silent_parameter_dap_repl_execute branch from e3947e2 to eb0f578 Compare October 23, 2025 13:29
@mfussenegger
Copy link
Copy Markdown
Owner

Isn't this a bit confusing if there's no separation/variable indication in the output?

@banana59
Copy link
Copy Markdown
Author

Certainly in some cases, that's why the default is still verbose. I quite liked the neatness in this usecase, that . dataFrame directly outputs the content instead of first outputting the interpreted version like repr(dataFrame).

@banana59
Copy link
Copy Markdown
Author

banana59 commented Mar 15, 2026

I have adjusted the implementation such that now simply entering the variable within the configuration below allows to suppress unwanted metainfo / tree output in repl.

dap.defaults.fallback.repl_hide_tree_filetypes = {
    python = true,
    python3 = true,
}

One could still use the DAP Scopes to inspect variables in more detail or for e.g. python one could use dir(<variable>).

@banana59
Copy link
Copy Markdown
Author

@mfussenegger Could you please review this PR again?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants