tweak the rust/lsp setup

This commit is contained in:
Joe Ardent 2025-01-04 14:09:39 -08:00
parent 6cb14c05b8
commit 64e0ff2881
3 changed files with 58 additions and 49 deletions

View file

@ -880,7 +880,7 @@ Another section defines some complementary functionality
:default-family "Noto Sans Mono" :default-family "Noto Sans Mono"
:default-height 130) :default-height 130)
(regular (regular
:default-height 130) :default-height 150)
(medium (medium
:default-weight semilight :default-weight semilight
:default-height 170 :default-height 170
@ -902,7 +902,7 @@ Another section defines some complementary functionality
:default-weight regular :default-weight regular
:default-slant normal :default-slant normal
:default-width normal :default-width normal
:default-height 130 :default-height 150
:fixed-pitch-family nil ; falls back to :default-family :fixed-pitch-family nil ; falls back to :default-family
:fixed-pitch-weight nil ; falls back to :default-weight :fixed-pitch-weight nil ; falls back to :default-weight
@ -1521,10 +1521,6 @@ Open a nodal history graph in a new window to navigate all previous histories wi
:PROPERTIES: :PROPERTIES:
:ID: 01JGD1AZDG00072YN0C6Y1FFEG :ID: 01JGD1AZDG00072YN0C6Y1FFEG
:END: :END:
The [[https://github.com/emacsorphanage/key-chord][key-chord package]] lets you define multi-key inputs, including double-taps of single keys, that
map to emacs commands. I use it for common window operations, like splitting, deleting, or rotating
them; the other major chord I use is =BB= which switches buffers.
#+begin_src emacs-lisp :tangle "nebkor-modules/nebkor-essentials.el" #+begin_src emacs-lisp :tangle "nebkor-modules/nebkor-essentials.el"
(use-package key-chord (use-package key-chord
:ensure t :ensure t
@ -1545,6 +1541,10 @@ them; the other major chord I use is =BB= which switches buffers.
) )
#+end_src #+end_src
The [[https://github.com/emacsorphanage/key-chord][key-chord package]] lets you define multi-key inputs, including double-taps of single keys, that
map to emacs commands. I use it for common window operations, like splitting, deleting, or rotating
them; the other major chord I use is =BB= which switches buffers.
** The =nebkor-essentials= section for ~which-key~ ** The =nebkor-essentials= section for ~which-key~
:PROPERTIES: :PROPERTIES:
:ID: 01JGD1BCEX00019X4P0RCQXVQW :ID: 01JGD1BCEX00019X4P0RCQXVQW
@ -4961,17 +4961,11 @@ colors (you can use tree-sitter to do *syntactic* highlighting, but that's diffe
:bind (("C-c C-c Q" . lsp-workspace-shutdown) :bind (("C-c C-c Q" . lsp-workspace-shutdown)
("C-c C-c q" . lsp-workspace-restart)) ("C-c C-c q" . lsp-workspace-restart))
:config :config
(setq lsp-rust-all-targets nil (setq lsp-log-io nil
lsp-rust-analyzer-cargo-all-targets nil
lsp-log-io nil
lsp-semgrep-server-command nil lsp-semgrep-server-command nil
lsp-completion-provider :none lsp-completion-provider :none
lsp-inlay-hint-enable t lsp-inlay-hint-enable t
lsp-modeline-diagnostics-enable nil lsp-modeline-diagnostics-enable nil
lsp-rust-analyzer-import-merge-behaviour "full"
lsp-rust-analyzer-completion-auto-import-enable t
lsp-rust-rustfmt-path "/home/ardent/.cargo/bin/rustfmt"
lsp-rust-unstable-features t
lsp-semantic-tokens-enable t lsp-semantic-tokens-enable t
lsp-semantic-tokens-warn-on-missing-face nil lsp-semantic-tokens-warn-on-missing-face nil
lsp-treemacs-error-list-current-project-only t lsp-treemacs-error-list-current-project-only t
@ -4983,17 +4977,6 @@ colors (you can use tree-sitter to do *syntactic* highlighting, but that's diffe
lsp-eldoc-render-all t lsp-eldoc-render-all t
lsp-idle-delay 0.2 lsp-idle-delay 0.2
lsp-enable-snippet t lsp-enable-snippet t
;; enable / disable the hints as you prefer:
lsp-rust-analyzer-cargo-watch-command "clippy"
lsp-rust-analyzer-server-display-inlay-hints t
lsp-rust-analyzer-call-info-full t
lsp-rust-analyzer-proc-macro-enable t
lsp-rust-analyzer-display-lifetime-elision-hints-enable "skip_trivial"
lsp-rust-analyzer-display-chaining-hints t
lsp-rust-analyzer-display-lifetime-elision-hints-use-parameter-names t
lsp-rust-analyzer-display-closure-return-type-hints t
lsp-rust-analyzer-display-parameter-hints nil
lsp-rust-analyzer-display-reborrow-hints t
read-process-output-max (* 1024 1024)) read-process-output-max (* 1024 1024))
:hook :hook
( (
@ -5010,7 +4993,7 @@ colors (you can use tree-sitter to do *syntactic* highlighting, but that's diffe
:ID: 4cc12328-6cca-4c79-b9ca-fb07492ba890 :ID: 4cc12328-6cca-4c79-b9ca-fb07492ba890
:END: :END:
Rust is my primary development language. Rust is my primary development language; ~rustic~ is derived from ~rust-mode~.
#+begin_src emacs-lisp :tangle "nebkor-modules/nebkor-langs.el" #+begin_src emacs-lisp :tangle "nebkor-modules/nebkor-langs.el"
(use-package cargo (use-package cargo
@ -5025,8 +5008,6 @@ Rust is my primary development language.
("C-c C-c l" . flycheck-list-errors) ("C-c C-c l" . flycheck-list-errors)
("C-c C-c s" . lsp-rust-analyzer-status)) ("C-c C-c s" . lsp-rust-analyzer-status))
:hook rust-ts-mode :hook rust-ts-mode
:custom
(rustic-format-on-save t)
:config :config
(setq rustic-format-on-save t (setq rustic-format-on-save t
rust-indent-method-chain t rust-indent-method-chain t
@ -5037,6 +5018,32 @@ Rust is my primary development language.
(setq-local lsp-semantic-tokens-enable t)) (setq-local lsp-semantic-tokens-enable t))
#+end_src #+end_src
Most of the fancy IDE-like features are coming from rust-analyzer, and as I mentioned above in the
[[id:f6046c17-ff41-4474-8b50-94f652da3b13][LSP section]], I prefer to use ~lsp-mode~ as my LSP client. It has a lot of Rust-specific config.
#+begin_src emacs-lisp :tangle "nebkor-modules/nebkor-langs.el"
(use-package lsp-mode
:ensure nil
:defer t
:config
(setq lsp-rust-all-targets nil
lsp-rust-analyzer-cargo-all-targets nil
lsp-rust-analyzer-import-merge-behaviour "full"
lsp-rust-analyzer-completion-auto-import-enable t
lsp-rust-rustfmt-path "/home/ardent/.cargo/bin/rustfmt"
lsp-rust-unstable-features t
lsp-rust-analyzer-cargo-watch-command "clippy"
lsp-rust-analyzer-server-display-inlay-hints t
lsp-rust-analyzer-call-info-full t
lsp-rust-analyzer-proc-macro-enable t
lsp-rust-analyzer-display-lifetime-elision-hints-enable "skip_trivial"
lsp-rust-analyzer-display-chaining-hints t
lsp-rust-analyzer-display-lifetime-elision-hints-use-parameter-names t
lsp-rust-analyzer-display-closure-return-type-hints t
lsp-rust-analyzer-display-parameter-hints nil
lsp-rust-analyzer-display-reborrow-hints t))
#+end_src
** The =nebkor-langs.el= section for Python ** The =nebkor-langs.el= section for Python
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: h:EA5EA223-F97D-4EE9-8663-99822A037618 :CUSTOM_ID: h:EA5EA223-F97D-4EE9-8663-99822A037618

View file

@ -176,17 +176,11 @@
:bind (("C-c C-c Q" . lsp-workspace-shutdown) :bind (("C-c C-c Q" . lsp-workspace-shutdown)
("C-c C-c q" . lsp-workspace-restart)) ("C-c C-c q" . lsp-workspace-restart))
:config :config
(setq lsp-rust-all-targets nil (setq lsp-log-io nil
lsp-rust-analyzer-cargo-all-targets nil
lsp-log-io nil
lsp-semgrep-server-command nil lsp-semgrep-server-command nil
lsp-completion-provider :none lsp-completion-provider :none
lsp-inlay-hint-enable t lsp-inlay-hint-enable t
lsp-modeline-diagnostics-enable nil lsp-modeline-diagnostics-enable nil
lsp-rust-analyzer-import-merge-behaviour "full"
lsp-rust-analyzer-completion-auto-import-enable t
lsp-rust-rustfmt-path "/home/ardent/.cargo/bin/rustfmt"
lsp-rust-unstable-features t
lsp-semantic-tokens-enable t lsp-semantic-tokens-enable t
lsp-semantic-tokens-warn-on-missing-face nil lsp-semantic-tokens-warn-on-missing-face nil
lsp-treemacs-error-list-current-project-only t lsp-treemacs-error-list-current-project-only t
@ -198,17 +192,6 @@
lsp-eldoc-render-all t lsp-eldoc-render-all t
lsp-idle-delay 0.2 lsp-idle-delay 0.2
lsp-enable-snippet t lsp-enable-snippet t
;; enable / disable the hints as you prefer:
lsp-rust-analyzer-cargo-watch-command "clippy"
lsp-rust-analyzer-server-display-inlay-hints t
lsp-rust-analyzer-call-info-full t
lsp-rust-analyzer-proc-macro-enable t
lsp-rust-analyzer-display-lifetime-elision-hints-enable "skip_trivial"
lsp-rust-analyzer-display-chaining-hints t
lsp-rust-analyzer-display-lifetime-elision-hints-use-parameter-names t
lsp-rust-analyzer-display-closure-return-type-hints t
lsp-rust-analyzer-display-parameter-hints nil
lsp-rust-analyzer-display-reborrow-hints t
read-process-output-max (* 1024 1024)) read-process-output-max (* 1024 1024))
:hook :hook
( (
@ -230,8 +213,6 @@
("C-c C-c l" . flycheck-list-errors) ("C-c C-c l" . flycheck-list-errors)
("C-c C-c s" . lsp-rust-analyzer-status)) ("C-c C-c s" . lsp-rust-analyzer-status))
:hook rust-ts-mode :hook rust-ts-mode
:custom
(rustic-format-on-save t)
:config :config
(setq rustic-format-on-save t (setq rustic-format-on-save t
rust-indent-method-chain t rust-indent-method-chain t
@ -241,6 +222,27 @@
(setq-local buffer-save-without-query t) (setq-local buffer-save-without-query t)
(setq-local lsp-semantic-tokens-enable t)) (setq-local lsp-semantic-tokens-enable t))
(use-package lsp-mode
:ensure nil
:defer t
:config
(setq lsp-rust-all-targets nil
lsp-rust-analyzer-cargo-all-targets nil
lsp-rust-analyzer-import-merge-behaviour "full"
lsp-rust-analyzer-completion-auto-import-enable t
lsp-rust-rustfmt-path "/home/ardent/.cargo/bin/rustfmt"
lsp-rust-unstable-features t
lsp-rust-analyzer-cargo-watch-command "clippy"
lsp-rust-analyzer-server-display-inlay-hints t
lsp-rust-analyzer-call-info-full t
lsp-rust-analyzer-proc-macro-enable t
lsp-rust-analyzer-display-lifetime-elision-hints-enable "skip_trivial"
lsp-rust-analyzer-display-chaining-hints t
lsp-rust-analyzer-display-lifetime-elision-hints-use-parameter-names t
lsp-rust-analyzer-display-closure-return-type-hints t
lsp-rust-analyzer-display-parameter-hints nil
lsp-rust-analyzer-display-reborrow-hints t))
;;;; Configuration for Python Programming ;;;; Configuration for Python Programming
(use-package python (use-package python

View file

@ -104,7 +104,7 @@
:default-family "Noto Sans Mono" :default-family "Noto Sans Mono"
:default-height 130) :default-height 130)
(regular (regular
:default-height 130) :default-height 150)
(medium (medium
:default-weight semilight :default-weight semilight
:default-height 170 :default-height 170
@ -126,7 +126,7 @@
:default-weight regular :default-weight regular
:default-slant normal :default-slant normal
:default-width normal :default-width normal
:default-height 130 :default-height 150
:fixed-pitch-family nil ; falls back to :default-family :fixed-pitch-family nil ; falls back to :default-family
:fixed-pitch-weight nil ; falls back to :default-weight :fixed-pitch-weight nil ; falls back to :default-weight