Browse Source

Got dotnet dap working

master
Josh Wolfe 1 week ago
parent
commit
28f605a676
  1. 16
      emacs/.emacs.d/base/completion.el
  2. 2
      emacs/.emacs.d/base/settings.el
  3. 54
      emacs/.emacs.d/lisp/netcoredbg-dap.el

16
emacs/.emacs.d/base/completion.el

@ -16,7 +16,8 @@ @@ -16,7 +16,8 @@
"l r" '(lsp-rename :wk "Rename")
"l i" '(lsp-find-implementation :wk "Implementation")
"l d" '(lsp-find-definition :wk "Definition")
"l u" '(lsp-find-references :wk "Usages"))
"l u" '(lsp-find-references :wk "Usages")
"l D" '(dap-debug :wk "Debug"))
:init
(setq read-process-output-max (* 1024 1024)
lsp-idle-delay 0.500)
@ -28,10 +29,19 @@ @@ -28,10 +29,19 @@
:after lsp-mode)
(use-package dap-mode
:defer t
:commands (dap-debug)
:general
(general-define-key
:keymaps 'dap-mode-map
:states '(normal insert)
"<f5>" 'dap-continue
"<f10>" 'dap-next
"<f11>" 'dap-step-in
"<f12>" 'dap-step-out)
:custom
(dap-auto-configure-mode t)
(require 'dap-netcore))
:config
(require 'netcoredbg-dap))
(defun wolfe/hot-load-company (orig-fun &rest args)
(unless (bound-and-true-p company-mode)

2
emacs/.emacs.d/base/settings.el

@ -22,7 +22,7 @@ @@ -22,7 +22,7 @@
(hook-if-daemonp
(lambda ()
(when (display-graphic-p)
(let ((utf8-font "Fira Code"))
(let ((utf8-font "Symbola"))
(set-fontset-font "fontset-startup" '(#x000000 . #x3FFFFF) utf8-font)
(set-fontset-font "fontset-default" '(#x000000 . #x3FFFFF) utf8-font)
(set-fontset-font "fontset-standard" '(#x000000 . #x3FFFFF) utf8-font)))))

54
emacs/.emacs.d/lisp/netcoredbg-dap.el

@ -0,0 +1,54 @@ @@ -0,0 +1,54 @@
;;; netcoredbg-dap.el -*- lexical-binding: t; -*-
(defun dap-netcore--debugger-cmd ()
"The location of the netcoredbg executable."
(let ((file-ext (pcase system-type
(`windows-nt ".exe")
(_ ""))))
(executable-find "netcoredbg")))
(defun dap-netcore--debugger-locate-or-install ()
"Return the location of netcoredbg."
(let ((dbg (dap-netcore--debugger-cmd)))
(unless (file-exists-p dbg)
(error "Cannot start debugger configuration without netcoredbg"))
dbg))
(defun dap-netcore--populate-args (conf)
"Populate CONF with arguments to launch or attach netcoredbg."
(dap--put-if-absent conf :dap-server-path (list (dap-netcore--debugger-locate-or-install) "--interpreter=vscode"))
(pcase (plist-get conf :mode)
("launch"
(dap--put-if-absent
conf
:program
(let ((project-dir (locate-dominating-file
(file-name-directory buffer-file-name)
(lambda (parent) (directory-files parent nil ".*\.csproj")))))
(save-mark-and-excursion
(find-file (concat (f-slash project-dir) "*.*proj") t)
(let ((csproj (buffer-file-name))
(res (if (libxml-available-p)
(libxml-parse-xml-region (point-min) (point-max))
(xml-parse-region (point-min) (point-max)))))
(kill-buffer)
(f-join project-dir "bin" "Debug"
(dom-text (dom-by-tag res 'TargetFramework))
(dom-text (dom-by-tag res 'RuntimeIdentifier))
(concat (f-base csproj) ".dll")))))))
("attach"
(dap--put-if-absent conf :processId (string-to-number (read-string "Enter PID: " "2345"))))))
(dap-register-debug-provider
"coreclr"
'dap-netcore--populate-args)
(dap-register-debug-template ".Net Core Launch (Console)"
(list :type "coreclr"
:request "launch"
:mode "launch"
:name "NetCoreDbg::Launch"
:dap-compilation "dotnet build"))
(provide 'netcoredbg-dap)
Loading…
Cancel
Save