summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--custom/jao-custom-mac.el3
-rw-r--r--custom/jao-custom-programming.el13
-rw-r--r--lib/prog/jao-rust.el23
3 files changed, 31 insertions, 8 deletions
diff --git a/custom/jao-custom-mac.el b/custom/jao-custom-mac.el
index a4d44a1..94879c6 100644
--- a/custom/jao-custom-mac.el
+++ b/custom/jao-custom-mac.el
@@ -21,5 +21,8 @@
(add-to-list 'Info-directory-list "/opt/homebrew/share/info")
+(setenv "CC" "clang")
+(setenv "CXX" "clang++")
+
(provide 'jao-custom-mac)
;;; jao-custom-mac.el ends here
diff --git a/custom/jao-custom-programming.el b/custom/jao-custom-programming.el
index 3f17c1a..cbc7d4f 100644
--- a/custom/jao-custom-programming.el
+++ b/custom/jao-custom-programming.el
@@ -308,11 +308,9 @@
(use-package rust-mode
:ensure t
- :demand t
:hook (rust-mode . jao-rust-mode-hook)
- :init
- (setq rust-mode-treesitter-derive nil)
:config
+ (setq rust-mode-treesitter-derive t)
(use-package smartparens-rust :demand t)
(defun jao-rust-mode-hook ()
@@ -329,20 +327,21 @@
(use-package rustic
:ensure t
- :demand t
- :init
+ :after (rust-mode)
+ :config
(setq rustic-format-on-save nil
rustic-lsp-client 'eglot) ;; 'lsp-mode 'eglot nil
- :config
(jao-define-attached-buffer '(major-mode . rustic-compilation-mode) 25)
:custom
(rustic-cargo-use-last-stored-arguments nil)
(rustic-analyzer-command '("rust-analyzer"))
(rustic-cargo-test-runner 'nextest)
(rustic-cargo-nextest-exec-command '("nextest" "run" "--color=never" "--show-progress=none"))
- :bind (:map rustic-mode-map (("C-c d" . rustic-cargo-build-doc)
+ :bind (:map rustic-mode-map (("C-c d" . jao-rust-build-doc)
+ ("C-c t g" . jao-rust-goto-tests)
("C-c t w" . jao-rust-test-workspace)
("C-c t m" . jao-rust-test-module)
+ ("C-c t r" . jao-rust-retest)
("C-c t t" . jao-rust-test-current))))
(use-package rust-playground
diff --git a/lib/prog/jao-rust.el b/lib/prog/jao-rust.el
index fdc6b0d..436de00 100644
--- a/lib/prog/jao-rust.el
+++ b/lib/prog/jao-rust.el
@@ -20,7 +20,8 @@
;;; Code:
-(defun jao-rust--root () (project-root (project-current)))
+(defun jao-rust--root ()
+ (locate-dominating-file default-directory "Cargo.toml"))
(defun jao-rust-open-cargo ()
(interactive)
@@ -54,6 +55,15 @@
(forward-line)
(jao-rust-test-at-point))))
+
+(defconst jao-rust--tests-mod-rx "^\\(pub\\)? *mod tests {")
+
+(defun jao-rust-goto-tests ()
+ (interactive)
+ (or (re-search-forward jao-rust--tests-mod-rx nil t)
+ (re-search-backward jao-rust--tests-mod-rx nil t)
+ (message "No tests module")))
+
(defun jao-rust-test-current ()
(interactive)
(if-let* ((m (jao-rust-current-module-name))
@@ -83,10 +93,21 @@
(rustic-cargo-use-last-stored-arguments t))
(rustic-cargo-test)))))
+(defun jao-rust-retest ()
+ (interactive)
+ (let* ((rustic-test-arguments "-R latest")
+ (rustic-cargo-use-last-stored-arguments t))
+ (rustic-cargo-test)))
+
(defun jao-rust-test-workspace ()
(interactive)
(let ((rustic-test-arguments rustic-default-test-arguments))
(rustic-cargo-test)))
+
+(defun jao-rust-build-doc (deps)
+ (interactive "P")
+ (rustic-run-cargo-command `(,(rustic-cargo-bin) "doc" ,@(unless deps '("--no-deps")))))
+
(provide 'jao-rust)
;;; jao-rust.el ends here