mfussenegger / nvim-dap

Debug Adapter Protocol client implementation for Neovim
GNU General Public License v3.0
5.46k stars 194 forks source link

Make dap.repl.evaluate_handler public #1089

Closed wookayin closed 10 months ago

wookayin commented 10 months ago

This allows users to have a minimal configuration point for customizing dap-repl's behavior on printing variables or expressions.

(One possible approach/workaround for #1062)

mfussenegger commented 10 months ago

Thanks but I'd rather keep that prevent. Exposing it might get in the way latter when adding proper formatting extensions.

If you you really want to override the full handler, you could instead define a custom command:

  repl.commands.custom_commands = {
    [".p"] = function(text)
      local session = dap.session()
      if not session then
        return
      end
      session:evaluate(text, function(err, resp)
        vim.print(err or "no error")
        vim.print(resp or "no response")
      end)
    end,
  }
wookayin commented 10 months ago

I understand that you don't want this approach. However, what I wanted to override is the evaluate_handler without any custom commands (for #737 #1062, etc.), evaluation of any arbitrary expressions in the REPL; so custom commands would not work for me.

mfussenegger commented 10 months ago

However, what I wanted to override is the evaluate_handler without any custom commands (for https://github.com/mfussenegger/nvim-dap/issues/737 https://github.com/mfussenegger/nvim-dap/issues/1062, etc.), evaluation of any arbitrary expressions in the REPL; so custom commands would not work for me.

The snippet I posted allows to evaluate arbitrary expressions. .p foobar would evaluate foobar.

wookayin commented 10 months ago

I'd like to have foobar working instead of typing .p foobar.

dap> foobar
"foobar"