-
-
Notifications
You must be signed in to change notification settings - Fork 190
Lem Manual for Users
The documentation is in progress. You can find a first list of available keys and commands in default-keybindings.md.
NEW! Lem has a web page, in progress too: https://lem-project.github.io/lem-page/usage/keybindings/
Lem has Emacs-like keybindings, as well as a vi emulation (M-x vi-mode
).
So, to open a file, press C-x C-f
(you get the file selection dialog shown above). To save it, it's C-x C-s
. To save many buffers at once, C-x s
.
To switch to the REPL: C-c C-z
.
To compile and load a buffer: C-c C-k
. To compile a function: C-c C-c
.
To switch windows (aka splits of a screen): C-x o
('o' letter) and M-o
. To make a window fullscreen: C-x 1
. To split it vertically: C-x 3
and horizontally: C-x 2
. To make the current window disappear: C-x 0
(zero).
To switch buffers: C-x b
.
To run an interactive command: M-x
(alt-x
).
To evaluate some Lisp code: M-:
.
To show the context menu: Shift-F10
.
See this Emacs & Slime cheatsheet to find more: https://lispcookbook.github.io/cl-cookbook/emacs-ide.html#appendix
Use C-x b
(aka M-x list-buffers
). But don't stop here, it's a rich command.
You are presented a "modale" window. Type some text to start narrowing the buffers list matching your entry.
You can also use Space to select/deselect entries, then use a right click to choose an action to apply on the selected buffers. Default actions are to kill the selected buffers, or to save them.
Use M-x vi-mode
and M-x emacs-mode
.
To know what function is bound to a key binding, use M-x describe-key
(C-x ?
).
To see the currently available key bindings, use M-x describe-bindings
.
See also describe-mode
, to understand in which mode the editor is in the current buffer.
M-x grep
this presents the results in a two-panes window. You can edit lines in the results buffer, changes are reflected immediately on the files, and updated on the right side. You can use search and replace M-x query-replace
in the results buffer.
Use M-C
(Alt and capital c), `M-x add-cursors-to-next-line) to add a cursor to the next line.
For Go, if you have gopls, it should work without doing anything.
Otherwise, configurations are required.
An example JS config for LSP:
(lem-lsp-mode/lsp-mode::define-language-spec
(js-spec lem-js-mode:js-mode)
;; thanks @sasanidas
:language-id "javascript"
:root-uri-patterns '("package.json" "tsconfig.json")
:command '("typescript-language-server" "--stdio")
:install-command "npm install -g typescript-language-server typescript"
:readme-url "https://github.com/typescript-language-server/typescript-language-server"
:connection-mode :stdio)
To see all supported languages and modes, see the modes/ directory.
Languages include: asm, c, css, dart, go, haskell, html, java, js, lisp, nim, ocaml, python, rust, scala, scheme, shell, sql…
Other modes include: asciidoc, dot, json, lsp, makefile, paredit, patch, posix-shell, review, vi, yaml…
python-mode
supports:
- syntax highlighting
-
M-x run-python
command M-x python-eval-region
elixir-mode
(preliminary work merged on 30th, May 2023) adds:
- syntax highlighting
- preliminary LSP support
-
M-x run-elixir
command M-x elixir-eval-region
For more information: https://github.com/lem-project/lem/pull/647
- syntax highlighting
-
M-x go-electric-close
,gofmt
,godoc
,godef-describe
,goflymake
with inline annotations,M-x go-remove-notes
to delete the overlays.
This is the default LSP configuration:
;; in modes/go-mode/lsp-config.lisp
(define-language-spec (go-spec lem-go-mode:go-mode)
:language-id "go"
:root-uri-patterns '("go.mod")
:command (lambda (port) `("gopls" "serve" "-port" ,(princ-to-string port)))
:install-command "go install golang.org/x/tools/gopls@latest"
:readme-url "https://github.com/golang/tools/tree/master/gopls"
:connection-mode :tcp)
Example config:
;; thks sasanidas
(setf lem-scheme-mode::*default-port* 4010
lem-scheme-mode::*use-scheme-autodoc* :auto
lem-scheme-mode::*scheme-swank-server-run-command*
'("guile" "--r7rs"
"-l" "lisp/scheme/r7rs-swank/guile-swank.scm"
"-c" "(import (guile-swank)) (start-swank)")
lem-scheme-mode::*use-scheme-repl-shortcut* t )
- syntax highlighting, go to beginning/end of function, indentation…
- format buffer (see
*rust-format-buffer*
which defaults to "rustfmt"), format on save hook (see*rust-format-on-save*
which defaults tot
) - preliminary support for find definition.
Default keys:
(define-key *rust-mode-keymap* "C-c C-f" 'rust-format-buffer)
(define-key *rust-mode-keymap* "M-C-q" 'indent-exp)
Use define-command
:
(in-package :lem)
(define-command open-init-file () ()
;; @sasanidas
(lem:find-file
(merge-pathnames "init.lisp" (lem-home))))
or copy-paste this with M-:
(lem:define-command open-init-file () ()
(lem:find-file
(merge-pathnames "init.lisp" (lem:lem-home))))
You can now call it with M-x open-init-file
.
(if none of the 100 available in Lem 2.0 don't satisfy you, see M-x list-color-themes
).
;; thanks https://gist.github.com/jason-chandler/6332e3fd753fa87e3b1cd13582df5862
(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")
- @sasanidas
- https://gist.github.com/jason-chandler/6332e3fd753fa87e3b1cd13582df5862 getting cxxxr/valtan to work along with paredit and the monokai theme