dap-mode icon indicating copy to clipboard operation
dap-mode copied to clipboard

Documentation, and how to use (require dap-<lang>)

Open johnhamelink opened this issue 3 years ago • 0 comments

HI there,

I've managed to figure out how to use dap-mode with PHP today. I'm very excited about being able to debug PHP, Elixir, and Typescript in emacs!

One thing I struggled with in the documentation was the way that the language-specific modes are referenced. For example, with PHP, the advice is simply to evaluate (require 'dap-php). For me, this was confusing as I wasn't sure how to automate this for PHP buffers.

I initially used my dir-locals.el file to evaluate the function when I entered a php-mode buffer while inside a php project, but this requires a dir-locals.el file for each php project I want to debug.

Here's what my dir-locals.el ended up looking like, for those interested:

((nil . ((lsp-file-watch-ignored-directories . ("/\\.git$"
						"/\\.github$"
						"/\\.idea$"
						"/contrib$"
						"/app/Vendor$"
						"/app/tmp$"
						"/app/webroot$"))
	 (projectile-project-compilation-cmd . "docker-compose up --build")
	 (projectile-compile-use-comint-mode . t)
         ))
(php-mode . ((eval . (require 'dap-php))))))

However I settled on adding a hook to php-mode to my init.el instead, which will work with any php-mode buffer:

(use-package php-mode
  :mode "\\.php\'"
  :config
  (add-hook 'php-mode-hook (lambda () (require 'dap-php)))
  :hook
  (php-mode . lsp-deferred))

I thought I'd share this, as I'm sure quite a few newbies will struggle with this also!

johnhamelink avatar Jul 09 '21 11:07 johnhamelink