Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt att using serve-d via lsp-mode in Emacs #317

Open
nordlow opened this issue Apr 20, 2023 · 3 comments
Open

Attempt att using serve-d via lsp-mode in Emacs #317

nordlow opened this issue Apr 20, 2023 · 3 comments

Comments

@nordlow
Copy link

nordlow commented Apr 20, 2023

Adding

(defun serve-d-command ()
  "Shell command to start serve-d."
  '("dub" "run" "serve-d@~master")) ;; "--logfile" "serve-d.log" "--loglevel" "all"

(require 'lsp-mode 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))

to my ~/.emacs.d/init.el followed by a manual evalutation of

(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))

and manual activation of lsp-mode in d-mode sets up a connection to an instance of serve-d.

However trying out xref-find-definitions on, for instance, the symbol WordOrder.mostSignificantWordFirst at https://github.com/nordlow/gmp-d/blob/master/src/gmp/z.d#L312 results in

Debugger entered--Lisp error: (error "Attempted to get unknown instance component DCDComponent in instance cwd:$HOME/Work/gmp-d")
  error("Attempted to get unknown instance component DCDComponent in instance cwd:$HOME/Work/gmp-d")
  lsp-request("textDocument/definition" (:textDocument (:uri "file://$HOME/Work/gmp-d/src/gmp/z.d") :position (:line 311 :character 25)))
  #f(compiled-function (backend identifier) #<bytecode 0xc84f7d380117922>)(xref-lsp #("mostSignificantWordFirst" 0 24 (identifier-at-point t face (highlight-symbol-face font-lock-constant-face) fontified t)))
  apply(#f(compiled-function (backend identifier) #<bytecode 0xc84f7d380117922>) xref-lsp #("mostSignificantWordFirst" 0 24 (identifier-at-point t face (highlight-symbol-face font-lock-constant-face) fontified t)))
  xref-backend-definitions(xref-lsp #("mostSignificantWordFirst" 0 24 (identifier-at-point t face (highlight-symbol-face font-lock-constant-face) fontified t)))
  #f(compiled-function () #<bytecode -0xe5cbf2f02411dfc>)()
  xref-show-definitions-buffer(#f(compiled-function () #<bytecode -0xe5cbf2f02411dfc>) ((window . #<window 9 on z.d>) (display-action) (auto-jump)))
  xref--show-defs(#f(compiled-function () #<bytecode -0xe5cbf2f02411dfc>) nil)
  xref--find-definitions(#("mostSignificantWordFirst" 0 24 (identifier-at-point t face (highlight-symbol-face font-lock-constant-face) fontified t)) nil)
  xref-find-definitions(#("mostSignificantWordFirst" 0 24 (identifier-at-point t face (highlight-symbol-face font-lock-constant-face) fontified t)))
  funcall-interactively(xref-find-definitions #("mostSignificantWordFirst" 0 24 (identifier-at-point t face (highlight-symbol-face font-lock-constant-face) fontified t)))
  command-execute(xref-find-definitions)

. What's missing?

See also https://forum.dlang.org/post/[email protected].

@nordlow nordlow changed the title Problems using serve-d with lsp-mode in Emacs Attempt att using serve-d via lsp-mode in Emacs Apr 20, 2023
@WebFreak001
Copy link
Member

lookup works fine here with vscode, so it's likely an issue with how serve-d is initialized with emacs.

Can you share more log, especially the initialization parts?

@nordlow
Copy link
Author

nordlow commented Apr 21, 2023

lookup works fine here with vscode, so it's likely an issue with how serve-d is initialized with emacs.

Can you share more log, especially the initialization parts?

Ok, thanks.

Which logs are you referring? The output from serve-d?

@WebFreak001
Copy link
Member

WebFreak001 commented Apr 22, 2023

the LSP logs, ideally also what emacs sends and receives, but the serve-d logs alone (e.g. piped to a file) would probably also help already.

Enable trace logging for it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants