Skip to content

Commit

Permalink
feat: add alive support
Browse files Browse the repository at this point in the history
https://github.com/nobody-famous/alive

The corresponding VSCode configuration:

```json
{
    "telemetry.telemetryLevel": "off",
    "alive.lsp.startCommand": [
        "calm",
        "alive"
    ]
}
```
  • Loading branch information
VitoVan committed Jul 22, 2023
1 parent 3df68d6 commit 345ca82
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 24 deletions.
3 changes: 3 additions & 0 deletions build/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ build_fedora () {
./calm s dev fedora deps.sh && \
./calm s dev fedora sbcl.sh && \
./calm s dev all quicklisp.sh && \
./calm s dev all alive.sh && \
./calm s dev all copy-lib.sh && \
./calm s dev fedora config-lib.sh

Expand Down Expand Up @@ -42,6 +43,7 @@ build_darwin () {
./calm s dev darwin deps.sh && \
./calm s dev darwin sbcl.sh && \
./calm s dev all quicklisp.sh && \
./calm s dev all alive.sh && \
./calm s dev all copy-lib.sh && \
./calm s dev darwin config-lib.sh && \
./calm s dev darwin pack.sh && \
Expand All @@ -58,6 +60,7 @@ build_msys () {
./calm s dev msys deps.sh && \
./calm s dev msys sbcl.sh && \
./calm s dev all quicklisp.sh && \
./calm s dev all alive.sh && \
./calm s dev all copy-lib.sh && \
./calm s dev msys config-lib.sh

Expand Down
33 changes: 18 additions & 15 deletions entry.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,19 @@
(u:calm-log "building Linux AppImage...")
(u:load-from-calm "s/usr/linux/appimage.lisp")))

(cond
(alexandria:switch (*calm-env-calm-cmd* :test #'equal)

((string= *calm-env-calm-cmd* "test")
("test"
(u:calm-log-fancy "Nothing to test.")
(uiop:quit 0))

((string= *calm-env-calm-cmd* "show")
("alive"
(u:load-from-calm "s/dev/all/start-alive.lisp"))

("show"
(calm:calm-load-and-start))

((string= *calm-env-calm-cmd* "hello")
("hello"
(u:copy-file (merge-pathnames "s/usr/all/panic.lisp" *calm-env-calm-home*)
(merge-pathnames "canvas.lisp" *calm-env-app-dir*))
(ensure-directories-exist (merge-pathnames "assets/" *calm-env-app-dir*))
Expand All @@ -106,38 +109,38 @@
(merge-pathnames "fonts/fonts.conf" *calm-env-app-dir*))
(u:calm-log-fancy "Hello, sample files and directories created, please enjoy"))

((string= *calm-env-calm-cmd* "publish") (publish))
("publish" (publish))

((string= *calm-env-calm-cmd* "publish-web") (publish-web))
("publish-web" (publish-web))

((string= *calm-env-calm-cmd* "publish-with-options")
("publish-with-options"
(setf (uiop:getenv "CALM_ASK_ME") "yes-please")
(publish))

((string= *calm-env-calm-cmd* "publish-web-with-options")
("publish-web-with-options"
(setf (uiop:getenv "CALM_ASK_ME") "yes-please")
(publish-web))

;; rebuild calm.core
;; this could speed up your CALM command
#+sbcl
((string= *calm-env-calm-cmd* "core") (sb-ext:save-lisp-and-die (merge-pathnames *calm-env-calm-home* "calm.core")))
("core" (sb-ext:save-lisp-and-die (merge-pathnames *calm-env-calm-home* "calm.core")))

#+darwin
((string= *calm-env-calm-cmd* "make-bundle") (u:load-from-calm "s/usr/macos/bundle.lisp"))
("make-bundle" (u:load-from-calm "s/usr/macos/bundle.lisp"))
#+darwin
((string= *calm-env-calm-cmd* "make-dmg") (u:load-from-calm "s/usr/macos/dmg.lisp"))
("make-dmg" (u:load-from-calm "s/usr/macos/dmg.lisp"))

#+win32
((string= *calm-env-calm-cmd* "make-installer") (u:load-from-calm "s/usr/windows/installer.lisp"))
("make-installer" (u:load-from-calm "s/usr/windows/installer.lisp"))
#+win32
((string= *calm-env-calm-cmd* "set-icon") (u:load-from-calm "s/usr/windows/icon.lisp"))
("set-icon" (u:load-from-calm "s/usr/windows/icon.lisp"))

#+linux
((string= *calm-env-calm-cmd* "make-appimage") (u:load-from-calm "s/usr/linux/appimage.lisp"))
("make-appimage" (u:load-from-calm "s/usr/linux/appimage.lisp"))

#+sbcl
((string= *calm-env-calm-cmd* "dist") (dist #p"dist/"))
("dist" (dist #p"dist/"))

(t (format t "UNKOWN CALM_CMD: ~A~%" *calm-env-calm-cmd*)))

Expand Down
8 changes: 7 additions & 1 deletion s/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
ALl the scripts in this directory are only meant to be used by CALM Developers. Although the scripts in `usr` directory are prepared for the end-users, but the end-users shall not aware of their existence.
ALl the scripts in this directory are only meant to be called by CALM Developers. Although the scripts in `usr` directory are prepared for the end-users, but the end-users shall not aware of their existence.

All the scripts should NOT be executed directly, instead, use `calm` command, like this:

```bash
calm s usr macos init-msg.scpt
```

or

```bash
calm sbcl --load s/dev/all/start-alive.lisp
```

All the scripts are executed in the `CALM_HOME` directory,
with env `CALM_HOME` and `CALM_APP_DIR` provided,

Expand Down
5 changes: 5 additions & 0 deletions s/dev/all/alive.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
echo "Downloading alive-lsp ..."
if ! [ -d quicklisp/local-projects/alive-lsp ]; then
git clone --depth 1 --branch v0.2.0 https://github.com/nobody-famous/alive-lsp.git quicklisp/local-projects/alive-lsp
./calm sbcl --load ./s/dev/all/load-calm.lisp --load ./s/dev/all/install-alive.lisp
fi
2 changes: 2 additions & 0 deletions s/dev/all/install-alive.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
(ql:quickload :alive-lsp)
(quit)
3 changes: 3 additions & 0 deletions s/dev/all/load-calm.lisp
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
;; the existence of this file is to avoid the tricky shitty escaping of quotation marks
#-quicklisp
(load "./quicklisp/setup.lisp")
#-calm
(load "./calm.asd")
#-calm
(ql:quickload :calm)
3 changes: 3 additions & 0 deletions s/dev/all/start-alive.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(ql:quickload :alive-lsp)
(alive/server:start)
(eval (read))
29 changes: 22 additions & 7 deletions s/usr/all/panic.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,30 @@
(uiop:quit)))


;; DEBUGGING, please uncomment the correspoding line
;;
;; the swank server is for debugging, for usage please check
;; Emacs:
;; for Emacs - SLIME
;; https://slime.common-lisp.dev/
;; Visual Studio Code
;; https://lispcookbook.github.io/cl-cookbook/vscode-alive.html
;;
;; uncomment the following line to enable SWANK Server
;; (unless (str:starts-with? "dist" (uiop:getenv "CALM_CMD")) (swank:create-server))
;; (unless (str:starts-with? "dist" (uiop:getenv "CALM_CMD")) (swank:create-server :dont-close t))
;;
;; for LEM - micros
;; https://github.com/lem-project/micros
;;
;; (unless (str:starts-with? "dist" (uiop:getenv "CALM_CMD")) (micros:create-server :dont-close t))
;;
;; for Alive - Visual Studio Code
;; https://github.com/nobody-famous/alive
;; please config `alive.lsp.startCommand':
;;
;; {
;; "alive.lsp.startCommand": [
;; "calm",
;; "alive"
;; ]
;; }



;;
;; by default, the screensaver is disabled,
Expand All @@ -32,7 +47,7 @@
;; (setf (uiop:getenv "SDL_VIDEO_ALLOW_SCREENSAVER") "1")

;;
;; setting window properties, for more of this, please check
;; setting window properties, for others, please check
;; https://github.com/VitoVan/calm/blob/main/src/config.lisp
;;
(setf *calm-window-width* 600)
Expand Down
2 changes: 1 addition & 1 deletion src/calm.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* !!!! SHITTY CODE AHEAD !!!!
*
* I tried to replace Bash with C to get more compatibility
* on different OSes, but I suck at C programming.
* on different OSes, but iSuck@C.
* Now the bright side is that it worked,
* the dark side is that the code is worse than the Bash scripts.
*
Expand Down

0 comments on commit 345ca82

Please sign in to comment.