Pangram verdict · v3.3
We believe that this document is fully human-written
AI likelihood · overall
HumanArticle text · 1,734 words · 5 segments analyzed
By Susam Pal on 07 Dec 2019 Introduction Fifteen years ago, writing Lisp code in Vim was an odd adventure. There were no good plugins for Vim that assisted in structured editing of Lisp s-expressions or allowed interactive programming by embedding a Lisp Read-Eval-Print-Loop (REPL) or a debugger within the editor. The situation has improved a lot since then. In the last ten years, we have seen active development of two Vim plugins named Slimv and Vlime. Slimv is over 10 years old now. Vlime is more recent and less than 3 years old right now. Both support interactive programming in Lisp. I am going to discuss and compare both Slimv and Vlime in this article. I will show how to get started with both plugins and introduce some of their basic features. I will not cover everything though. This is not a tutorial. For tutorials, see the References section. If you are looking only for a comparison of the two plugins or a quick recommendation, jump directly to the Comparison of Slimv and Vlime section or the Quick Recommendation section. Contents Introduction Background Lisp Emacs: SLIME Vim: Slimv/Vlime Vim Plugin Management Software Versions Get Started Get Started with Slimv and SBCL Get Started with Vlime and SBCL Get Started with Paredit Use Debugger and Inspector Use Debugger and Inspector with Slimv Use Debugger and Inspector with Vlime Trace Function Trace Function in Slimv Trace Function in Vlime Nifty Features Evaluate Top-Level Form Rainbow Parentheses Argument List Omni-Completion Describe Symbol Expand Macro Cross Reference Other Common Lisp Implementations Use Slimv with CLISP Use Slimv with ECL Use Vlime with CLISP Use Vlime with ECL Other Lisp Dialects Use Slimv with MIT/GNU Scheme Use Slimv with Clojure Comparison of Slimv and Vlime Quick Recommendation Disclosure References Background Before we get started with Slimv and Vlime, it would be nice to take a brief look at the heritage behind these plugins. These plugins provide Lisp development environments for Vim, so their story begins with Lisp. Lisp Lisp is a family of programming languages with a distinctive, fully parenthesised prefix notation. It is quite unlike most of the other popular programming languages today like C, Python, Ruby, etc.
Its homoiconic nature and its powerful macro system that can transform arbitrary Lisp expressions make it such a flexible, versatile, extensible and introspective language that articles describing Lisp often have the word "enlightenment" in them. For example, see the following articles: Beating the Averages (by Paul Graham) The Nature of Lisp (by Slava Akhmechet) How Lisp Became God's Own Programming Language (by Sinclair Target) Lisp has been described in various ways by various eminent personalities in the history of computing. Alan Kay has famously described Lisp as: The greatest single programming language ever designed. John Foderaro has written this about Lisp: Lisp is a programmable programming language. Eric S. Raymond has expressed the enlightenment one experiences by learning Lisp in his famous article titled How To Become A Hacker: Lisp is worth learning for the profound enlightenment experience you will have when you finally get it. That experience will make you a better programmer for the rest of your days, even if you never actually use Lisp itself a lot. Randall Munroe, the creator of the XKCD webcomic has dedicated two comic strips to Lisp: Lisp by Randall Munroe (Source: https://xkcd.com/224/) Lisp Cycles by Randall Munroe (Source: https://xkcd.com/297/) Developed in 1958 by John McCarthy, Lisp is the second oldest programming language in use today. Only Fortran is older, by one year. Some of the popular Lisp dialects today include Common Lisp, Scheme and Clojure. Most of this article would focus on Common Lisp. Scheme and Clojure would be discussed briefly towards the end of this article. Emacs: SLIME Many Lisp programmers immediately think of Emacs when they think of writing Lisp code. Emacs is a family of text editors. An Emacs editor itself is typically implemented in a dialect of Lisp. There is an Emacs mode named SLIME that provides excellent support for programming in Lisp. SLIME stands for Superior Lisp Interaction Mode for Emacs. First released in August 2003, SLIME was created by Eric Marsden and then later developed further by Luke Gorrie and Helmut Eller.
It offers a Read-Eval-Print-Loop (REPL), integrated debugging and interactive evaluation of expressions, all available right within the editor. There are several nifty key bindings available to compile and evaluate parts or whole of the code in the current buffer. SLIME works by launching a Swank TCP server. Swank is a backend server program written in Common Lisp that listens on a socket to receive SLIME commands from Emacs and execute them. SLIME is so useful that it is considered to be indispensible by many Lisp programmers who write Lisp code in Emacs. Vim: Slimv/Vlime Is there anything similar to SLIME for Vim? Yes, there are two popular options: Slimv: It stands for Superior Lisp Interaction Mode for Vim. It is a Vim plugin created by Tamas Kovacs that was first released in January 2009. Vlime: It is a Vim plugin created by Kay Z that was first released in May 2017. It is much more recent than Slimv. Vlime is younger than Slimv by eight years. Both plugins use a client-server architecture like SLIME does in Emacs. Both plugins rely on Swank server to be started. In fact, Slimv bundles a slightly modified version of Swank with it, so that it can launch it and connect to it to send expressions to be evaluated. Vlime does not bundle Swank server with itself but it provides a wrapper that automatically downloads Swank server when needed. Vim Plugin Management When I started using Vim fifteen years ago, we used to just download a Vim plugin and copy/extract it to ~/.vim directory. These days, there are a few plugin management tools for Vim such as Pathogen, Vundle, vim-plug, etc. I am not going to use any of them because I don't know which one of them you use and I don't want to write down steps for each one of them. In fact, I have never used any Vim plugin manager myself. Until Vim 7, I used to create a ~/.vim/bundle directory, then copy each plugin to its own directory within it and add the plugin's directory path to Vim's runtimepath option. Vim 8 has native support for packages which makes installing plugins and loading them simpler.
With Vim 8, we can copy each plugin to its own directory within ~/.vim/pack/plugins/start and they are loaded automatically when Vim starts. The directory name plugins in this path is only an example. It could be any arbitrary name and Vim would still load the plugins fine. In this article, I will use Vim 8's native support for packages to set up Vim plugins. The only exception to this would be installing Vlime. The top-level directory of Vlime is not the plugin directory. The plugin directory is contained in a subdirectory named vim. This does not conform to the directory structure of plugins in a Vim package. Therefore, in this article, I will set up Vlime in the old fashioned way by copying it to ~/.vim/bundle and then adding the path to its plugin directory to Vim's runtimepath option. Software Versions Since this article involves several layers of software, some of what is written here may not hold good in future as these various pieces of software change and evolve over time. Therefore, in this section, I will note down the versions of various software tools I used while writing this article. Here they are: Debian GNU/Linux 10.1 (buster) Vim 8.1 Slimv (Git repo last updated on 30 Nov 2019 with commit 47a0070) Vlime (Git repo last updated on 16 Oct 2017 with commit 065b95f) Paredit (Git repo last updated on 30 Nov 2019 with commit d99905a) Rainbow Parentheses (Git repo last updated on 29 Oct 2015 with commit 27e7cd7) SBCL 1.4.16.debian GNU CLISP 2.49.92 ECL 16.1.3 MIT/GNU Scheme 9.1.1 on Debian GNU/Linux 9.11 (stretch) Clojure 1.10.1 Quicklisp beta (libraries last updated on 30 Nov 2019) tmux 2.8 You will probably need only a tiny subset of the tools above depending on which sections in this article you would follow.
Just pick the sections you want to try out and follow the steps written in them. They will walk you through the procedure to install the tools applicable to the sections you have picked. Regardless of which sections you pick, I recommend that you definitely go through the three "Get Started" subsections below. These subsections go into detail about some of the prerequisites such as support for tmux, Paredit, support for Python interface in Vim, etc. that are not covered in the other sections. The choice of Debian may look like an odd one. I want the commands and steps discussed in this article to be easily reproducible in a free and open source operating system. Debian happens to be my favourite. What works on Debian is easily reproducible on Ubuntu and other derivatives, often without any changes to the steps. I believe, it will not be too difficult to translate the steps provided for Debian to the steps that would work on another operating system. Note that Quicklisp (a prerequisite for Vlime) is still beta software at the time of writing this article. The actual steps to install Quicklisp may change in future. Check https://www.quicklisp.org/ for the most up-to-date instructions to install Quicklisp. Get Started Get Started with Slimv and SBCL Here are the steps to set up Slimv and use it: Install the tools required to set up a Common Lisp development environment with Slimv with this command: sudo apt-get install vim-nox sbcl tmux git The default Vim in Debian is vim.basic provided by the vim package which does not have support for Python interface. Slimv is written in Vim script, Lisp and Python 3, so it does need a Vim package that has support for Python interface. One such package is vim-nox that provides the vim.nox command. Installing it automatically updates the vim command to run vim.nox. Another such package is vim-gtk which additionally provides GUI support. The graphical Vim known as GVim can be launched with the gvim command. It runs in the desktop environment. For the purpose of this article, I will stick to vim-nox because it is lightweight. All steps meant for Slimv would run equally well on vim-gtk, MacVim and GVim.