Skip to content

Commit 95efeb7

Browse files
committed
Fix issue with rust-analyzer and proc-macro imports
See rust-lang/rust-analyzer#6054
1 parent 017cce1 commit 95efeb7

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

init.el

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@
219219

220220
(use-package smartparens
221221
:ensure t
222+
:defer 1
222223
:init
223224
(defhydra smartparens-hydra ()
224225
"Smartparens"
@@ -315,13 +316,15 @@
315316
(python-mode . lsp)
316317
(go-mode . lsp)
317318
(terraform-mode . lsp)
319+
(rust-mode . lsp)
318320
(lsp-mode . lsp-enable-which-key-integration))
319321
:commands lsp
320322
:bind-keymap
321323
("C-c l" . lsp-command-map)
322324
:config
323325
(willsheu/lsp-pyls-setup)
324326
(willsheu/lsp-ts-ls-setup)
327+
(willsheu/lsp-rust-setup)
325328
(setq lsp-keymap-prefix "C-c l")
326329
)
327330

@@ -414,6 +417,13 @@
414417
:ensure
415418
:mode ("\\.\\(l\\|y\\)\\'"))
416419

420+
;; Rust
421+
(use-package rust-mode
422+
:ensure
423+
:mode ("\\.rs\\'")
424+
:config
425+
(setq rust-format-on-save t))
426+
417427
;; Python
418428
;; (defun willsheu/pipenv-pyls-location ()
419429
;; (message lsp--cur-workspace)
@@ -761,6 +771,9 @@
761771
'(lsp-prefer-flymake nil)
762772
'(lsp-pyls-server-command '("pyls_pipenv"))
763773
'(lsp-restart 'auto-restart)
774+
'(lsp-rust-analyzer-cargo-load-out-dirs-from-check t)
775+
'(lsp-rust-analyzer-proc-macro-enable t)
776+
'(lsp-rust-server 'rust-analyzer)
764777
'(lsp-ui-doc-enable nil)
765778
'(lsp-ui-peek-enable nil)
766779
'(lsp-ui-sideline-enable t)
@@ -771,7 +784,7 @@
771784
'(magit-refresh-verbose nil)
772785
'(org-export-backends '(ascii html icalendar latex md odt))
773786
'(package-selected-packages
774-
'(git-link company-box which-key pipenv lsp-origami origami lsp-ivy minions company-terraform terraform-mode winnow forge cmake-mode glsl-mode flymd ccls prettier-js tide ediprolog dockerfile-mode counsel-projectile ivy-hydra counsel jdee org company-go go-mode flycheck-elm material-theme hemisu-theme leuven-theme color-theme-sanityinc-tomorrow dired-details+ web-mode solarized-theme robe lua-mode list-processes+ js2-mode idle-highlight-mode icicles hydra highlight-indent-guides haml-mode geiser fuzzy-match flycheck facemenu+ exec-path-from-shell elpy column-marker auctex ag))
787+
'(rust-mode git-link company-box which-key pipenv lsp-origami origami lsp-ivy minions company-terraform terraform-mode winnow forge cmake-mode glsl-mode flymd ccls prettier-js tide ediprolog dockerfile-mode counsel-projectile ivy-hydra counsel jdee org company-go go-mode flycheck-elm material-theme hemisu-theme leuven-theme color-theme-sanityinc-tomorrow dired-details+ web-mode solarized-theme robe lua-mode list-processes+ js2-mode idle-highlight-mode icicles hydra highlight-indent-guides haml-mode geiser fuzzy-match flycheck facemenu+ exec-path-from-shell elpy column-marker auctex ag))
775788
'(prettier-js-show-errors 'echo)
776789
'(projectile-globally-ignored-directories
777790
'(".idea" ".ensime_cache" ".eunit" ".git" ".hg" ".fslckout" "_FOSSIL_" ".bzr" "_darcs" ".tox" ".svn" ".stack-work" "*.ccls-cache" ".ccls-cache"))

lisp/my-functions.el

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,5 +164,17 @@ current buffer's, reload dir-locals."
164164
:ignore-messages '("readFile .*? requested by TypeScript but content not available")
165165
:server-id 'ts-ls-2)))
166166

167+
(defun willsheu/lsp-modify-rust-init (base)
168+
"Modify init plist"
169+
(plist-put
170+
base :diagnostics
171+
(plist-put
172+
(plist-get base :diagnostics) :disabled
173+
["unresolved-import"])))
174+
175+
(defun willsheu/lsp-rust-setup ()
176+
"Do setup to customize rust-analyzer"
177+
(advice-add 'lsp-rust-analyzer--make-init-options :filter-return 'willsheu/lsp-modify-rust-init))
178+
167179
(provide 'my-functions)
168180
;;; my-functions.el ends here

0 commit comments

Comments
 (0)