Created
October 5, 2016 16:19
-
-
Save spott/145dae38a59bb543524f434665c5c6ee to your computer and use it in GitHub Desktop.
platformio-mode layer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(setq pio-packages | |
'( | |
(platformio-mode :toggle (configuration-layer/package-usedp 'projectile)) | |
)) | |
(defun pio/init-platformio-mode () | |
(use-package platformio-mode | |
:defer t | |
:init | |
(progn | |
(defun conditionally-enable () | |
"Enable `platformio-mode' only when a `platformio.ini' file is present in project root." | |
(condition-case nil | |
(when (projectile-verify-file "platformio.ini") | |
(platformio-mode 1)) | |
(error nil))) | |
(add-hook 'c++-mode-hook (conditionally-enable)) | |
(add-hook 'c-mode-hook (conditionally-enable))) | |
:config | |
(progn | |
(platformio-setup-compile-buffer) | |
(spacemacs/set-leader-keys-for-major-mode 'c++-mode | |
"pb" 'platformio-build | |
"pu" 'platformio-upload | |
"pp" 'platformio-programmer-upload | |
"ps" 'platformio-spiffs-upload | |
"pc" 'platformio-clean | |
"pd" 'platformio-update | |
) | |
))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
platformio-mode already provides a
platformio-conditionally-enable
function which is identical to yourconditionally-enable
here. To use it in the:init
ofuse-package
, you have to make it autoloadable using the:commands
key, like here .I am trying to create a good and complete platformio layer there, if you want you help you're welcome!