ide-purescript

PureScript support for completion, build and assistance with Atom IDE

nwolverson

18,336

8

0.25.0

MIT

GitHub

This package consumes the following services:

ide-purescript package for Atom

Build Status

This package provides editor support for PureScript projects in Atom, based on a Language Server which uses the purs compiler IDE server functionality, with UI provided via the atom-ide framework.

This package provides:

Package should trigger on opening a .purs file or running any PureScript/PSCI command from the menu bar or command palette. For full support of atom-ide features, your PureScript project should be opened at the root folder level in Atom.

Installation and General Use

For best results (and default settings) install dependencies:

Required atom packages - these should be auto-installed by starting the package, eg by running any PureScript command.

For use with older versions of pulp, or for alternative build tools and configuration tips, see below. In brief the build command is configurable, but should output JSON errors.

IDE server

This package runs a langauge server process, which itself starts a compiler server process, purs ide server (previously psc-ide-server), to provide type information, completions,etc. This package will automatically start the IDE server in your project directory and kill it when closing.

You can start/stop and restart this via provided commands, and configure the server to auto-start or not as desired; if for some reason if for some reason you want to manually start a purs ide server process you can start that before starting atom, and configure the server port to match (but beware clashes of multiple instances, and the path must match).

Multiple PureScript projects are supported, by adding each project as a top level folder.

For all functions provided by purs ide server you will need to build your project first! In particular a full build, not a "fast-build" on save, is required first time or after upgrading purs, afterwards saving individual files will update tooltips etc.

Autocomplete

Provided from the IDE server. Make sure your project is built first. Only for top level definitions.

Completions will be sourced from all available modules by default; this is configurable to just those imported in the current file, in which case explicitly (re-)triggering the completion will expand to show all modules.

Imports will be inserted automatically for completions! Again this is configurable.

Tooltips

Hovering over an identifier will show a tooltip with its type (only for top level definitions):

Type tooltip

This is really stupid, and only cares that you hover over a word regardless of context, you will get some false positives.

Go to definitions

Hyperclick goto-definition functionality is supported. This is available with purs version 0.9.2 and above, and like tooltips/autocomplete works on identifiers bound at the top level. This is available as command/ctrl+click or cmd+alt/opt+enter by default, see atom-ide-ui config.

In case source positions are not up to date, they may not be updated on rebuild, try rebuilding or restarting psc-ide server.

Pursuit lookup

Pursuit lookup

Command available from the command palette:

PSCI

PSCI window

Basic PSCI REPL integration (runs pulp psci). Comprises a read-only pane which displays PSCI output, and an input field to send expressions to the REPL (just hitting enter). Input can be sent from the current buffer by line or selection.

Command from the command palette:

Build

Build support is provided via pulp build by default, configurable to any command which will output psc errors. This can be configured to run on save, alternatively there is a 'PureScript Build' command.

As well as this there is "fast rebuild" via the IDE server on save (by default), this will build an individual file. The recommended approach is to run a full build initially and after any dependency upgrades, compiler updates, etc. or when producing build artifacts, and otherwise quick build for continuous error feedback.

Build configuration hints

The default build command is

pulp build -- --json-errors

(on windows pulp.cmd is called instead). Note This default requires pulp 0.10 as command syntax changed to require -- separator. This is configurable: the command should be on your PATH (or could be an explicit absolute path) with arguments, such that it will output JSON errors as per psc, on stderr. This is not interpreted via shell, simply pulled apart as a list of string separated arguments.

Some alternatives:

Since atom unfortunately does not support per-project configuration, the npm run script approach may be particularly useful where you have different projects that build differently. Alternatively you can look into the project-manager package.

You may be able to get away without thinking about all this if your project specific setup is only required for a "full" build (e.g. browserify step) and not just for the basic compilation stage.

Error Suggestions / Quick-Fix

Error indication

Error fix UI

Error suggestions may be triggered from some underlined compiler warnings. Suggestions apply on hover, or a context menu can be triggered by 'alt-A' (Diagnostics: Show Actions at Position) when the cursor is on an eligible warning. Currently fixable warnings:

Case split / add clause

Case split/add clause

Currently the type of the arguments must be provided by the user.

Hacking on atom-ide-purescript

After cloning, install dependencies • psc-package updatenpm install

Bundle for Atom: npm run -s bundle

You can use the regular pulp build as part of your tooling or to see compile errors, but bundling is required for the plugin to be usable by Atom and will build the project as part of the task.

To use your local development version, you will first need to uninstall any current version you have installed. Then from within the atom-ide-purescript directory run apm link. This will create a symlink from the Atom plugins directory to your development directory.