/ .dir-locals.el
.dir-locals.el
  1  ;; [[file:CONTRIBUTING.org::*microvisor.el (\[\[https:/github.com/mohkale/compile-multi\]\[compile-multi\]\] + \[\[https:/github.com/rejeep/prodigy.el\]\[prodigy\]\])][microvisor.el ([[https://github.com/mohkale/compile-multi][compile-multi]] + [[https://github.com/rejeep/prodigy.el][prodigy]]):1]]
  2  ;; Copyright (C) 2022-2025 Free Software Foundation, Inc.
  3  
  4  ;; This file is not part of GNU Emacs.
  5  
  6  ;; This program is free software: you can redistribute it and/or modify
  7  ;; it under the terms of the GNU General Public License as published by
  8  ;; the Free Software Foundation, either version 3 of the License, or
  9  ;; (at your option) any later version.
 10  
 11  ;; This program is distributed in the hope that it will be useful,
 12  ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
 13  ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 14  ;; GNU General Public License for more details.
 15  
 16  ;; You should have received a copy of the GNU General Public License
 17  ;; along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.
 18  
 19  ((nil .
 20        ((compile-multi-annotate-cmds . t)
 21         (compile-multi-annotate-limit . 10)
 22         (compile-multi-annotate-string-cmds . nil)
 23         (compile-multi-group-cmds . group-and-replace)
 24         ;; ================================================================================================================================================================== ;;
 25         (compile-multi-dir-local-config
 26          . ((t
 27              ;; ======================================|=======|===============================================|=========|===========================|===========|============ ;;
 28              ("󱄅 microvisor :󰔡 activate"           :command "nix run .#activate"                                                                 :annotation "       nix ")
 29              ;; ======================================|=======|===============================================|=========|===========================|===========|============ ;;
 30              ("󱄅 microvisor :󰋽 info"               :command "devenv info"                                  :prodigy t                            :annotation "    devenv 󱄅")
 31              ("󱄅 microvisor :󰇺 tasks"              :command "devenv tasks list"                            :prodigy t                            :annotation "    devenv 󱄅")
 32              ("󱄅 microvisor :󰚦 down"               :command "devenv processes down"                        :prodigy t                            :annotation "    devenv 󱄅")
 33              ("󱄅 microvisor : sqld"               :command "devenv up sqld"                               :prodigy t :port 8080                 :annotation "    devenv 󱄅")
 34              ("󱄅 microvisor : caddy"              :command "devenv up caddy"                              :prodigy t :port   80                 :annotation "    devenv 󱄅")
 35              ("󱄅 microvisor :󰇮 mailpit"            :command "devenv up mailpit"                            :prodigy t :port 8025                 :annotation "    devenv 󱄅")
 36              ("󱄅 microvisor : postgres"           :command "devenv up postgres"                           :prodigy t :port 5432                 :annotation "    devenv 󱄅")
 37              ("󱄅 microvisor : tailscale"          :command "devenv up tailscale"                          :prodigy t :port 8080                 :annotation "    devenv 󱄅")
 38              ("󱄅 microvisor : prometheus"         :command "devenv up prometheus"                         :prodigy t :port 9090                 :annotation "    devenv 󱄅")
 39              ;; ======================================|=======|===============================================|=========|===========================|===========|============ ;;
 40              (" loco : start"                    :command "cargo loco start"                             :prodigy t :port 5150                 :annotation "     cargo ")
 41              (" loco : db"                       :command "cargo loco db"                                :prodigy t                            :annotation "     cargo ")
 42              (" loco :󱤟 db:status"                :command "cargo loco db status"                         :prodigy t                            :annotation "     cargo ")
 43              (" loco :󱘽 db:migrate:up"            :command "cargo loco db migrate up"                     :prodigy t                            :annotation "     cargo ")
 44              (" loco :󱘼 db:migrate:down"          :command "cargo loco db migrate up"                     :prodigy t                            :annotation "     cargo ")
 45              (" loco :󰆺 db:seed"                  :command "cargo loco db seed"                           :prodigy t                            :annotation "     cargo ")
 46              (" loco :󰑪 routes"                   :command "cargo loco routes"                            :prodigy t                            :annotation "     cargo ")
 47              (" loco :󰣖 jobs"                     :command "cargo loco jobs"                              :prodigy t                            :annotation "     cargo ")
 48              (" loco : doctor"                   :command "cargo loco doctor"                            :prodigy t                            :annotation "     cargo ")
 49              ;; ======================================|=======|===============================================|=========|===========================|===========|============ ;;
 50              ;; ======================================|=======|===============================================|=========|===========================|===========|============ ;;
 51              ;; ======================================|=======|===============================================|=========|===========================|===========|============ ;;
 52              ("󱄅 microvisor : openbsd:upgrade"    :command "doas pkg_add -u                  "                                                  :annotation "   pkg_add ")
 53              ("󱄅 microvisor :󰣠 freebsd:upgrade"    :command "sudo pkg update && pkg upgrade -y"                                                  :annotation "       pkg 󰣠")
 54              ("󱄅 microvisor : darwin:switch"      :command "darwin-rebuild switch --flake .  "                                                  :annotation "       nix ")
 55              ("󱄅 microvisor :󰘳 darwin:rebuild"     :command "darwin-rebuild build  --flake .  "                                                  :annotation "       nix ")
 56              ("󱄅 microvisor : guix:pull"          :command "guix pull                        "                                                  :annotation "      guix ")
 57              ("󱄅 microvisor : nixos:rebuild"      :command "nixos-rebuild  build  --flake .  "                                                  :annotation "       nix ")
 58              ;; ======================================|=======|================================================|=========|==========================|===========|============ ;;
 59              ;; ======================================|=======|================================================|=========|==========================|===========|============ ;;
 60              ("󱄅 microvisor : arch:upgrade"       :command "sudo pacman -Syu                 "                                                  :annotation "    pacman ")
 61              ("󱄅 microvisor : debian:upgrade"     :command "sudo apt update && sudo apt upgrade -y"                                             :annotation "       apt ")
 62              ;; ======================================|=======|================================================|=========|==========================|===========|============ ;;
 63              ;; ======================================|=======|================================================|=========|==========================|===========|============ ;;
 64              ;; ======================================|=======|================================================|=========|==========================|===========|============ ;;
 65              ("󰕮 microtop 󰕮:󰐊 run"                  :command "cargo r -rp microtop"                          :prodigy t                           :annotation "     cargo ")
 66              ("󰕮 microtop 󰕮:󰳽 serve"                :command "trunk serve --config apps/microtop/Trunk.toml" :prodigy t :port 8080                :annotation "     cargo ")
 67              ;; ======================================|=======|================================================|=========|=================================================== ;;
 68              ;; ======================================|=======|================================================|=========|=================================================== ;;
 69              ("󰦉 web 󰦉:󰳽 serve"                     :command "dx serve -p web"                               :prodigy t                           :annotation "    dioxus ")
 70              ("󰦉 web 󰦉:󰟀 serve:desktop"             :command "dx serve -p web"                               :prodigy t                           :annotation "    dioxus ")
 71              ("󰦉 web 󰦉: serve:ssg"                 :command "dx serve -rp web --ssg"                        :prodigy t :port 8080                :annotation "    dioxus ")
 72              ("󰦉 web 󰦉:󰡢 build"                     :command "dx build -p web"                               :prodigy t                           :annotation "    dioxus ")
 73              ;; ======================================|=======|================================================|=========|==========================|===========|============ ;;
 74              ;; ======================================|=======|================================================|=========|==========================|===========|============ ;;
 75              (" tui :󰐊 run"                       :command "cargo r -rp tui"                               :prodigy t                           :annotation "     cargo ")
 76              (" tui :󰍹 run:simulate"              :command "cargo r -rp tui --bin simulator"               :prodigy t                           :annotation "     cargo ")
 77              (" tui :󰇉 run:simulate(min) "        :command "cargo r -rp tui --bin simulator-minimal"       :prodigy t                           :annotation "     cargo ")
 78              (" tui :󰳽 serve"                     :command "trunk serve"                                   :prodigy t :port 8080                :annotation "     cargo ")
 79              ;; ======================================|=======|================================================|=========|==========================|===========|============ ;;
 80              ;; ======================================|=======|================================================|=========|==========================|===========|============ ;;
 81              ;; ======================================|=======|================================================|=========|==========================|===========|============ ;;
 82              (" ESP32 :󰐊 run"                     :command "cargo +esp rr"                                                                      :annotation "cargo +esp ")
 83              ;; ======================================|=======|=====================================================================================|===========|============ ;;
 84              ;; ======================================|=======|=====================================================================================|===========|============ ;;
 85  
 86              (" ESP32S3 :󰐊 build"                 :command "cargo +esp bb -r"                                                                   :annotation "cargo +esp ")
 87              (" ESP32S3 :󱈝 build:partition"       :command "cargo espflash partition-table boards/esp32s3.partitions.csv"                       :annotation "cargo +esp ")
 88  
 89              (" ESP32S3 :󰔰 flash"                 :command "cargo +esp flash --target xtensa-esp32s3-none-elf"                                  :annotation "cargo +esp ")
 90              (" ESP32S3 : upload"                :command "cargo loco t upload"                                                                :annotation "cargo +esp ")
 91              (" ESP32S3 : debug"                 :command "espflash partition-table firmware/machine/esp32s3.partitions.csv; cargo +esp rr"     :annotation "cargo +esp ")
 92              (" ESP32S3 :󰭎 monitor"               :command "probe-rs run"                                  :prodigy nil                         :annotation "cargo +esp ")
 93  
 94              (" ESP32S3 :󱈫 test"                  :command "cargo +esp tt                     "                                                 :annotation "cargo +esp ")
 95              (" ESP32S3 :󱠡 test:hello"            :command "cargo +esp tt --test hello        "                                                 :annotation "cargo +esp ")
 96              (" ESP32S3 :󰋊 test:spi"              :command "cargo +esp tt --test spi          "                                                 :annotation "cargo +esp ")
 97              (" ESP32S3 : test:sd"               :command "cargo +esp tt --test sd           "                                                 :annotation "cargo +esp ")
 98              (" ESP32S3 :󰹤 test:ota"              :command "cargo +esp tt --test ota          "                                                 :annotation "cargo +esp ")
 99              (" ESP32S3 : test:i2c"              :command "cargo +esp tt --test i2c          "                                                 :annotation "cargo +esp ")
100              (" ESP32S3 :󰒪 test:sntp"             :command "cargo +esp tt --test sntp         "                                                 :annotation "cargo +esp ")
101              (" ESP32S3 :󰜤 test:scd30"            :command "cargo +esp tt --test scd30        "                                                 :annotation "cargo +esp ")
102              (" ESP32S3 :󰟤 test:scd4x"            :command "cargo +esp tt --test scd4x        "                                                 :annotation "cargo +esp ")
103              (" ESP32S3 : e2e:system"            :command "cargo +esp tt --test system       "                                                 :annotation "cargo +esp ")
104              (" ESP32S3 : test:ds3231"           :command "cargo +esp tt --test ds3231       "                                                 :annotation "cargo +esp ")
105              (" ESP32S3 :󱡬 example:gpio"          :command "cargo +esp rr --example gpio      "                                                 :annotation "cargo +esp ")
106              (" ESP32S3 :󱂛 test:http_api"         :command "cargo +esp tt --test http_api     "                                                 :annotation "cargo +esp ")
107              (" ESP32S3 : test:filesystem"       :command "cargo +esp tt --test filesystem   "                                                 :annotation "cargo +esp ")
108              (" ESP32S3 : test:ntc_formula"      :command "cargo +esp tt --test ntc_formula  "                                                 :annotation "cargo +esp ")
109              (" ESP32S3 :󰈘 test:sd_card_webpage"  :command "cargo +esp tt --test sd_card_webpage"                                               :annotation "cargo +esp ")
110              ;; (" ESP32S3 : example:mdns"          :command "cargo +esp rr --example mdns_responder"                                             :annotation "cargo +esp ")
111              (" ESP32S3 :󰒲 example:deep_sleep"    :command "cargo +esp rr --example deep_sleep"                                                 :annotation "cargo +esp ")
112              (" ESP32S3 :󰒲 example:defmt-tcp"     :command "cargo +esp rr --example defmt-tcp "                                                 :annotation "cargo +esp ")
113              (" ESP32S3 :󰐊 pio run"               :command "pio run                           "                                                 :annotation "platformio ")
114              (" ESP32S3 : pio test"              :command "pio test                          "                                                 :annotation "platformio ")
115              (" ESP32S3 :󰞏 pio test --without"    :command "pio test --without-building --without-uploading"                                    :annotation "platformio ")
116              (" ESP32S3 :󰔰 pio run -t upload"     :command "pio run -t upload                 "                                                 :annotation "platformio ")
117              (" ESP32S3 : pio run -t compiledb"  :command "pio run -t compiledb              "                                                 :annotation "platformio ")
118              (" ESP32S3 : pio run -t uploadfs"   :command "pio run -t uploadfs               "                                                 :annotation "platformio ")
119              (" ESP32S3 :󰭎 pio device monitor"    :command "pio device monitor                "                                                 :annotation "platformio ")
120              ;; ======================================|=======|============================================================================================================== ;;
121              ;; ======================================|=======|============================================================================================================== ;;
122              ;; ======================================|=======|============================================================================================================== ;;
123              ("󰚗 STM32H723ZG 󰚗:󰔰 flash"             :command "cargo r -r    --bin stm32h723zg                    --target thumbv7em-none-eabihf"  :annotation "     cargo ")
124              ("󰚗 STM32H723ZG 󰚗: debug"             :command "cargo r       --bin stm32h723zg                    --target thumbv7em-none-eabihf"  :annotation "     cargo ")
125              ;; ======================================|=======|============================================================================================================== ;;
126              )))
127         ;; ===========================================|=======|============================================================================================================== ;;
128         (eval . (progn
129                   (require 'seq) (require 'cl-lib) (require 'subr-x) (require 'prodigy) (require 'compile-multi) (require 'nerd-icons nil t)
130                   ;; ========================================================================================================================================================= ;;
131                   (defun my/compile-multi-local-annotation (original-function task)
132                     (if-let* ((annotation_text (plist-get (cdr task) :annotation)) ((stringp annotation_text)) ((fboundp 'nerd-icons-icon-for-file))
133                               (annotation_words (split-string (string-trim-right annotation_text) "[[:space:]]+" t))
134                               (icon_file_name (alist-get (car annotation_words) '(("cargo" . "Cargo.toml") ("nix" . "flake.nix") ("devenv" . "flake.nix")) nil nil #'string=)))
135                         (let* ((annotation_base (string-join (if (> (length annotation_words) 1) (butlast annotation_words) annotation_words) " "))
136                                (annotation_text_truncated (if (and compile-multi-annotate-limit (> (length annotation_base) compile-multi-annotate-limit))
137                                                               (concat (truncate-string-to-width annotation_base compile-multi-annotate-limit) "…") annotation_base))
138                                (annotation_rendered (concat (propertize annotation_text_truncated 'face 'completions-annotations) " " (nerd-icons-icon-for-file icon_file_name)))
139                                (annotation_width (string-width (substring-no-properties annotation_rendered))))
140                           (concat " " (propertize " " 'display `(space :align-to (- right ,(+ 1 annotation_width)))) annotation_rendered))
141                       (funcall original-function task))) ;; end defun my/compile-multi-local-annotation
142                   ;; ========================================================================================================================================================= ;;
143                   (unless (advice-member-p #'my/compile-multi-local-annotation #'compile-multi--annotation-function)
144                     (advice-add 'compile-multi--annotation-function :around #'my/compile-multi-local-annotation)) ;; end unless
145                   (defun my/compile-multi-running-prodigy-face (original-function tasks)
146                     (mapcar
147                      (lambda (task)
148                        (let* ((title (car task))
149                               (plist (cdr task))
150                               (plain-title (substring-no-properties title))
151                               (service (and (plist-get plist :prodigy) (prodigy-find-service plain-title))))
152                          (if (and service (prodigy-service-started-p service))
153                              (let ((title* (copy-sequence title))) (add-face-text-property 0 (length title*) 'prodigy-green-face t title*) (cons title* plist))
154                            task)))
155                      (funcall original-function tasks)))
156  
157                   (unless (advice-member-p #'my/compile-multi-running-prodigy-face #'compile-multi--add-properties)
158                     (advice-add 'compile-multi--add-properties :around #'my/compile-multi-running-prodigy-face))
159                   ;; ========================================================================================================================================================= ;;
160                   (dolist (task (seq-filter (lambda (task) (plist-get (cdr task) :prodigy)) (thread-first (compile-multi--config-tasks) (compile-multi--fill-tasks) (compile-multi--add-properties))))
161  
162                     (let* ((title        (car task))
163                            (plist        (cdr task))
164                            (port         (plist-get plist :port))
165                            (plain-title  (substring-no-properties title))
166                            (command      (or (get-text-property 0 'compile-multi--task title) (plist-get plist :command)))
167                            (group-label  (or (get-text-property 0 'consult--type title) (if (string-match "\\`\\([^:]+\\):\\(.*\\)\\'" plain-title) (string-trim (match-string 1 plain-title)) plain-title)))
168                            (display-name (if (string-match "\\`\\([^:]+\\):\\(.*\\)\\'" plain-title) (string-trim (match-string 2 plain-title)) plain-title)))
169  
170                       (apply #'prodigy-define-service
171                              (append
172                               (list
173                                :stop-signal                 'kill
174                                :name                        plain-title
175                                :display-name                display-name
176                                :group-label                 (format "%s" group-label)
177                                :kill-process-buffer-on-stop 'unless-visible
178                                :command                     shell-file-name
179                                :cwd                         (projectile-project-root)
180                                :args                        (list shell-command-switch command))
181                               (when port                    (list :port port))))))
182                   ;; ========================================================================================================================================================= ;;
183                   ;; (add-to-list
184                   ;;  'dape-configs
185                   ;;  '(probe-rs
186                   ;;    :chip "esp32s3" :request "launch" :type "probe-rs-debug" :consoleLogLevel "Console" :flashingConfig (:flashingEnabled t)
187  
188                   ;;    port :autoport host "localhost" command "probe-rs"
189                   ;;    modes (rust-mode rustic-mode)
190                   ;;    compile "cargo +esp b -p firmware  --example gpio --target xtensa-esp32s3-none-elf"
191                   ;;    command-args ("dap-server" "--port" ":autoport")
192                   ;;    command-cwd (lambda () (project-root (project-current)))
193                   ;;    :fn (lambda (config) (if (derived-mode-p 'dape-repl-mode) config (plist-put config 'compile nil)))
194                   ;;    :coreConfigs [(
195                   ;;                   :coreIndex 0
196                   ;;                   :rttEnabled t
197                   ;;                   :rttChannelFormats [(:channelNumber 0 :showTimestamps t :dataFormat "String")]
198                   ;;                   :svdFile (lambda () (let ((f (expand-file-name "boards/esp32s3.svd" (project-root (project-current)))))
199                   ;;                                         (unless (file-exists-p f) (error "Missing SVD file: %s" f)) f))
200                   ;;                   :programBinary (lambda () (expand-file-name "target/xtensa-esp32s3-none-elf/debug/examples/gpio" (project-root (project-current))))
201                   ;;                   )]
202                   ;;    ))
203                   ;; ========================================================================================================================================================= ;;
204                   )) ;; end eval
205         )))
206  ;; microvisor.el ([[https://github.com/mohkale/compile-multi][compile-multi]] + [[https://github.com/rejeep/prodigy.el][prodigy]]):1 ends here