purescript / spago

🍝 PureScript package manager and build tool
BSD 3-Clause "New" or "Revised" License
782 stars 132 forks source link

Usage with psc-ide-emacs #64

Closed justinwoo closed 5 years ago

justinwoo commented 5 years ago

To use spago with psc-ide-emacs, will either need to specify some user globs yourself or make a PR to psc-ide-emacs: https://github.com/epost/psc-ide-emacs

In particular, see this block for how source globs are prepared and inserted:

https://github.com/epost/psc-ide-emacs/blob/01a158b77210fec9c1bfc0caffaf08fccc0412ac/psc-ide.el#L263-L274


(defun psc-ide--server-start-globs ()
  "Detects bower and psc-package projects and determines sensible
  source globs"

  (when (and (file-exists-p "psc-package.json") (file-exists-p "bower.json"))
    (message "Detected both a \"psc-package.json\" and a \"bower.json\" file."))

  (let ((server-globs psc-ide-source-globs))

    ;; see this section specifically, which handles psc-package globs
    (if (file-exists-p "psc-package.json")                        ; first, we check for psc-package.json
        (let* ((results "*PSC-PACKAGE SOURCES*")                  ; we let stdout go to a buffer named *PSC-PACKAGE SOURCES*
               (errors "*PSC-PACKAGE ERRORS*"))                   ; stderr goes ot the errors buffer

          (shell-command "psc-package sources" results errors)    ; run the psc-package sources command

          (if (get-buffer errors)                                 ; if there's an error, display it
              (switch-to-buffer-other-window errors)
            (progn                                                ; otherwise, we can take the results and kill the results buffer
              (with-current-buffer results
                (let* ((globs (split-string (buffer-string))))
                  (setq server-globs (append server-globs globs)) ; then we set the server globs with our globs being added to it
                  (kill-buffer results)))
              (message "Set source globs from psc-package. Starting server..."))))
              ;; end of psc-package glob handling

      (if (file-exists-p "bower.json")
          (setq server-globs (append server-globs '("bower_components/purescript-*/src/**/*.purs")))
        (message "Couldn't find psc-package.json nor bower.json files, using just the user specified globs.")))
server-globs))
f-f commented 5 years ago

@justinwoo though there is psc-package sources, so I wonder if we could make this more configurable? Something like making the command configurable, or detecting spago and psc-package and just calling sources in that case?

justinwoo commented 5 years ago

Sure, it might work fine. I just wrote this information down here so someone who wants to do it knows exactly where to look after doing the whole rigmarole of local emacs package development.

f-f commented 5 years ago

Fix up here: https://github.com/purescript-emacs/psc-ide-emacs/pull/161 (thanks @vapaj!)

vapaj commented 5 years ago

Merged in: https://github.com/purescript-emacs/psc-ide-emacs/pull/164