www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - serve-d and emacs

reply =?UTF-8?Q?Christian_K=c3=b6stlin?= <christian.koestlin gmail.com> writes:
Does anybody use serve-d with emacs (lsp-mode or eglot)?
I would love to see the configuration!

Kind regards,
Christian
Apr 26 2021
parent reply WebFreak001 <d.forum webfreak.org> writes:
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
Apr 26 2021
next sibling parent reply =?UTF-8?Q?Christian_K=c3=b6stlin?= <christian.koestlin gmail.com> writes:
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
Apr 28 2021
parent reply Per =?UTF-8?B?Tm9yZGzDtnc=?= <per.nordlow gmail.com> writes:
On Wednesday, 28 April 2021 at 23:04:27 UTC, Christian Köstlin 
wrote:
 if you configure it yourself, feel free to share the 
 configuration and maybe PR it to serve-d repo.
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:
I'm having problems with serve-d + eglot in Emacs. All calls to ``` eglot-find-declaration eglot-find-implementation eglot-find-typeDefinition ``` answers as ``` eglot--error: [eglot] Sorry, this server doesn't do :textDocument/declaration ``` Are neither of ``` :textDocument/declaration ``` supported? If so what lsp request type should I use to lookup/navigate to definitions? Without such functionality I see no use of eglot. . I'm currently using ```elisp (use-package eglot ;; :straight t :ensure t :defer t :hook (d-mode . eglot-ensure) :config (progn ;; (add-hook 'd-mode-hook 'eglot-ensure) (let ((cmd '("dub" "run" "--vquiet" "serve-d"))) (add-to-list 'eglot-server-programs ;https://forum.dlang.org/post/s6cpls$pg3$1 digitalmars.com `(d-mode . ,cmd)) (add-to-list 'eglot-server-programs ;https://forum.dlang.org/post/s6cpls$pg3$1 digitalmars.com `(d-ts-mode . ,cmd)))) ;; (remove-hook 'd-mode-hook 'eglot-ensure) ) ``` . Has anybody gotten these things to work?
Apr 19 2023
next sibling parent reply Per =?UTF-8?B?Tm9yZGzDtnc=?= <per.nordlow gmail.com> writes:
On Wednesday, 19 April 2023 at 09:37:56 UTC, Per Nordlöw wrote:
 . Has anybody gotten these things to work?
I'm gonna try `lsp-mode` instead of `eglot`.
Apr 19 2023
parent reply Per =?UTF-8?B?Tm9yZGzDtnc=?= <per.nordlow gmail.com> writes:
On Wednesday, 19 April 2023 at 09:39:19 UTC, Per Nordlöw wrote:
 On Wednesday, 19 April 2023 at 09:37:56 UTC, Per Nordlöw wrote:
 . Has anybody gotten these things to work?
I'm gonna try `lsp-mode` instead of `eglot`.
I believe this should work ```elisp (defun serve-d-command () "Shell command to start serve-d." '("dub" "run" "--vquiet" "serve-d")) (when (require 'lsp nil t) (dolist (mode '(d-mode d-ts-mode)) (add-to-list 'lsp-language-id-configuration `(,mode . "d"))) (lsp-register-client (make-lsp-client :major-modes '(d-mode d-ts-mode) :server-id 'serve-d))) ``` but unfortunately I get status disconncted in the mode-line and the call to dub run shuts down. Clues anyone?
Apr 19 2023
next sibling parent Per =?UTF-8?B?Tm9yZGzDtnc=?= <per.nordlow gmail.com> writes:
On Wednesday, 19 April 2023 at 10:35:31 UTC, Per Nordlöw wrote:
 I believe this should work

 ```elisp
 (defun serve-d-command ()
   "Shell command to start serve-d."
   '("dub" "run" "--vquiet" "serve-d"))

 (when (require 'lsp nil t)
   (dolist (mode '(d-mode d-ts-mode))

 	(add-to-list 'lsp-language-id-configuration `(,mode . "d")))
   (lsp-register-client
    (make-lsp-client

     :major-modes '(d-mode d-ts-mode)
     :server-id 'serve-d)))
 ```

 but unfortunately I get status disconncted in the mode-line and 
 the call to dub run shuts down. Clues anyone?
How do I most easily get the debug output from ``` '("dub" "run" "--vquiet" "serve-d") ``` ?
Apr 19 2023
prev sibling parent Per =?UTF-8?B?Tm9yZGzDtnc=?= <per.nordlow gmail.com> writes:
On Wednesday, 19 April 2023 at 10:35:31 UTC, Per Nordlöw wrote:
 On Wednesday, 19 April 2023 at 09:39:19 UTC, Per Nordlöw wrote:
 On Wednesday, 19 April 2023 at 09:37:56 UTC, Per Nordlöw wrote:
 . Has anybody gotten these things to work?
I'm gonna try `lsp-mode` instead of `eglot`.
I believe this should work ```elisp (defun serve-d-command () "Shell command to start serve-d." '("dub" "run" "--vquiet" "serve-d")) (when (require 'lsp nil t) (dolist (mode '(d-mode d-ts-mode)) (add-to-list 'lsp-language-id-configuration `(,mode . "d"))) (lsp-register-client (make-lsp-client :major-modes '(d-mode d-ts-mode) :server-id 'serve-d))) ``` but unfortunately I get status disconncted in the mode-line and the call to dub run shuts down. Clues anyone?
Hmm, it turns out that using this a call to lsp-mode with this never triggers a call to the elisp function `serve-d-command` . I don't see what's wrong.
Apr 19 2023
prev sibling parent reply =?UTF-8?Q?Christian_K=c3=b6stlin?= <christian.koestlin gmail.com> writes:
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
Apr 20 2023
parent Renato <renato athaydes.com> writes:
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: ```lisp ;; 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](https://www.gnu.org/software/emacs/manual/html_node/emacs/Direc ory-Variables.html) 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): ```lisp ((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.
Dec 19 2023
prev sibling parent reply =?UTF-8?Q?Christian_K=c3=b6stlin?= <christian.koestlin gmail.com> writes:
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 threw together a "minimal" emacs configuration that can be used if you have just a plain emacs and dlang installation. See https://github.com/gizmomogwai/demacs Kind regards, Christian
Apr 30 2021
parent Imperatorn <johan_forsberg_86 hotmail.com> writes:
On Friday, 30 April 2021 at 21:24:35 UTC, Christian Köstlin wrote:
 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 threw together a "minimal" emacs configuration that can be used if you have just a plain emacs and dlang installation. See https://github.com/gizmomogwai/demacs Kind regards, Christian
👍
May 01 2021