svaante / dape

Debug Adapter Protocol for Emacs
GNU General Public License v3.0
448 stars 25 forks source link

Launching `dape` opens two copies of dape-shell. #73

Closed aatxe closed 5 months ago

aatxe commented 6 months ago

I'm not entirely sure what the cause of this is, it's totally possible it's a configuration on my end, but for whatever reason, whenever I launch dape, I end up with two buffers open for *dape-shell*. Everything works totally fine, but it's annoying to have the second copy of the buffer open and cut the actual window for code in half. The attached image shows what I get just from running M-x dape and my current configuration that I'm running this with is set up as:

  (add-to-list 'dape-configs
               `(lut
                 modes (c++-mode)
                 ensure dape-ensure-command fn dape-config-autoport command "codelldb" command-cwd dape-command-cwd
                 :type "lldb"
                 :request "launch"
                 command-args ("--port" :autoport)
                 port :autoport
                 :cwd "."
                 :args #1=["--fflags=true,DebugLuauDeferredConstraintResolution=true"]
                 :program "build/ninja/common-tests/optimized/Luau/Luau.UnitTest"
                 :preRunCommands #2=["command script import ./Client/Luau/tools/lldb_formatters.py", "command source ./Client/Luau/tools/lldb_formatters.lldb"]))

image

svaante commented 6 months ago

Hey! That it's annoying. Would you mind sharing your configuration?

aatxe commented 6 months ago

I'm using doom-emacs, so things might be complicated by that somehow, but as far as config for dape in particular:

;;; in packages.el for doom
(package! jsonrpc)
(package! dape)

;;; in config.el for doom
(after! dape
  (setq dape-cwd-fn 'projectile-project-root)
  (setq dape-buffer-window-arrangement 'right)

  (add-to-list 'dape-configs
               `(lut-noopt
                 modes (c++-mode)
                 ensure dape-ensure-command fn dape-config-autoport command "codelldb" command-cwd dape-command-cwd
                 :type "lldb"
                 :request "launch"
                 command-args ("--port" :autoport)
                 port :autoport
                 :cwd "."
                 :args #1=["--fflags=true,DebugLuauDeferredConstraintResolution=true"]
                 :program "build/ninja/common-tests/noopt/Luau/Luau.UnitTest"
                 :preRunCommands #2=["command script import ./Client/Luau/tools/lldb_formatters.py", "command source ./Client/Luau/tools/lldb_formatters.lldb"]))

  (add-to-list 'dape-configs
               `(lut
                 modes (c++-mode)
                 ensure dape-ensure-command fn dape-config-autoport command "codelldb" command-cwd dape-command-cwd
                 :type "lldb"
                 :request "launch"
                 command-args ("--port" :autoport)
                 port :autoport
                 :cwd "."
                 :args #1=["--fflags=true,DebugLuauDeferredConstraintResolution=true"]
                 :program "build/ninja/common-tests/optimized/Luau/Luau.UnitTest"
                 :preRunCommands #2=["command script import ./Client/Luau/tools/lldb_formatters.py", "command source ./Client/Luau/tools/lldb_formatters.lldb"])))
svaante commented 6 months ago

No special window configurations? Starting dape with transient or hydra? I might give doom ago and see if I can reproduce the issue.

aatxe commented 6 months ago

I don't believe so. It really should be as mundane a setup as is possible, I think, so obviously I was pretty surprised at the behavior. :)

svaante commented 6 months ago

Hey tried it out with of the shelf doom config with no configuration and dape-shell was placed in the correct window.

The following might solve you issue

(add-to-list 'display-buffer-alist
             ("\\*dape-repl\\*"
              (display-buffer-in-side-window)
              (side . bottom)
              (slot . 1)))
aatxe commented 5 months ago

Hmm, I tried that and when I load my configuration, I get the following error:

Warning (initialization): An error occurred while loading ‘/Users/aaronweiss/.config/emacs/.local/etc/@/init.28.elc’:

Error caused by user's config or system: /Users/aaronweiss/.doom.d/config.el, (invalid-function \*dape-repl\*)

To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file.  Start Emacs with
the ‘--debug-init’ option to view a complete error backtrace. Disable showing Disable logging

And the same error occurs if I try to use dape-shell instead of dape-repl there. I put this config in the after! macro, so it should be running after dape is loaded.

svaante commented 5 months ago

Sorry I made an typo, missed an single quote:

(add-to-list 'display-buffer-alist
             '("\\*dape-repl\\*"
               (display-buffer-in-side-window)
               (side . bottom)
               (slot . 1)))
aatxe commented 5 months ago

I've tried that way with both dape-repl anddape-shell (the latter is the one that's actually being duplicated), and unfortunately neither seems to fix the problem. Is there some way I could dump some relevant state or something to help root cause it? I'm not an advanced enough emacs user to know the right way to debug stuff like this, but I know that something like that ought to exist.

svaante commented 5 months ago

Hey, I might have made some progress on this issue. I found an unexpected side effect in dape's way of launching the shell. I have reworked the shell creation. If you use the latest master branch the issue might be fixed. I have no idea how you install packages from git forges instead of package repositories in doom but that information should be available somewhere.

aatxe commented 5 months ago

Hah, awesome! Got a chance to switch over to the GH version and you did indeed fix it! Thanks so much! :3