Emacs eglot config for purescript-language-server

I’ve been running with the eglot lsp client with purescript-language-server, in emacs for some time now, with no hiccups. However I have been using a very vanilla configuration, that is using the system installed version of purs.

Has anybody got eglot working with a node_modules/.bin/ version of purs ? I can’t figure how to do it. I would like eglot to use these config settings:

"purescript.addNpmPath": true,
"purescript.buildCommand": "npx spago build --purs-args --json-errors",

eglot doesn’t officially mention anything about purescript on their page, so I am kind of in no man’s land here.

Solution, for anyone who stumbles upon this, is composed of two points:

  1. Config like the above can be sent to the purescript-language-server on startup with the --config flag, so in lisp:
(add-to-list 'eglot-server-programs
             '(purescript-mode  . ("/home/xyz/.nvm/versions/node/v14.15.1/bin/purescript-language-server" "--stdio"
                                   "--config {\"purescript.addNpmPath\": true,
                                              \"purescript.buildCommand\": \"npx spago build --purs-args --json-errors\"}" )))
  1. I needed to add the node_modules/.bin to the emacs PATH in my init.el. Then purescript-language-server, which is running as a child of the shell instance emacs runs in, will then find the project bespoke purs. *

*I guess I wouldn’t need to do this if I was running emacs from my bash shell, where all this environmental stuff is setup, it would just inherit the environment as a child process. But I run emacs through a laucher. I’m happy doing this config step in as I can see right there in my init.el what is being pulled in, and update it when the need arises.