emacs-lsp / lsp-mode

Emacs client/library for the Language Server Protocol
https://emacs-lsp.github.io/lsp-mode
GNU General Public License v3.0
4.75k stars 873 forks source link

Inlay hints not showing at all #4152

Open jamesperez2005 opened 1 year ago

jamesperez2005 commented 1 year ago

Thank you for the bug report

Bug description

Note: I failed to trigger lsp-start-plain -- it is crashing on a backtrace relating to svg (?)

I am using lsp-mode with rust-analyzer, installed via doom emacs. The configuration on the doom side is pretty straightforward:

(rust +lsp)

And I do a doom sync -u every morning so I am guessing this means I'm up to date.

When opening a new project, even a simple one like this:

fn main()
{
    let x = 2;
}

I don't get inlay hints displayed for x, even when lsp-inlay-hints-enable is t and when inlay-hints-mode is turned on. I am using the latest Rust analyzer binary, and Emacs 28.2 on macOS 13.5.1

Any help trying to understand what is going wrong with my setup will be greatly appreciated.

Steps to reproduce

fn main()
{
    let x = 2;
}

Expected behavior

Inlay hints are showing

Which Language Server did you use?

rust-analyzer

OS

MacOS

Error callstack

No response

Anything else?

No response

yyoncho commented 1 year ago

I tested it out with the latest rust analyzer and using M-x lsp-start-plain and after setting lsp-inlay-hints-enable to t it works fine.

jamesperez2005 commented 1 year ago

Well, for me lsp-start-plain fails with

(error "Invalid image type ‘svg’")
  signal(error ("Invalid image type ‘svg’"))
  error("Invalid image type `%s'" svg)
  image-type("/var/folders/bs/wqjbrbn948j78gb4303rjdcc0000gn/T/l..." svg nil)
  create-image("/var/folders/bs/wqjbrbn948j78gb4303rjdcc0000gn/T/l..." svg nil :ascent center :width 22 :height 22)
  (if (and (integerp treemacs--icon-size) (image-type-available-p 'imagemagick)) (create-image icon-path 'imagemagick nil :ascent 'center :width width :height height) (create-image icon-path (intern (if (string-match treemacs-file-extension-regex icon-path) (substring icon-path (1+ (match-beginning 0))) icon-path)) nil :ascent 'center :width width :height height))
  (let ((height treemacs--icon-size) (width treemacs--icon-size)) (if (and (integerp treemacs--icon-size) (s-starts-with\? "root-" icon-path)) (progn (let ((w (round (* width 0.909))) (h (round (* height 1.1818)))) (setq width w height h)))) (if (and (integerp treemacs--icon-size) (image-type-available-p 'imagemagick)) (create-image icon-path 'imagemagick nil :ascent 'center :width width :height height) (create-image icon-path (intern (if (string-match treemacs-file-extension-regex icon-path) (substring icon-path (1+ (match-beginning 0))) icon-path)) nil :ascent 'center :width width :height height)))
  (let* ((img-selected (let ((height treemacs--icon-size) (width treemacs--icon-size)) (if (and (integerp treemacs--icon-size) (s-starts-with\? "root-" icon-path)) (progn (let (... ...) (setq width w height h)))) (if (and (integerp treemacs--icon-size) (image-type-available-p 'imagemagick)) (create-image icon-path 'imagemagick nil :ascent 'center :width width :height height) (create-image icon-path (intern (if ... ... icon-path)) nil :ascent 'center :width width :height height)))) (img-unselected (copy-sequence img-selected))) (nconc img-selected '(:background "darkseagreen2")) (nconc img-unselected '(:background "White")) (concat (propertize " " 'display img-unselected 'img-selected img-selected 'img-unselected img-unselected) " "))
  (if (not (image-type-available-p 'png)) fallback (let* ((img-selected (let ((height treemacs--icon-size) (width treemacs--icon-size)) (if (and (integerp treemacs--icon-size) (s-starts-with\? "root-" icon-path)) (progn (let ... ...))) (if (and (integerp treemacs--icon-size) (image-type-available-p ...)) (create-image icon-path 'imagemagick nil :ascent 'center :width width :height height) (create-image icon-path (intern ...) nil :ascent 'center :width width :height height)))) (img-unselected (copy-sequence img-selected))) (nconc img-selected '(:background "darkseagreen2")) (nconc img-unselected '(:background "White")) (concat (propertize " " 'display img-unselected 'img-selected img-selected 'img-unselected img-unselected) " ")))
  (let ((tui-icon fallback) (gui-icon (if (not (image-type-available-p 'png)) fallback (let* ((img-selected (let ... ... ...)) (img-unselected (copy-sequence img-selected))) (nconc img-selected '(:background "darkseagreen2")) (nconc img-unselected '(:background "White")) (concat (propertize " " 'display img-unselected 'img-selected img-selected 'img-unselected img-unselected) " "))))) (cons gui-icon tui-icon))
  (let* ((xs (mapcar #'(lambda (it) (ignore it) (if (stringp it) (downcase it) it)) '("src-closed"))) (fallback (propertize "+ " 'face 'treemacs-term-node-face)) (icons-dir (progn (or (progn (and (memq ... cl-struct-treemacs-theme-tags) t)) (signal 'wrong-type-argument (list 'treemacs-theme treemacs--current-theme))) (aref treemacs--current-theme 2))) (icon-path (treemacs-join-path icons-dir "svgrepo/dir-src-closed.svg")) (icon-pair (let ((tui-icon fallback) (gui-icon (if (not ...) fallback (let* ... ... ... ...)))) (cons gui-icon tui-icon))) (gui-icons (progn (or (progn (and (memq ... cl-struct-treemacs-theme-tags) t)) (signal 'wrong-type-argument (list 'treemacs-theme treemacs--current-theme))) (aref treemacs--current-theme 3))) (tui-icons (progn (or (progn (and (memq ... cl-struct-treemacs-theme-tags) t)) (signal 'wrong-type-argument (list 'treemacs-theme treemacs--current-theme))) (aref treemacs--current-theme 4))) (gui-icon (car icon-pair)) (tui-icon (cdr icon-pair))) nil (if (get-text-property 0 'display gui-icon) nil (setq gui-icon (propertize " " 'display gui-icon))) (let ((--dolist-tail-- xs)) (while --dolist-tail-- (let ((ext (car --dolist-tail--))) (if (symbolp ext) (progn (let* (...) (add-to-list ... ext) (set symbol nil)))) (setq --dolist-tail-- (cdr --dolist-tail--))))) (let ((list xs) (i 0)) (while list (let ((it (car-safe (prog1 list ...))) (it-index i)) (ignore it it-index) (if (and "svgrepo/dir-src-closed.svg" (not (image-type-available-p ...)) (string= (if ... ... "svgrepo/dir-src-closed.svg") "svg")) nil (prog1 nil (puthash it gui-icon gui-icons))) (prog1 nil (puthash it tui-icon tui-icons))) (setq i (1+ i)))))
  (progn (let* ... nil ... ... ...) (let* ... nil ... ... ...) (let* ... nil ... ... ...) (let* ... nil ... ... ...) (let* ... nil ... ... ...) (let* ... nil ... ... ...) (let* ... nil ... ... ...) (let* ... nil ... ... ...) (let* ... nil ... ... ...) (let* ... nil ... ... ...) (let* ... nil ... ... ...) (let* ... nil ... ... ...) (let* ... nil ... ... ...) ...)
  (let* (...) (progn ... ... ... ... ... ... ... ... ... ... ... ... ... ...) (treemacs--propagate-new-icons theme))
  (let* (... ... ...) (add-to-list ... theme) nil (let* ... ... ...) "Default")
  eval-buffer(#<buffer  *load*-564788> nil "/var/folders/bs/wqjbrbn948j78gb4303rjdcc0000gn/T/l..." nil t)  ; Reading at buffer position 32488
  load-with-code-conversion("/var/folders/bs/wqjbrbn948j78gb4303rjdcc0000gn/T/l..." "/var/folders/bs/wqjbrbn948j78gb4303rjdcc0000gn/T/l..." nil t)
  require(treemacs-icons)
  eval-buffer(#<buffer  *load*-301065> nil "/var/folders/bs/wqjbrbn948j78gb4303rjdcc0000gn/T/l..." nil t)  ; Reading at buffer position 1294
  load-with-code-conversion("/var/folders/bs/wqjbrbn948j78gb4303rjdcc0000gn/T/l..." "/var/folders/bs/wqjbrbn948j78gb4303rjdcc0000gn/T/l..." nil t)
  require(treemacs)
  eval-buffer(#<buffer  *load*-829629> nil "/var/folders/bs/wqjbrbn948j78gb4303rjdcc0000gn/T/l..." nil t)  ; Reading at buffer position 1073
  load-with-code-conversion("/var/folders/bs/wqjbrbn948j78gb4303rjdcc0000gn/T/l..." "/var/folders/bs/wqjbrbn948j78gb4303rjdcc0000gn/T/l..." nil t)
  require(lsp-treemacs)
  eval-buffer(#<buffer  *load*-329963> nil "/var/folders/bs/wqjbrbn948j78gb4303rjdcc0000gn/T/l..." nil t)  ; Reading at buffer position 1136
  load-with-code-conversion("/var/folders/bs/wqjbrbn948j78gb4303rjdcc0000gn/T/l..." "/var/folders/bs/wqjbrbn948j78gb4303rjdcc0000gn/T/l..." nil t)
  require(lsp-java)
  (closure ((pkg-list lsp-mode lsp-ui yasnippet lsp-java lsp-python-ms lsp-haskell helm-lsp lsp-treemacs dap-mode lsp-origami lsp-dart company flycheck lsp-pyright rust-mode php-mode scala-mode dart-mode clojure-mode typescript-mode csharp-mode haskell-mode) t) (pkg) (if (package-installed-p pkg) nil (package-install pkg)) (require pkg))(lsp-java)
  mapc((closure ((pkg-list lsp-mode lsp-ui yasnippet lsp-java lsp-python-ms lsp-haskell helm-lsp lsp-treemacs dap-mode lsp-origami lsp-dart company flycheck lsp-pyright rust-mode php-mode scala-mode dart-mode clojure-mode typescript-mode csharp-mode haskell-mode) t) (pkg) (if (package-installed-p pkg) nil (package-install pkg)) (require pkg)) (lsp-mode lsp-ui yasnippet lsp-java lsp-python-ms lsp-haskell helm-lsp lsp-treemacs dap-mode lsp-origami lsp-dart company flycheck lsp-pyright rust-mode php-mode scala-mode dart-mode clojure-mode typescript-mode csharp-mode haskell-mode))
  (let* ((pkg-list '(lsp-mode lsp-ui yasnippet lsp-java lsp-python-ms lsp-haskell helm-lsp lsp-treemacs dap-mode lsp-origami lsp-dart company flycheck lsp-pyright rust-mode php-mode scala-mode dart-mode clojure-mode typescript-mode csharp-mode haskell-mode))) (package-initialize) (package-refresh-contents) (mapc #'(lambda (pkg) (if (package-installed-p pkg) nil (package-install pkg)) (require pkg)) pkg-list) (yas-global-mode) (add-hook 'prog-mode-hook 'lsp) (add-hook 'kill-emacs-hook (list 'lambda nil (cons 'delete-directory (cons package-user-dir '(t))))))
  eval-buffer(#<buffer  *load*> nil "/private/var/folders/bs/wqjbrbn948j78gb4303rjdcc00..." nil t)  ; Reading at buffer position 2311
  load-with-code-conversion("/private/var/folders/bs/wqjbrbn948j78gb4303rjdcc00..." "/private/var/folders/bs/wqjbrbn948j78gb4303rjdcc00..." nil t)
  load("/private/var/folders/bs/wqjbrbn948j78gb4303rjdcc00..." nil t)
  command-line-1(("-l" "/var/folders/bs/wqjbrbn948j78gb4303rjdcc0000gn/T/p..." "/src/..."))
  command-line()
  normal-top-level()
onsails commented 10 months ago

Had the same issue, manually setting lsp-inlay-hint-enable to t fixed this.