Re: serve-d and emacs

2023-12-19 Thread Renato via Digitalmars-d-learn
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/Directory-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.


Re: serve-d and emacs

2023-05-04 Thread Seeand Amans via Digitalmars-d-learn

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


Check out popular tpurist places to visit in Port Blair and grab 
best Tour Packages For Andaman And Nicobar Island offered by 
Seeandamans.com at discounted price. Grab the exciting deals on 
Port Blair trip Packages today.





https://www.seeandamans.com/



Re: serve-d and emacs

2023-04-20 Thread Christian Köstlin via Digitalmars-d-learn
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


Re: serve-d and emacs

2023-04-19 Thread Per Nordlöw via Digitalmars-d-learn

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-hook mode #'lsp)
(add-to-list 'lsp-language-id-configuration `(,mode . "d")))
  (lsp-register-client
   (make-lsp-client
:new-connection (lsp-stdio-connection #'serve-d-command)
: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.


Re: serve-d and emacs

2023-04-19 Thread Per Nordlöw via Digitalmars-d-learn

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-hook mode #'lsp)
(add-to-list 'lsp-language-id-configuration `(,mode . "d")))
  (lsp-register-client
   (make-lsp-client
:new-connection (lsp-stdio-connection #'serve-d-command)
: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")
```

?


Re: serve-d and emacs

2023-04-19 Thread Per Nordlöw via Digitalmars-d-learn

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-hook mode #'lsp)
(add-to-list 'lsp-language-id-configuration `(,mode . "d")))
  (lsp-register-client
   (make-lsp-client
:new-connection (lsp-stdio-connection #'serve-d-command)
: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?


Re: serve-d and emacs

2023-04-19 Thread Per Nordlöw via Digitalmars-d-learn

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`.


Re: serve-d and emacs

2023-04-19 Thread Per Nordlöw via Digitalmars-d-learn
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?


Re: serve-d and emacs

2021-05-01 Thread Imperatorn via Digitalmars-d-learn

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





Re: serve-d and emacs

2021-04-30 Thread Christian Köstlin via Digitalmars-d-learn

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


Re: serve-d and emacs

2021-04-28 Thread Christian Köstlin via Digitalmars-d-learn

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



Re: serve-d and emacs

2021-04-26 Thread WebFreak001 via Digitalmars-d-learn

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