🌚 LunarVim + Purescript + LSP
Being a die-hard fan of coding in (neo)vim
, I've been forced myself to look for the perfect (or at the very least decent)
configuration of a development environment for my language of choice, or the one I'm currently learning, which in this case is purescript
.
The present post's goal is to shed some light on certain tooling that exist today but they are probably not
widely known; such as LunarVim
, and also keep a record for myself for how the hell did I
configure this!? 😜
What is LunarVim
My main (and pretty much only) editor today is LunarVim
(for both work and personal stuff),
the reason I stuck with it instead of my own neovim configuration, is because I like the defaults of the editor and the nice automation it has when adding a new treesitter language or a new lsp implementation.
So if that piqued your interest, you should definitely give it a try!, the cool thing is that it won't interfere with your current neovim install 😉.
Why LSP
For every language that I work I NEED to have an implementation of a language server protocol (LSP) for it (or similar), I just need to get a feeling of some standard automated process will assist me on my coding, including simple stuff such as Dockerfile or mardown files (yes, I want it to be autoformatted for me, that is how lazy I am!)
How to get it working 💚
1. Configure your LunarVim
Make sure you have installed LunarVim
.
LunarVim
uses treesitter
in order to detect file types, and it also includes advanced syntax
highlighting via the included plugin nvim-treesitter
. But, as of now, it only supports a fixed set of languages, which does not include purescript
😭
But fear not, you can easily fall back to a super popular plugin, called vim-polyglot
.
Add the following in your ~/.config/lvim/config.lua
lvim.plugins = {
-- rest of plugins ...
{ "sheerun/vim-polyglot" },
{ "purescript-contrib/purescript-vim" },
}
Now you have proper file type detection and syntax highlighting!.
2. Create a Purescript
project
The tooling that I use for a purescript
project are purescript
(surprise!) and spago
, so proceed to install then if
you don't have them:
$ brew install purescript spago
$ mkdir hello-world-ps
$ cd hello-world-ps
$ spago init
$ spago run
Open the created file:
$ lvim src/Main.purs
LunarVim
will detect the file type and download the proper LSP
, in this case is
purescriptls
automatically, and... that's it!, really!, enjoy! 😁