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

dap-mode not using direnv #776

Open
LemonBreezes opened this issue Feb 17, 2024 · 1 comment
Open

dap-mode not using direnv #776

LemonBreezes opened this issue Feb 17, 2024 · 1 comment

Comments

@LemonBreezes
Copy link

dap-mode is not launching my program with the environment variables I set in my .envrc and have set buffer-local to my code files using direnv.
Related issues: emacs-lsp/lsp-mode#2583, purcell/envrc#71.

@LemonBreezes
Copy link
Author

LemonBreezes commented Feb 18, 2024

I just came up with a hacky advice to work around this:

(defun cae-dap-debug-pass-envrc-a (args)
  (when (length= (plist-get (car args) :environment) 0)
    (plist-put (car args) :environment
               (apply #'vector
                      (mapcar (lambda (s)
                                (let ((m (string-match "=" s)))
                                  (if m
                                      (list :name
                                            (substring-no-properties s 0 m)
                                            :value
                                            (substring-no-properties s (1+ m)
                                                                     (length s)))
                                    (list :name s
                                          :value ""))))
                              process-environment))))
  args)
(advice-add #'dap-start-debugging-noexpand :filter-args
            #'cae-dap-debug-pass-envrc-a)

Maybe we can add something like this to the package. An option to propagate the program being debugged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant