Skip to content

Instantly share code, notes, and snippets.

@zepadovani
Created March 7, 2024 13:36
Show Gist options
  • Save zepadovani/422cfbb5bf6bdde1823e002e554f6b4c to your computer and use it in GitHub Desktop.
Save zepadovani/422cfbb5bf6bdde1823e002e554f6b4c to your computer and use it in GitHub Desktop.
Tutorial to install/configure IDyOM and run it using Visual Studio Code

1. Only if you need to install sbcl and Visual Studio Code (here, using homebrew)

  1. If you don’t have homebrew (just type brew -v in a terminal to test), I adviseyou to install it as it makes it easier to install apps, command line tools, and similar things, as well to update them. To do that, just run this from command line:

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

  2. Test if you have sbcl (sbcl -v) otherwise install by running: brew install sbcl

  3. Install Visual Studio Code if you don't have it. You can do this by running: brew install --cask visual-studio-code

2. Install quicklisp

  1. Install quicklisp if you don't have already:

    cd
    curl -O https://beta.quicklisp.org/quicklisp.lisp
    sbcl --load quicklisp.lisp
    

    sbcl will start, loading the quicklisp.lisp file that allows to install quicklisp... run:

    (quicklisp-quickstart:install)
    (ql:add-to-init-file)
    (quit)
    
  2. If you also want use emacs, run the following lines in the terminal to setup a .emacs config file:

echo '(load (expand-file-name "~/quicklisp/slime-helper.el"))\n(setq inferior-lisp-program "sbcl")' >> ~/.emacs

3. Install and configure sbcl to run IDyOM:

  1. Download and unzip idyom:
cd ~/quicklisp/local-projects/ && curl -O https://github.com/mtpearce/idyom/archive/refs/tags/v1.7.1.zip && unzip v1.7.1.zip
  1. We need to add some lines to .sbclrc (SBCL configuration file) so that it loads clsql, when started, and has a function definition to start idyom. You can do this by copying this to your terminal:
echo '
;; Loads clsql by defaylt: clsql is a package to deal with SQL databases
(ql:quickload "clsql")  

;;; Define function to start IDyOM  
(defun start-idyom ()  
	(defvar *idyom-root* (merge-pathnames "idyom/" (user-homedir-pathname)))  
	(defvar *idyom-message-detail-level* 1)  
	(ql:quickload "idyom")  
	(clsql:connect `(,(namestring (merge-pathnames "idyom/db/database.sqlite" (user-homedir-pathname)))) :if-exists :old :database-type :sqlite3))' >> ~/.sbclrc
  1. Althought IDyOM should automatically create all directories needed to work, it does not create the ~/idyom/db/ folder, where it stores the database file. So, let's create it pasting this to the terminal:
mkdir -p ~/idyom/db
  1. Run sbcl and start IDyOM
sbcl
(start-idyom)
  1. In the first run, you will need to initialise the database (this command cleans everything if you have already created one, so don't run it in further interactions if you don't want to wipe everything inside IDyOM's database):
(idyom-db:initialise-database)

4. Configure Visual Studio Code to run Lisp Code in the terminal

  1. Install the Common Lisp Extension (author: Qingpeng Li): ![[Pasted image 20240307102844.png]]
  2. Configure a shortcut to run selected regions of a file in the terminal:
    1. (Cmd+Shift+P) and search for "Run Selected Text in Active Terminal" ![[Pasted image 20240307103114.png]]
    2. Click in keybinding and press the keybinding (ex: Cmd+ Enter). Then press Enter to assign.
    3. Create some lisp file anywhere and type (+ 2 3), just to test a simple sum
    4. Open the integrated Terminal (Ctrl+`)
    5. In the terminal, run sbcl (sbcl)
    6. Select the sum in the text file and use your shortcut.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment