April 20, 2023
I tried to reproduce my old eglot experiment, and for me serve-d was not even compiling with the newest dmd. Which versions are you using?

Kind regards,
Christian
December 19, 2023

On Thursday, 20 April 2023 at 19:54:11 UTC, Christian Köstlin wrote:

>

I tried to reproduce my old eglot experiment, and for me serve-d was not even compiling with the newest dmd. Which versions are you using?

Kind regards,
Christian

I've just managed to make Emacs 29 work with serve-d using use-package and eglot (which both come built-in on Emacs 29+).

If anyone is interested, I just downloaded a pre-built binary from the serve-d Github releases page, then added this to my init.el file:

;; D
(use-package d-mode :ensure t
  :init (with-eval-after-load 'eglot
          (add-to-list 'eglot-server-programs
                       '(d-mode . ("~/programming/apps/serve-d")))))

This follows the eglot documentation's advice.
When you go do a D buffer, d-mode starts up automatically, but not eglot... just hit "M-x eglot" to get serve-d assistance (which will also work on other files you open in the same project).

I found the eglot docs quite helpful: https://joaotavora.github.io/eglot/#Setting-Up-LSP-Servers

Things that are working for me (so you can check if your setup is working):

  • eglot-format-buffer - formats the buffer
  • minibuffer docs - as you point at code elements.
  • code navigation - e.g. hit s-. to go to a definition, including D stdlib.
  • auto-completion - shows available symbols, even from non-imported modules.
  • flycheck - shows errors as you type, highlighting them in the editor.

The auto-import functionality does not seem to work (it doesn't automatically insert imports, despite the auto-completions saying "auto-import ...". But apart from that, this is a very nice environment to write D code!

I also added a ".dir-locals.el" file on the root of my project with something like this (so that the formatter doesn't put 8 spaces on indentation! And "M-x compile" does the right thing):

((nil . ((indent-tabs-mode . nil)
         (tab-width . 4)))
 (d-mode . ((compile-command . "dmd -L-ld_classic -run"))))

Hope that helps others as I had to spend some time trying to do more advanced stuff when the setup that actually works is really basic.

1 2
Next ›   Last »