Skip to content

Instantly share code, notes, and snippets.

@ZachMassia
Created October 23, 2016 01:29
Show Gist options
  • Save ZachMassia/aed3239d1f0171c8e3faf111a18b29c6 to your computer and use it in GitHub Desktop.
Save ZachMassia/aed3239d1f0171c8e3faf111a18b29c6 to your computer and use it in GitHub Desktop.
C++ / PlatformIO setup using use-package

Add irony-mode and platformio-mode to c/c++ mode.

(use-package irony
  :ensure t
  :commands (irony-mode))

(use-package irony-eldoc
  :ensure t
  :commands (irony-eldoc))

(use-package platformio-mode
  :ensure t
  :commands (platformio-conditionally-enable)
  :config (platformio-setup-compile-buffer))

(defun irony-and-platformio-hook ()
  (irony-mode)
  (irony-eldoc)
  (platformio-conditionally-enable))

(add-hook 'c-mode-hook 'irony-and-platformio-hook)
(add-hook 'c++-mode-hook 'irony-and-platformio-hook)

Replace the completion-at-point and complete-symbol bindings in irony-mode’s buffers by the async functions.

(defun irony-use-async-ac ()
  (define-key irony-mode-map [remap completion-at-point]
    'irony-completion-at-point-async)

  (define-key irony-mode-map [remap completion-symbol]
    'irony-completion-at-point-async)
  (irony-cdb-autosetup-compile-options))

(add-hook 'irony-mode-hook 'irony-use-async-ac)

Use Flycheck with Irony.

(use-package flycheck-irony
  :ensure t
  :defer 2
  :init (add-hook 'flycheck-mode-hook #'flycheck-irony-setup))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment