Emacs integration for psc-ide
The package is available on MELPA. Please read the MELPA’s Getting Started guide
for more information. Once you have MELPA configured install psc-ide-emacs
via package.el
:
M-x package-install RET psc-ide RET
Add the following to your ~/.emacs
:
(require 'psc-ide)
(add-hook 'purescript-mode-hook
(lambda ()
(psc-ide-mode)
(company-mode)
(flycheck-mode)
(turn-on-purescript-indentation)))
If you want to use the psc-ide server that is relative to your npm bin
directory, e.g. ./node_modules/.bin/purs
, add this line to your
config:
(setq psc-ide-use-npm-bin t)
If you would like to use a custom codegen target for your rebuild. (default is “js”)
There is a `psc-ide-codegen` option that can be set globally in your user config:
(setq psc-ide-codegen '("corefn"))
or in specific files by addind this to the top of file:
-- -*- psc-ide-codegen: ("corefn") -*-
This isn’t usually necessary, as the start server command sends a load all command after starting the server.
This was bound to C-SPC
in earlier versions but was too intrusive for
usual emacs users so you’ll have to bind it to a key of choice.
eg. (global-set-key (kbd "C-SPC") 'company-complete)
Prepending the universal argument expands type synonyms in the displayed type.
For example:
C-c C-t
might return getName :: Person -> String
If Person
is a type synonym for a record you can use the universal
argument to inspect that record:
C-u C-c C-t
will then return getName :: { name :: String, age :: Int } ->
String
You can use M-, to jump back to where you came from . If your sourcefiles
are not captured by the default globs you can add a .dir-locals.el
file to
the root of your project, like so:
((purescript-mode
. ((psc-ide-source-globs
. ("src/**/*.purs" "test/**/*.purs" "examples/**/*.purs")))))
Modify the globs accordingly and don’t worry about dependency globs for bower, psc-package or spago projects. The plugin picks these up by default. Check the doc-string for `psc-ide-source-globs` for some advanced options.
If the import is ambiguous you will get a selection of modules, from which you can choose the identifier you want.
Can be turned off with:
(customize-set-variable 'psc-ide-add-import-on-completion nil)
If you set (customize-set-variable 'psc-ide-rebuild-on-save t)
psc-ide will
try to rebuild your module on every save.
This is determined by the variable psc-ide-flycheck-ignored-error-codes
. It can be configured
with customize-option
or similar methods.
When the cursor is placed over an error that includes suggestion information, use C-c M-s
to
apply the suggestion.
Key | Function |
---|---|
C-c C-s | psc-ide-server-start |
C-c C-q | psc-ide-server-quit |
C-c C-t | psc-ide-show-type |
C-c C-i | psc-ide-add-import |
C-c C-a | psc-ide-add-clause |
C-c C-c | psc-ide-case-split |
C-c C-l | psc-ide-load-all |
C-c C-b | psc-ide-rebuild |
C-c C-S-l | psc-ide-load-module |
C-c M-s | psc-ide-flycheck-insert-suggestion |