Node-based Language Server Protocol server for PureScript based on the PureScript IDE server
(aka psc-ide / purs ide server
). Used as the vscode plugin
backend but should be compatible with other Language Server Client implementations.
The language server is a wrapper around the IDE server included as part of the compiler distribution,
providing editing assistance and build features according to support available. This means that
the server will start its own purs ide server
instance to talk to for the project directory it is started
in.
- Completion provider
- Definition provider
- Formatting provider
- Document & workspace symbol providers
- Hover provider
- Code action provider
- Compiler fix suggestions for imports/missing types
- Build on save (via IDE server "fast rebuild" facility, certain limitations apply)
- Provides diagnostics
- Commands
- Build (full build via
purs compile
/ configured build command) - provides diagnostics - Case split
- Add clause
- Replace suggestion
- Add completion import
- Start IDE server
- Stop IDE server
- Restart IDE server
- Build (full build via
- Config
purescript.*
This LSP implmementation is consumed by vscode and Atom plugins as a node module, and bundled along with those plugins.
To use with another LSP client, you will want to install this either globally or locally for npm
, e.g.
npm i -g purescript-language-server
And then use the resulting executable, e.g. purescript-language-server --stdio
.
This language server is based on vscode-languageserver-node which means it should support --stdio
, --socket=[number]
, --node-ipc
or --pipe
methods of communication, see vscode-languageserver-node for details.
Use atom-ide-purescript.
Use vimmer-ps.
Configuration with coc.nvim:
"purescript": {
"command": "purescript-language-server",
"args": ["--stdio"],
"filetypes": ["purescript"],
"trace.server": "off",
"rootPatterns": ["bower.json", "psc-package.json", "spago.dhall"],
"settings": {
"purescript": {
"addSpagoSources": true // etc
}
}
}
Config may be supplied via client-push on startup (workspace.didChangeConfiguration
), server-request (workspace.configuration
), or at last resort by JSON object on the command line with --config
option.
See config defined in vscode plugin.
When using the language server together with alternate backends, the only requirement is to stop purs ide server
from attempting to generate JS when rebuilding, this is done via the config
"purescript.codegenTargets": [ "corefn" ]
(and you should make sure the build command is in accordance with that, if used, eg specify backend
in spago
config).
Various commands are provided. Some are triggered via completion etc, some must be called explicitly from a LSP client.
No arguments. Provides diagnostics.
No arguments. Start IDE server according to configuration.
No arguments. Stop running IDE server.
No arguments. Stop any running IDE server then start a new one according to configuration.
Arguments: identifier, module, document URI.
Arguments: module, qualifier, document URI.
No arguments. Get list of available modules.
Arguments: document URI, replacement, replacement range.
Flex search for identifier.
Arguments: search text.
Arguments: document URI, line, character.
(Used to back the case split command in VS Code UI).
Arguments: document URI, line, character, type.
(Used to back the add clause command in VS Code UI).
Arguments: document URI, line, character.
(Used to back the purescript.typedHole
code action triggered in the VS Code UI)
Arguments: hole name, document URI, hole range, PscIde.Command.TypeInfo
of chosen replacement option
To develop (rather than use) this language server
- Clone this repo and
npm install
- Make changes and
npm run build
- Ensure the built module is picked up by your editor
For 3, if the editor integrates using the node module rather than standalone binary, I suggest using npm link
- this will work for atom and vscode at least.
For atom, clone atom-ide-purescript
and:
- In
purescript-language-server
runnpm link
, inatom-ide-purescript
runnpm link purescript-language-server
- In
atom-ide-purescript
runapm link
to pick up local changes - In
atom-ide-purescript
, runnpm run bundle
to build the plugin itself - Reload any atom window to pick up changes
For vscode, clone vscode-ide-purescript
and:
- Run
npm install
- In
purescript-language-server
runnpm link
, invscode-ide-purescript
runnpm link purescript-language-server
- Open
vscode-ide-purescript
in vscode (code .
) and hit F5 to "launch extension" - Use the newly launched Extension Development Host to test language server changes
See vscode plugin repo, atom plugin. Common code via purescript-ide-purescript-core.