Skip to content

Account for poor formatting of error messages by SPM plugin compilation failures. #195

@dabrahams

Description

@dabrahams

Sorry I didn't deal with this earlier. Very similar to #191, I have the following to deal with this SPM issue. It would be awesome if swift-mode could handle this for me.

(defun dwa/spm-plugin-compilation-error-patch ()
  "Update the gnu error message format to account for https://github.com/apple/swift-package-manager/issues/6862."
  (let ((e (cdr (assoc 'gnu compilation-error-regexp-alist-alist)))
	(prefix "\\(?:error: plugin compilation \\)?"))

    (unless
	;; Attempt to make this modification idempotent
	(or (string-match (regexp-quote prefix) (car e))
	    ;; Don't try anything unless the regexp starts with "^".
	    (not (equal (substring (car e) 0 1) "^"))
      ; Shadow the existing alist entry; no need to modify it.
      (add-to-list
       'compilation-error-regexp-alist-alist
       ;; Inject the prefix after the "^"
       `(gnu . ,(cons (concat "^" prefix (substring (car e) 1)) (cdr e))))))))

(use-package swift-mode
  :custom
  (swift-mode:basic-offset 2)
  :mode ("\\.swift\\.gyb" . swift-mode)
  :init
  ;; Diagnostic parsing
  (require 'compile)
  (require 'compilation-smart-find)

  (add-hook 'swift-mode-hook (lambda () (setq tab-width 2)))
  (dwa/spm-plugin-compilation-error-patch)
  (dwa/swift-mode-lsp-setup))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions