diff options
| -rw-r--r-- | custom/jao-custom-mac.el | 3 | ||||
| -rw-r--r-- | custom/jao-custom-programming.el | 15 | ||||
| -rw-r--r-- | init.el | 30 | ||||
| -rw-r--r-- | lib/doc/jao-org-focus.el | 47 | ||||
| -rw-r--r-- | lib/prog/jao-rust.el | 54 |
5 files changed, 119 insertions, 30 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 6106e9a..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,21 +327,22 @@ (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 t" . rustic-cargo-current-test)))) + ("C-c t r" . jao-rust-retest) + ("C-c t t" . jao-rust-test-current)))) (use-package rust-playground :ensure t) @@ -456,6 +456,16 @@ (jao-themes-setup) ;;; Help system +;;;; which-key +(use-package which-key + :custom + (which-key-add-column-padding 2) + (which-key-lighter "") + (which-key-idle-delay 10000) + (which-key-idle-secondary-delay 0.05) + (which-key-show-early-on-C-h t) + :hook (after-init . which-key-mode)) + ;;;; help buffers (setq help-window-select t help-window-keep-selected nil @@ -1120,7 +1130,10 @@ (use-package spatial-window :ensure t - :bind ("M-o" . spatial-window-select)) + :bind + ("M-o" . spatial-window-select) + ("C-x o" . spatial-window-select) + ("C-x p" . spatial-window-select)) ;;;; transposing windows (defun transpose-windows (arg) @@ -1312,8 +1325,13 @@ ;; used by markdown mode to edit code blocks (use-package edit-indirect :ensure t) -(dolist (ext '("\\.md$" "\\.markdown$")) - (add-to-list 'auto-mode-alist (cons ext 'markdown-mode))) +;; (dolist (ext '("\\.md$" "\\.markdown$")) +;; (add-to-list 'auto-mode-alist (cons ext 'markdown-mode))) + +(use-package md-ts-mode + :ensure t) + +(md-ts-mode-enable-global) ;;;; TeX and LaTex (use-package tex-site @@ -1627,6 +1645,7 @@ magit-push-always-verify nil magit-save-repository-buffers 'dontask magit-section-visibility-indicators '(("…" . t)) + magit-show-long-lines-warning nil magit-status-buffer-switch-function 'switch-to-buffer magit-status-show-hashes-in-headers t)) @@ -1665,7 +1684,10 @@ ;;;; toml (use-package eldoc-toml :ensure t) (use-package toml-ts-mode - :config (add-to-list 'auto-mode-alist '("`.*\\.toml" . toml-ts-mode))) + :config + (add-to-list 'auto-mode-alist '("`.*\\.toml" . toml-ts-mode)) + (add-hook 'toml-ts-mode-hook 'turn-off-auto-fill)) + ;;;; protobuf (use-package protobuf-mode :ensure t) diff --git a/lib/doc/jao-org-focus.el b/lib/doc/jao-org-focus.el index a135ff5..2383cfc 100644 --- a/lib/doc/jao-org-focus.el +++ b/lib/doc/jao-org-focus.el @@ -24,20 +24,40 @@ (defvar-local jao-org-focus--parent nil) (defvar-local jao-org-focus--section nil) +(defvar jao-org-focus-siblings '("escaleta.org" . "novela.org")) + +(defun jao-org-focus--header-title () + (when-let* ((elem (org-element-at-point)) + (header (if (eq 'headline (org-element-type elem)) + elem + (org-previous-visible-heading 1) + (org-element-at-point)))) + (org-element-property :title header))) + +(defun jao-org-focus--is-outline () + (string= (car jao-org-focus-siblings) + (file-name-nondirectory (or (buffer-file-name) "")))) + +(defun jao-org-focus-jump-to-sibling () + (interactive) + (when-let* ((title (save-excursion (jao-org-focus--header-title))) + (file (if (jao-org-focus--is-outline) + (cdr jao-org-focus-siblings) + (car jao-org-focus-siblings))) + (link (format "[[./%s::*%s]]" file title))) + (org-link-open-from-string link))) + ;;; focus on subtree (defun jao-org-focus () "Pop creatingly to an indirect buffer focused on the encloing subtree. When invoked on an indirect buffer, pops back to its base." (interactive) + (when (jao-org-focus--is-outline) + (jao-org-focus-jump-to-sibling)) (if-let* ((b (get-buffer (or jao-org-focus--parent "")))) (pop-to-buffer b) - (when-let* ((elem (org-element-at-point)) - (header (if (eq 'headline (org-element-type elem)) - elem - (org-previous-visible-heading 1) - (org-element-at-point))) - (title (org-element-property :title header)) + (when-let* ((title (jao-org-focus--header-title)) (parent (buffer-name)) (bname (format "%s [%s]" title parent))) (if-let* ((b (get-buffer bname))) @@ -119,17 +139,18 @@ With arg, offer to switch to all children, regardless of their parent." (defvar jao-org-focus-consult-buffer-source `(:name "Focus buffers" - :category jao-org-focus-buffers - :action switch-to-buffer - :hidden t - :narrow ,(cons ?o "focus") - :history jao-org-focus--focused-history - :items ,(lambda () (mapcar 'buffer-name (jao-org-focus-list t))))) + :category jao-org-focus-buffers + :action switch-to-buffer + :hidden t + :narrow ,(cons ?o "focus") + :history jao-org-focus--focused-history + :items ,(lambda () (mapcar 'buffer-name (jao-org-focus-list t))))) (define-minor-mode org-focus-mode "A mode where keeping track of focused children is on by default." :lighter " ◎" - :keymap '(("\C-cl" . jao-org-focus-switch) + :keymap '(("\C-ce" . jao-org-focus-jump-to-sibling) + ("\C-cl" . jao-org-focus-switch) ("\C-cR" . jao-org-focus-redisplay) ("\C-co" . jao-org-focus) ("\C-cw" . count-words) diff --git a/lib/prog/jao-rust.el b/lib/prog/jao-rust.el index 9c08e9b..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) @@ -40,14 +41,45 @@ (replace-regexp-in-string "/\\(mod\\|lib\\|main\\)$" "") (string-replace "/" "::")))) +(defconst jao-rust--test-header-rx + (concat "#\\[" (regexp-opt '("test" "quickcheck" "tokio::test") t))) + +(defconst jao-rust--test-name-rx "^ *\\(pub\\)?\\( async\\)? fn \\([^(]+\\)(") + +(defun jao-rust-test-at-point () + (when (looking-at jao-rust--test-name-rx) (match-string-no-properties 3))) + +(defun jao-rust-test-before-point () + (save-excursion + (when (re-search-backward jao-rust--test-header-rx nil t) + (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)) + (n (jao-rust-test-before-point))) + (let ((rustic-test-arguments (format "-- --exact %s::tests::%s" m n)) + (rustic-cargo-use-last-stored-arguments t)) + (rustic-cargo-test)) + (message "No test before point"))) + (defun jao-rust-buffer-tests () (save-excursion (goto-char (point-min)) (let ((res '())) - (while (re-search-forward "#\\[\\(tokio::test\\|test\\|quickcheck\\)" nil t) + (while (re-search-forward jao-rust--test-header-rx nil t) (forward-line) - (when (looking-at "^ *\\(pub\\)?\\( async\\)? fn \\([^(]+\\)(") - (push (match-string-no-properties 3) res))) + (when-let* ((name (jao-rust-test-at-point))) (push name res))) res))) (defun jao-rust-test-module () @@ -57,13 +89,25 @@ (messages "No tests in this module") (let* ((mod (jao-rust-current-module-name)) (tests (mapconcat (lambda (x) (format "%s::tests::%s" mod x)) tests " ")) - (rustic-test-arguments (format "-- --exact %s" tests))) + (rustic-test-arguments (format "-- --exact %s" tests)) + (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 |
