Last active
May 7, 2024 15:44
-
-
Save jason-chandler/6332e3fd753fa87e3b1cd13582df5862 to your computer and use it in GitHub Desktop.
Basic .lem/init.lisp showing some ugly workarounds for getting cxxxr/valtan to work along with paredit and the monokai theme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(in-package :lem-user) | |
;; beautiful monokai | |
(define-color-theme "monokai" () | |
(:foreground "#eeeeee") | |
(:background "#262626") | |
(cursor :foreground "#262626" :background "#eeeeee") | |
(syntax-warning-attribute :foreground "#87005f" :background "#262626") | |
(syntax-string-attribute :foreground "#d7d787" :background "#262626") | |
(syntax-comment-attribute :foreground "#666666" :background "#262626") | |
(syntax-keyword-attribute :foreground "#5fd7ff" :background "#262626") | |
(syntax-constant-attribute :foreground "#5fd7ff" :background "#262626") | |
(syntax-function-name-attribute :foreground "#afd700" :background "#262626") | |
(syntax-variable-attribute :foreground nil :background "#262626") | |
(syntax-type-attribute :foreground nil :background "#262626") | |
(syntax-builtin-attribute :foreground nil :background "#262626")) | |
(load-theme "monokai") | |
;; use the ultralisp dist for quicklisp | |
(unless (member "ultralisp" (ql-dist:all-dists) | |
:key 'ql-dist:name | |
:test 'string=) | |
(ql-dist:install-dist "http://dist.ultralisp.org/" | |
:prompt nil)) | |
(define-file-type ("system") lem-lisp-mode:lisp-mode) | |
;; grab and load up individual pieces of valtan compiler | |
(progn | |
(dolist (valtan-lib '("valtan" "cl-source-map" "valtan/library/valtan-core" "lem/modes/lisp-mode" "valtan/lem")) | |
(let ((lib-path (concatenate 'string "~/.roswell/local-projects/cxxxr/" valtan-lib "/"))) | |
(push lib-path asdf:*central-registry*))) | |
(ql:quickload :valtan) | |
(ql:quickload :trivial-ws) | |
(dolist (lem-script '("remote-eval" "valtan-mode" "main")) | |
(let ((script-path (concatenate 'string "~/.roswell/local-projects/cxxxr/valtan/lem/" lem-script))) | |
(load script-path)))) | |
;; automatically load paredit when opening a lisp file | |
(defun pared-hook () | |
(lem-paredit-mode:paredit-mode t)) | |
(add-hook lem-lisp-mode:*lisp-mode-hook* #'pared-hook) | |
;; spin up a server and host the system in working directory as a valtan-compiled project | |
(define-command start-web-serve () () | |
(labels ((split-/ (path) (split-sequence:split-sequence "/" path :test #'string-equal :remove-empty-subseqs t)) | |
(concatenate-string (&rest seqs) (apply #'concatenate 'string seqs)) | |
(get-system (dir) (concatenate-string dir (car (last (split-/ dir))) ".system")) | |
(concatenate-/ (target) (concatenate-string target "/")) | |
(up-dir (path) (butlast (butlast path)))) | |
(let ((system-path (get-system (buffer-directory)))) | |
(loop :while (and (not (cl-fad:file-exists-p (pathname system-path))) (string-not-equal system-path ".system")) | |
:do (let ((next-path (apply #'concatenate-string (mapcar #'concatenate-/ (up-dir (split-/ system-path)))))) | |
(setf system-path (concatenate-string "/" (get-system next-path))))) | |
(valtan-host.build:build-application system-path :force nil) | |
(lem-valtan/remote-eval:start)))) | |
(define-command stop-web-serve () () | |
(lem-valtan/remote-eval:stop)) | |
(define-command web-serve-repl () () | |
(unwind-protect (lem-valtan/remote-eval:repl) | |
(lem-valtan/remote-eval:stop))) | |
(define-command valtan-paredit-mode () () | |
(lem-valtan.valtan-mode::valtan-mode)) | |
(define-command lisp-paredit-mode () () | |
(lem-lisp-mode:lisp-mode)) | |
(define-command valtan-save-file () () | |
(lem-core/commands/file:save-current-buffer) | |
(lem-valtan.valtan-mode::valtan-mode)) | |
;; add some keybinds i'm used to for paredit and valtan, shift + alt + f to slurp forward etc. | |
;; valtan-mode allows a SLIME-like connection to a running web-hosted lisp project | |
(defun define-keys-in-maps (&rest keymap-pairs) | |
(loop :for (keymap . new-key-list) :in keymap-pairs | |
:do (loop :for (key . action) :in new-key-list | |
:do (define-key keymap key action)))) | |
(defparameter *new-global-keys* | |
`(,lem:*global-keymap* . (("M-W" . lem-user::start-web-serve) | |
("M-R" . lem-user::web-serve-repl) | |
("M-Q" . lem-user::stop-web-serve) | |
("M-M" . lem-paredit-mode:paredit-mode) | |
("M-V" . lem-user::valtan-paredit-mode) | |
("M-L" . lem-user::lisp-paredit-mode)))) | |
(defparameter *new-paredit-keys* | |
`(,lem-paredit-mode:*paredit-mode-keymap* . (("M-F" . lem-paredit-mode:paredit-slurp) | |
("M-B" . lem-paredit-mode:paredit-barf)))) | |
(defparameter *new-valtan-mode-keys* | |
`(,lem-valtan.valtan-mode::*valtan-mode-keymap* . (("C-x C-s" . lem-user::valtan-save-file)))) | |
(define-keys-in-maps *new-global-keys* *new-paredit-keys*) | |
(define-keys-in-maps *new-global-keys* *new-valtan-mode-keys*) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks! That'd be a really big help.