Here’s a comparison of the different Vim IDE options I’ve tested for PS development.
To summarize there are four options, and each have their faults:
- VSCode + vim plugin
- VSCode + neovim plugin
- Vim + CoC
- Vim + LanguageClient_NeoVim
If you have any suggestions on how to get things running smoothly or have a favorite working setup, please share. This is a wiki post that anyone is free to update.
VS Code
This is the easiest to setup. Just grab these PS extensions:
And then choose either of these Vim extensions. Unfortunately both of them have irritating issues compared to native vim:
- vscodevim - Very laggy. This is due to a flaw in VS Code architecture that allows other extensions to block Vim’s text input.
- vscode-neovim - dot repeat and macros are unreliable. Side-effect of a work-around above performance issue.
Common Setup for Vim and Neovim
Plugin management:
The following instructions use vim-plug, but there are lots of other options.
Syntax highlighting:
Install purescript-vim by adding this line to the Plug section of ~/.vimrc
:
Plug 'purescript-contrib/purescript-vim'
Then relaunch vim and run :PlugInstall
Language server:
npm install -g purescript-language-server
CoC.nvim
(with Neovim)
Installation
Install plugin by adding this line to the Plug section of ~/.vimrc
:
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Then relaunch vim and run :PlugInstall
There’s no PS coc extension, so we’re just reusing the VSCode extension. Set that up by launching vim and running:
:CocConfig
Then paste this PS setup config:
{
"languageserver": {
"purescript": {
"command": "purescript-language-server",
"args": ["--stdio", "--config {}"],
"filetypes": ["purescript"],
"rootPatterns": ["bower.json", "psc-package.json", "spago.dhall"]
}
}
}
Then add your bindings. None are included by default. You can just start with coping the contents of this example to your ~/.vimrc
.
Issues
-
gd
“go to definition” usually only works after the second attempt -
K
to show documentation doesn’t render example snippets correctly:
LanguageClient_NeoVim + vimmer-ps + deoplete
-
LanguageClient_NeoVim lets you run queries on the symbol under your cursor such as:
-
:call LanguageClient#textDocument_definition
to jump to definition -
:call LanguageClient#textDocument_hover
to show documentation - None of these commands have default keybindings, so you need to setup these mappings yourself.
-
-
vimmer-ps handles launching purescript-language-server and connecting it to LanguageClient_NeoVim. It also provides some basic bindings such as:
-
\ g
to go to definition -
\ h
show documentation - These assume the default
\
(backslash) for<leader>
. You can confirm by checking if:let mapleader
returns undefined.
-
-
deoplete provides the auto-completion popup
- Cycle through suggestions with
ctrl+n
andctrl+p
. You can also use the arrow keys, but must then usectrl+y
to select the suggestion. These are the default binding and may be changed.
- Cycle through suggestions with
Installation
Add these to your plugin section in ~/.vimrc
:
Plug 'autozimu/LanguageClient-neovim', {
\ 'branch': 'next',
\ 'do': 'bash install.sh',
\ }
Plug 'sriharshachilakapati/vimmer-ps'
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Configure deoplete to launch at startup:
let g:deoplete#enable_at_startup = 1
Relaunch vim to reload ~/.vimrc
(to detect newly listed plugins) and install these plugins by running:
:PlugInstall
Issues
-
Does not work for
spago
projects. Only supportsbower
andpsc-package
projects. Leads to these issues with spago projects:- Only provides matches based on the other symbols in the current file. For example there’s clearly a lot of missing HTML tags here:
- Running
:Pbuild
produces this error:[LC] [Error] Problem running build: didn't find JSON output
- Jump to definition doesn’t work for library functions. For example with cursor on the
const
symbol running:call LanguageClient#textDocument_definition()
or using the mapped binding\ g
doesn’t take me to the definition inprelude
, but instead produces this error:[LC] Not found!
- Only provides matches based on the other symbols in the current file. For example there’s clearly a lot of missing HTML tags here:
-
The documentation popup is missing lots of valuable info. It would ideally show the same content as the pursuit entry, which is what VSCode does and what CoC attempts.
VSCode output: