Table of Contents
Perga
Perga is a Haskell project built using cabal, so should fairly easy to build and install if you are familiar with Haskell. I plan on nixifying the repo at some point, which would make installation significantly easier as well as reproducible, but for now, you can follow the following steps:
- Install Haskell (I would highly recommend using ghcup), specifically GHC 9.8.2.
- Install cabal, any recent version will do (I'm using the latest version, 3.12.1, at the time of writing).
- Clone this repo
$ git clone https://forgejo.ballcloud.cc/wball/perga. - Run the command
cabal installfrom within thepergadirectory. This will compilepergaand all of its dependencies and place the executable in$HOME/.cabal/bin. - Add
$HOME/.cabal/binto your$PATH. Now you should have the commandpergaavailable. Run with no arguments, it should drop you into a REPL whose prompt is simply>.
Neovim plugin
Any text editor will do for editing perga files, though support is most available through the perga.nvim plugin, which provides syntax highlighting through treesitter, among other things. It can be installed just like any other neovim plugin. Here is an example lazy.nvim plugin spec.
{
"https://forgejo.ballcloud.cc/wball/perga.nvim",
config = true,
},
Upon installing the plugin, you will have to run :TSInstall perga in order to install the treesitter grammar. At this point, any file with the .pg file extension should have wonderful syntax highlighting. I would also recommend the plugin rainbow-delimiters.nvim, which perga.nvim supports, which colors matching delimiters (e.g. parentheses) the same color. It is useful when working with any language with many nested delimiters (e.g. lisps), and that absolutely includes perga, at least for the moment.
As a word of warning, if you use fancy treesitter plugins, they may not handle some perga syntax well, particularly any expressions involving binary operators. Perga features custom binary operators (similar to Haskell, though I would like to extend it to be more like Agda in the future), which does not play well with treesitter. As such, the treesitter parser just assumes all operators have the same precedence and are left associative. This completely produces the wrong syntax tree, but produces correct syntax highlighting.