Skip to content

Commit

Permalink
Merge branch 'main' into add-lem-extesion-to-main
Browse files Browse the repository at this point in the history
  • Loading branch information
Sasanidas committed Nov 11, 2024
2 parents 6b3d172 + 5c72ad8 commit 33b30cd
Show file tree
Hide file tree
Showing 306 changed files with 21,192 additions and 5,182 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/build-terminal-shared-object.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Build terminal.so

on:
push:
branches:
- main
workflow_dispatch:

jobs:
build:
runs-on: macos-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Install Homebrew
run: |
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- name: Install vterm
run: brew install libvterm

- name: compile
run: |
cd extensions/terminal
gcc terminal.c -I/opt/homebrew/include -L/opt/homebrew/lib -lvterm -o terminal.so -shared -fPIC
mv terminal.so lib/macosx/arm64/terminal.so
- name: Commit and push changes
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add .
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: Add terminal.so
branch: update-terminal-so-macosx-arm64
title: Add terminal.so file
body: Update terminal.so on macosx/arm64
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
DEBUG
*.fasl
*.so
node_modules
package-lock.json
roswell/lem-ncurses
*~

Expand All @@ -28,11 +26,13 @@ GIT_IGNORE.*

lem
lem-ncurses
lem-rpc
lem-server

*.abcl
build/*

*.lx64fsl
.qlot
/systems/

/result
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ COPY . .

RUN apk add --no-cache curl bash build-base ncurses-dev sbcl git

RUN curl -o quicklisp.lisp https://beta.quicklisp.org/quicklisp.lisp
RUN sbcl --noinform --no-userinit --no-sysinit --non-interactive --load quicklisp.lisp --eval "(quicklisp-quickstart:install)" --eval "(ql-util:without-prompting (ql:add-to-init-file))"

RUN curl -L https://qlot.tech/installer | bash

RUN qlot install && \
Expand Down
72 changes: 67 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,91 @@ LISP ?= ${shell which sbcl}

ncurses:
qlot install
$(LISP) --noinform --no-sysinit --no-userinit --load .qlot/setup.lisp --load scripts/build-ncurses.lisp
$(LISP) --dynamic-space-size 4GiB --noinform --no-sysinit --no-userinit --load .qlot/setup.lisp --load scripts/build-ncurses.lisp

sdl2:
qlot install
$(LISP) --noinform --no-sysinit --no-userinit --load .qlot/setup.lisp --load scripts/build-sdl2.lisp
$(LISP) --dynamic-space-size 4GiB --noinform --no-sysinit --no-userinit --load .qlot/setup.lisp --load scripts/build-sdl2.lisp

sdl2-ncurses:
qlot install
$(LISP) --noinform --no-sysinit --no-userinit --load .qlot/setup.lisp --load scripts/build-sdl2-ncurses.lisp
$(LISP) --dynamic-space-size 4GiB --noinform --no-sysinit --no-userinit --load .qlot/setup.lisp --load scripts/build-sdl2-ncurses.lisp

server:
qlot install
$(LISP) --dynamic-space-size 4GiB --noinform --no-sysinit --no-userinit --load .qlot/setup.lisp --load scripts/build-server.lisp

install:
qlot install
$(LISP) --dynamic-space-size 4GiB --noinform --no-sysinit --no-userinit --load .qlot/setup.lisp --load scripts/build-sdl2-ncurses.lisp
sudo install -m 755 lem /usr/local/bin/
sudo install -m 644 scripts/install/lem.svg /usr/share/icons/hicolor/scalable/apps/
sudo gtk-update-icon-cache /usr/share/icons/hicolor
sudo desktop-file-install --dir=/usr/share/applications scripts/install/lem.desktop
@echo "+--------------------------------+"
@echo "| Lem installation complete! |"
@echo "+--------------------------------+"

test:
qlot install
.qlot/bin/rove lem-tests.asd

doc:
qlot install
$(LISP) --noinform --no-sysinit --no-userinit --load .qlot/setup.lisp --load scripts/generate-documentation-tests.lisp --eval '(progn (lem-documentation-mode/tests::generate-markdown-file "test.md" :test) (quit))'
$(LISP) --dynamic-space-size 4GiB --noinform --no-sysinit --no-userinit --load .qlot/setup.lisp --load scripts/generate-documentation-tests.lisp --eval '(progn (lem-documentation-mode/tests::generate-markdown-file "test.md" :test) (quit))'

update:
git pull
qlot install

lint:
.qlot/bin/sblint lem.asd
.qlot/bin/sblint lib/lisp-syntax/lem-lisp-syntax.asd
.qlot/bin/sblint extensions/asciidoc-mode/lem-asciidoc-mode.asd
.qlot/bin/sblint extensions/asm-mode/lem-asm-mode.asd
.qlot/bin/sblint extensions/c-mode/lem-c-mode.asd
.qlot/bin/sblint extensions/color-preview/lem-color-preview.asd
.qlot/bin/sblint extensions/css-mode/lem-css-mode.asd
.qlot/bin/sblint extensions/dart-mode/lem-dart-mode.asd
.qlot/bin/sblint extensions/documentation-mode/lem-documentation-mode.asd
.qlot/bin/sblint extensions/dot-mode/lem-dot-mode.asd
.qlot/bin/sblint extensions/elisp-mode/lem-elisp-mode.asd
.qlot/bin/sblint extensions/elixir-mode/lem-elixir-mode.asd
# .qlot/bin/sblint extensions/encodings/lem-encodings.asd
.qlot/bin/sblint extensions/erlang-mode/lem-erlang-mode.asd
.qlot/bin/sblint extensions/go-mode/lem-go-mode.asd
.qlot/bin/sblint extensions/haskell-mode/lem-haskell-mode.asd
.qlot/bin/sblint extensions/html-mode/lem-html-mode.asd
.qlot/bin/sblint extensions/java-mode/lem-java-mode.asd
.qlot/bin/sblint extensions/js-mode/lem-js-mode.asd
.qlot/bin/sblint extensions/json-mode/lem-json-mode.asd
.qlot/bin/sblint extensions/language-client/lem-language-client.asd
.qlot/bin/sblint extensions/language-server/lem-language-server.asd
.qlot/bin/sblint extensions/legit/lem-legit.asd
.qlot/bin/sblint extensions/lisp-mode/lem-lisp-mode.asd
.qlot/bin/sblint extensions/lisp-syntax/lem-lisp-syntax.asd
.qlot/bin/sblint extensions/lsp-base/lem-lsp-base.asd
.qlot/bin/sblint extensions/lsp-mode/lem-lsp-mode.asd
.qlot/bin/sblint extensions/lua-mode/lem-lua-mode.asd
.qlot/bin/sblint extensions/makefile-mode/lem-makefile-mode.asd
.qlot/bin/sblint extensions/markdown-mode/lem-markdown-mode.asd
.qlot/bin/sblint extensions/nim-mode/lem-nim-mode.asd
.qlot/bin/sblint extensions/ocaml-mode/lem-ocaml-mode.asd
.qlot/bin/sblint extensions/paredit-mode/lem-paredit-mode.asd
.qlot/bin/sblint extensions/patch-mode/lem-patch-mode.asd
.qlot/bin/sblint extensions/posix-shell-mode/lem-posix-shell-mode.asd
.qlot/bin/sblint extensions/process/lem-process.asd
.qlot/bin/sblint extensions/python-mode/lem-python-mode.asd
.qlot/bin/sblint extensions/review-mode/lem-review-mode.asd
.qlot/bin/sblint extensions/rust-mode/lem-rust-mode.asd
.qlot/bin/sblint extensions/scala-mode/lem-scala-mode.asd
.qlot/bin/sblint extensions/scheme-mode/lem-scheme-mode.asd
.qlot/bin/sblint extensions/shell-mode/lem-shell-mode.asd
.qlot/bin/sblint extensions/sql-mode/lem-sql-mode.asd
.qlot/bin/sblint extensions/swift-mode/lem-swift-mode.asd
.qlot/bin/sblint extensions/terminal/lem-terminal.asd
.qlot/bin/sblint extensions/typescript-mode/lem-typescript-mode.asd
.qlot/bin/sblint extensions/vi-mode/lem-vi-mode.asd
.qlot/bin/sblint extensions/welcome/lem-welcome.asd
.qlot/bin/sblint extensions/xml-mode/lem-xml-mode.asd
.qlot/bin/sblint extensions/yaml-mode/lem-yaml-mode.asd
.qlot/bin/sblint extensions/ruby-mode/lem-ruby-mode.asd
116 changes: 116 additions & 0 deletions STYLEGUIDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@

Thanks for contributing to Lem! Here are some guidelines that we follow in the codebase.

In general, we follow the Google guide: https://google.github.io/styleguide/lispguide.xml


## Alexandria and other utility libraries

Lem depends on `alexandria`, so you can use `if-let`, `when-let` and similar functions.

You can `:import-from` these symbols in your package definition, use the `alexandria:` package prefix, and define a package-local nickname.

Try to not use new utility functions that you don't see in the codebase yet.

For instance, we won't use `alexandria-2:line-up-first`.

Try to not use `alexandria:curry` and prefer higher-order functions.

## Dynamic bindings, functional style

Avoid dynamic symbol calls (`uiop:symbol-call`) but rething your architecture instead.

Use `defvar` and `defparameter` for user-facing variables, but avoid
using them as global variables that store state and that are used from
functions to functions. Have a more functional style, give explicit
arguments to functions.

Example:

```lisp
;; avoid this
(defvar *var* 1)
(defun foo ()
*var*)
(let ((*var* 2))
(foo))
```

instead, have `foo` take one argument.


## Don't ignore compiler warnings

Please take attention to compiler warnings.


## Deprecation warnings

If you change or delete a feature, if only a variable name, you must
take care of deprecation warnings. A user should be notified that
something changed. If possible, her old config file should not fail
loading, or it should not fail without notice. Measures can vary. Ideas:

- don't delete or rename a `defvar`, a `defparameter` or a function, but leave it and if it is used, signal a warning or an error. Add a `;; DEPRECATED` comment with the date of the comment.
- document the breaking change on the "next release changelog" issue (like https://github.com/lem-project/lem/issues/1027 or equivalent).


## Documentation

Write thorough docstrings to interactive commands (`define-command`),
give meaningful documentation to important functions, give a
high-level overview in packages and comments (the "why", not the
"how"). Use the `:documentation` option of packages, generic functions
and CLOS slots.

Please also contribute to Lem's website if you add or change a feature.

https://github.com/lem-project/lem-project.github.io/

or at least, open an issue about it so we don't forget to do it, thank you.


## Errors in Lem

`error` is for internal errors, and `editor-error` is displayed nicely to the user.

## File layout

Variables and parameters (`defvar`, `defparameter`) should be grouped
and appear near the top of the file, before conditions, classes and
functions.

### Major and minor modes keybindings layout

Lem modes should define all their keybindings at the top of the file.

## Git and pull requests

Please rebase and squash small commits together (you can do this with lem/legit ! ;) ).

When your changes are about a mode or a feature, we like the commit message to say it upfront, for example:

legit: add k to discard changes of unstaged files


## Loop

Loop keywords are written as keywords, with the `:`:

```lisp
(loop :for key :in … )
```

## Macros, backquote, comma

Don't write long macros, use the "call-with-" pattern.

Don't define lists with backquote and comma, use the `list` constructor.


## User-visible variables names

Parameters that can be changed by the user should not have a "-p"
suffix. Keep them for the functions' key arguments.

They can be saved and set-able with the `lem:config` system.
18 changes: 14 additions & 4 deletions contrib/tetris/tetris.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
(defvar *point-y*)
(defvar *current-tetrimino*)
(defvar *next-tetrimino*)
(defvar *hard-dropped*)

(defvar *score*)
(defvar *delete-nlines*)
Expand All @@ -90,7 +91,8 @@
(setq *point-x* 4)
(setq *point-y* -1)
(setq *current-tetrimino* *next-tetrimino*)
(setq *next-tetrimino* (random-tetrimino)))
(setq *next-tetrimino* (random-tetrimino))
(setq *hard-dropped* nil))

(defun init-field ()
(setq *field*
Expand Down Expand Up @@ -254,23 +256,30 @@
(setq *current-tetrimino* tetrimino))))

(define-command tetris-move-left () ()
(when *playing-p*
(when (and *playing-p* (not *hard-dropped*))
(unless (override-p (1- *point-x*) *point-y*)
(decf *point-x*)
(draw))))

(define-command tetris-move-right () ()
(when *playing-p*
(when (and *playing-p* (not *hard-dropped*))
(unless (override-p (1+ *point-x*) *point-y*)
(incf *point-x*)
(draw))))

(define-command tetris-move-down () ()
(when *playing-p*
(when (and *playing-p* (not *hard-dropped*))
(unless (override-p *point-x* (1+ *point-y*))
(incf *point-y*)
(draw))))

(define-command tetris-hard-drop () ()
(when *playing-p*
(loop :until (override-p *point-x* (1+ *point-y*))
:do (incf *point-y*))
(draw)
(setf *hard-dropped* t)))

(define-command tetris-rotate () ()
(when *playing-p*
(rotate)
Expand All @@ -283,6 +292,7 @@
(define-key *tetris-mode-keymap* "Left" 'tetris-move-left)
(define-key *tetris-mode-keymap* "Right" 'tetris-move-right)
(define-key *tetris-mode-keymap* "Down" 'tetris-move-down)
(define-key *tetris-mode-keymap* "Space" 'tetris-hard-drop)
(define-key *tetris-mode-keymap* "Up" 'tetris-rotate)
(define-key *tetris-mode-keymap* "q" 'tetris-quit)

Expand Down
6 changes: 6 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(import (let lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in fetchTarball {
url =
lock.nodes.flake-compat.locked.url or "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}) { src = ./.; }).defaultNix
Loading

0 comments on commit 33b30cd

Please sign in to comment.