Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flycheck arguments #12

Open
ghost opened this issue Jun 26, 2016 · 1 comment
Open

Fix flycheck arguments #12

ghost opened this issue Jun 26, 2016 · 1 comment

Comments

@ghost
Copy link

ghost commented Jun 26, 2016

With the new crystal the arguments passed should be probably be compile --no-color --no-codegen instead of compile build --no-build --no-color

However, probably one should use the json output together with json.el or so to get accurate error information

Actually, as a quick hack the following might work

(require 'json)

(flycheck-define-checker crystal-build
  "A Crystal syntax checker using crystal build"
  :command ("crystal"
            "compile"
            "--no-codegen"
            "--no-color"
            "--format" "json"
            source-inplace)
  :error-parser
  (lambda (output checker buffer)
    (mapcar (lambda (err)
              (flycheck-error-new :buffer buffer
                                  :checker checker
                                  :filename (cdr-safe (assoc 'file err))
                                  :line (cdr-safe (assoc 'line err))
                                  :column (cdr-safe (assoc 'column err))
                                  :level 'error
                                  :message (cdr-safe (assoc 'message err))))
            (append nil (json-read-from-string output))))
  :modes crystal-mode
  )
@ghost
Copy link
Author

ghost commented Nov 24, 2016

Actually, something changed in the meantime. The command is called "build" again but I need some safeguard against output being an empty string (because json-read-from-string signals an error in that case).

(require 'json)

(flycheck-define-checker crystal-build
  "A Crystal syntax checker using crystal build"
  :command ("crystal"
            "build"
            "--no-codegen"
            "--no-color"
            "--format" "json"
            source-inplace)
  :error-parser
  (lambda (output checker buffer)
    (mapcar (lambda (err)
              (flycheck-error-new :buffer buffer
                                  :checker checker
                                  :filename (cdr-safe (assoc 'file err))
                                  :line (cdr-safe (assoc 'line err))
                                  :column (cdr-safe (assoc 'column err))
                                  :level 'error
                                  :message (cdr-safe (assoc 'message err))))
            (append nil (and output
                             (not (zerop (length output)))
                             (json-read-from-string output)))))
  :modes crystal-mode
  )

elthariel pushed a commit to elthariel/emacs-crystal-mode that referenced this issue May 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants