summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2026-06-25 14:15:58 +0100
committerjao <jao@gnu.org>2026-06-25 14:15:58 +0100
commite7a033d37898567915d41266daa903b3c48a11f5 (patch)
tree06fb2ab7b744275aa9c78a371062d5b35e0b8a35
parent2cc462d0c581c4cd677b48d721b40290c40dbbbe (diff)
downloadelibs-e7a033d37898567915d41266daa903b3c48a11f5.tar.gz
elibs-e7a033d37898567915d41266daa903b3c48a11f5.tar.bz2
python and rust tweaks
-rw-r--r--custom/jao-custom-programming.el29
-rw-r--r--lib/prog/jao-rust.el20
2 files changed, 37 insertions, 12 deletions
diff --git a/custom/jao-custom-programming.el b/custom/jao-custom-programming.el
index f591ce1..c58b3a9 100644
--- a/custom/jao-custom-programming.el
+++ b/custom/jao-custom-programming.el
@@ -64,13 +64,7 @@
eglot-autoshutdown t)
:config
(add-to-list 'eglot-server-programs
- `(rust-mode . ("rust-analyzer"
- :initializationOptions
- (:check (:command "check") ;; (:command "clippy")
- :procMacro
- (:enable t :ignored
- (:async-trait ["async-trait"]))
- ))))
+ '((python-base-mode :language-id "python") . ("ty" "server")))
;; :config (add-to-list 'eglot-stay-out-of 'flymake)
:hook (eglot-managed-mode . jao-eglot-managed-mode-hook)
:bind (:map eglot-mode-map (("C-h ." . jao-eldoc-toggle))))
@@ -309,6 +303,16 @@
(use-package rust-mode
:ensure t
:hook (rust-mode . jao-rust-mode-hook)
+ :init
+ (with-eval-after-load 'eglot
+ (add-to-list 'eglot-server-programs
+ `(rust-mode . ("rust-analyzer"
+ :initializationOptions
+ (:check (:command "clippy") ;; (:command "check")
+ :procMacro
+ (:enable t :ignored
+ (:async-trait ["async-trait"]))
+ :diagnostics (:disable ["unlinked-file"]))))))
:config
(setq rust-mode-treesitter-derive t)
(use-package smartparens-rust :demand t)
@@ -337,6 +341,7 @@
(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" . jao-rust-build-doc)
+ ("C-c t d" . jao-rust-test-doctests)
("C-c t g" . jao-rust-goto-tests)
("C-c t w" . jao-rust-test-workspace)
("C-c t m" . jao-rust-test-module)
@@ -613,6 +618,16 @@
;; (venv-initialize-eshell)
;; (jao-compilation-env "VIRTUAL_ENV"))
+(use-package uv-mode
+ :ensure t
+ :hook (python-mode . uv-mode-auto-activate-hook))
+
+(use-package python
+ :init
+ (setq-default eglot-workspace-configuration
+ '((:python . (:analysis (:typeCheckingMode "off")))))
+ :hook (python-base-mode . eglot-ensure))
+
;;;; Javascript
(use-package typescript-mode
diff --git a/lib/prog/jao-rust.el b/lib/prog/jao-rust.el
index 2281875..b2549ab 100644
--- a/lib/prog/jao-rust.el
+++ b/lib/prog/jao-rust.el
@@ -39,13 +39,14 @@
rel
(replace-regexp-in-string "^src\\(/bin\\)?/" "")
(string-replace "-" "_")
- (replace-regexp-in-string "/\\(mod\\|lib\\|main\\)$" "")
+ (replace-regexp-in-string "\\(^\\|/\\)\\(mod\\|lib\\|main\\)$" "")
(string-replace "/" "::")))))
(defun jao-rust--tests-prefix ()
- (if-let* ((m (jao-rust-current-module-name)))
- (concat m "::tests::")
- ""))
+ (let ((m (jao-rust-current-module-name)))
+ (cond ((not (stringp m)) "")
+ ((string-empty-p m) "tests::")
+ (t (concat m "::tests::")))))
(defconst jao-rust--test-header-rx
(concat "#\\[" (regexp-opt '("test" "quickcheck" "tokio::test") t)))
@@ -98,13 +99,22 @@
(interactive)
(let ((tests (jao-rust-buffer-tests)))
(if (seq-empty-p tests)
- (message "No tests in this module")
+ (when (y-or-n-p "No tests in this module. Run doc tests?")
+ (jao-rust-test-doctests))
(let* ((prefix (jao-rust--tests-prefix))
(tests (mapconcat (lambda (x) (format "%s%s" prefix x)) tests " "))
(rustic-test-arguments (format "-- --exact %s" tests))
(rustic-cargo-use-last-stored-arguments t))
(rustic-cargo-test)))))
+(defun jao-rust-test-doctests (&optional all)
+ (interactive "P")
+ (let* ((m (if all "" (jao-rust-current-module-name)))
+ (rustic-cargo-test-runner 'cargo)
+ (rustic-test-arguments (format "--doc %s" m))
+ (rustic-cargo-use-last-stored-arguments t))
+ (rustic-cargo-test)))
+
(defun jao-rust-retest ()
(interactive)
(let* ((rustic-test-arguments "-R latest")