Published on 2021-06-26 by Kenneth Flak
Back to Tech Research
I am currently learning lisp, and setting up neovim on Arch Linux to do so. These are my notes to get a development environment up and running, heavily indebted to jdhao's post.
sbcl
is a lisp interpreter that allows you to do actual REPL. Easily installed through pacman:
sudo pacman -S sbcl
Done.
Quicklisp is the lisp package manager, allowing you to easily install external libraries. It is available in AUR, but I found the easier way to install and use it to be the official way:
curl -O https://beta.quicklisp.org/quicklisp.lisp
sbcl --load quicklisp.lisp
Fire up sbcl
and run:
(quicklisp-quickstart:install)
followed by
(ql:add-to-init-file)
This will add quicklisp to your .sbclrc
file:
;;; The following lines added by ql:add-to-init-file:
#-quicklisp
(let ((quicklisp-init (merge-pathnames "quicklisp/setup.lisp"
(user-homedir-pathname))))
(when (probe-file quicklisp-init)
(load quicklisp-init)))
Run this inside sbcl
:
(ql:quickload "linedit")
and add this to .sbclrc
:
;;; Check for --no-linedit command-line option.
(if (member "--no-linedit" sb-ext:*posix-argv* :test 'equal)
(setf sb-ext:*posix-argv*
(remove "--no-linedit" sb-ext:*posix-argv* :test 'equal))
(when (interactive-stream-p *terminal-io*)
(require :sb-aclrepl)
(require :linedit)
(funcall (intern "INSTALL-REPL" :linedit) :wrap-current t)))
use {
'vlime/vlime',
config = function()
rtp = 'vim/'
end
}
For convenience I created this alias in .zshrc
:
alias vlime='sbcl --load ~/.local/share/nvim/site/pack/packer/start/vlime/lisp/start-vlime.lisp'
This allows you to type vlime
into a terminal and give you a server.
Open a .lisp file, and type <localleader>cc
to establish a connection between nvim
and sbcl
. <localleader>
is mapped to \
by default.
To send a line to sbcl
for evaluation, type <localleader>ss
, or toggle interactive mode by typing <localleader>i
. This lets you evaluate any block of code by hitting <cr>
.
vlime
ships with its own completion engine, which seems to conflict with my preferred autocompletion plugin, nvim-compe
. For now I have decided to simply disable nvim-compe
for lisp files by creating ~/.config/nvim/after/ftplugin/lisp.vim
and adding
lua <<EOF
require'compe'.setup { enabled = false }
EOF
Additionally, ervandew/supertab
, a fantastic plugin in many ways, is stomping on the vlime
autocompletion, and there is no way to disable supertab
per buffer. I must admit, there's been more than once where I've thinking that it's time to let supertab
go, and I think this might have finally pushed me over the edge.
That's it for now, I will keep updating this post if and when I learn more tricks to leverage the power of lisp, nvim and sbcl...
Happy parenthesizing!