DEV Community

CoffeeBeagle
CoffeeBeagle

Posted on

Make environment to develop commonlisp with NeoVim

You can refer the document to make environment for sbcl.

The plugin in neovim

  • nvlime
  • lazy.nvim (It's not related this topic though)

How to use

I recommend some function for you. (You can read :h nvlime-tutor if you want to know more.)

  • <leader>rr To launch REPL server
  • <leader>si To send a command to REPL
  • <leader>cd To stop REPL server
  • <leader>rt To restart REPL server.
  • <leader><enter> To change interactive mode?
    • During this mode, you can eval a code that your cursur is on when you type enter in normal mode.

Problem1. SBCL can not load quicklisp, when it launch.

  • You can check help :h nvlime when you face some problems.
  • It may custome initializing function, so I try to call the function.
vim.g.nvlime_config = {
    implementation = "custom"
}

local setup_lisp_file_path = vim.fn.expand('$HOME/quicklisp/setup.lisp')

local fn = string.format([[
function! NvlimeBuildServerCommandFor_custom(nvlime_loader, nvlime_eval)
return [ "sbcl",
\ "--load", "%s",
\ "--load", a:nvlime_loader,
\ "--eval", a:nvlime_eval]
endfunction
]], setup_lisp_file_path)

vim.api.nvim_exec(fn, false)
Enter fullscreen mode Exit fullscreen mode

Problem2. Your package is not included in quicklisp when you launch REPL server.

  • I want to load my package when I launch the REPL server, so I customed my neovim setting, which it can load a file if the file named .sbcl.lisp is in current directory.

Problem3. How to load my develping package in the first place.

  • There is the variable asdf:*central-registry* included loading directory for some asdf, so you need to register your develping directory to the variable.
 (let ((packages '("project/"
                   "project/sub-module/")))
   (loop for p in packages
         do (let ((path (merge-pathnames  p (user-homedir-pathname))))
              (pushnew path asdf:*central-registry* :test #'equal))))
Enter fullscreen mode Exit fullscreen mode

Top comments (0)