purcell / emacs.d

An Emacs configuration bundle with batteries included
BSD 2-Clause "Simplified" License
6.85k stars 2.05k forks source link

Purescript environment with eglot #819

Closed arthurl closed 2 years ago

arthurl commented 2 years ago

Hi,

As you're aware, flymake in purescript-mode isn't working at present. (I tried digging into it, and it appears that for some reason psc-ide refuses to appear in the list of enabled checkers in flycheck, but that's as far as I got.)

Anyway, I had some use for purescript, so I went ahead and tried out purescript-language-server on eglot. The good news is, it pretty much works out of the box (i.e. calling eglot-ensure alone is enough), if you install the language server + purs + spago (not sure about bower) globally.

Personally, I hate installing anything globally, so there's just a few lines of code in this PR to make the language server find executables in the local project node_modules folder (and falls back to the usual behaviour if that fails). It works well for me so far, and maybe someone else might find it useful.

Thanks,

Arthur

purcell commented 2 years ago

I actually use nix and direnv for this myself (though even direnv would work out of the box with my config). There's also this package. For these reasons, I'm not sure I'd necessarily merge this PR in its current form.

purcell commented 2 years ago

To be clear, with direnv installed and the envrc package enabled, you can trivially add a .envrc file to your project which would add node_modules/.bin to $PATH.

arthurl commented 2 years ago

I actually use nix and direnv for this myself (though even direnv would work out of the box with my config). There's also this package. For these reasons, I'm not sure I'd necessarily merge this PR in its current form.

Okay, I’ll close the PR.

Regarding add-node-modules-path, that’s already used in your previous config. That doesn’t set the $PATH environment variable though, rather, it sets the exec-path emacs variable. So what I did was simply to make sure that the lsp server is started with the value of exec-path in $PATH, but without actually changing emacs’ $PATH.

purcell commented 2 years ago

That doesn’t set the $PATH environment variable though, rather, it sets the exec-path emacs variable.

Huh, interesting — it's risky to modify only one of those. Overall I can't recommend direnv highly enough for this use case and many others.

arthurl commented 2 years ago

I've been using direnv the past few days, and it's great. Way better than having separate elisp code for each language. Thanks for the tip!

purcell commented 2 years ago

Great, glad it's working for you!