serve-d and emacs

Christian Köstlin christian.koestlin at gmail.com
Wed Apr 28 23:04:27 UTC 2021


On 26.04.21 21:13, WebFreak001 wrote:
> On Monday, 26 April 2021 at 18:45:08 UTC, Christian Köstlin wrote:
>> Does anybody use serve-d with emacs (lsp-mode or eglot)?
>> I would love to see the configuration!
>>
>> Kind regards,
>> Christian
> 
> if you configure it yourself, feel free to share the configuration and 
> maybe PR it to serve-d repo.
> 
> Basic setup should be quite easy, see vim for reference: 
> https://github.com/Pure-D/serve-d/blob/master/editor-vim.md
I finally got it working for me.
Its a little tricky, because the basic setup works e.g. with emacs 27.2 
or newer, but not with 27.1.
All that is needed (if you have the right emacs version and use straight 
for installing packages) is:

     (use-package d-mode
       :straight t)

     (use-package eglot
       :straight t
       :init (progn
               (add-hook 'd-mode-hook 'eglot-ensure)
               ))
     (add-to-list
        'eglot-server-programs
        '(d-mode . ("PATH_TO_SERVE_D/serve-d")))


With a plain emacs installation the following should work:

     (require 'package)
     (add-to-list 'package-archives '("melpa" . 
"https://melpa.org/packages/") t)
     (package-initialize)
     (package-refresh-contents)
     (package-install 'project)
     (package-install 'd-mode)
     (package-install 'eglot)
     (require 'project)
     (require 'd-mode)
     (require 'eglot)

     (add-to-list
        'eglot-server-programs
        '(d-mode . ("FULL_PATH_TO_SERVE_D")))
     (add-hook 'd-mode-hook 'eglot-ensure)

(One emacs restart might be necessary, as there is a conflict of version 
for the dependency "project".

Kind regards,
Christian



More information about the Digitalmars-d-learn mailing list