Last active
December 14, 2017 04:28
-
-
Save sigma/2482d9a5eaaded909705670a1fc567db to your computer and use it in GitHub Desktop.
#emacs #bazel config
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
(use-package bazel | |
:mode ("BUILD\\|WORKSPACE\\|CROSSTOOL\\|\\.bazel\\'" . bazel-mode) | |
:config | |
(add-hook 'bazel-mode-hook 'bazel-install-reformat)) |
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
;;; bazel.el --- major mode for bazel files edition -*- lexical-binding: t; -*- | |
;; Copyright (C) 2017 Yann Hodique | |
;; Author: Yann Hodique <[email protected]> | |
;; Keywords: | |
;; This program is free software; you can redistribute it and/or modify | |
;; it under the terms of the GNU General Public License as published by | |
;; the Free Software Foundation, either version 3 of the License, or | |
;; (at your option) any later version. | |
;; This program is distributed in the hope that it will be useful, | |
;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
;; GNU General Public License for more details. | |
;; You should have received a copy of the GNU General Public License | |
;; along with this program. If not, see <http://www.gnu.org/licenses/>. | |
;;; Commentary: | |
;; | |
;;; Code: | |
(eval-after-load 'python | |
'(define-derived-mode bazel-mode python-mode "Bazel" | |
"Major mode for Bazel files" | |
nil)) | |
(defvar bazel-buildifier "buildifier") | |
(defun bazel-install-reformat () | |
(add-hook 'before-save-hook 'bazel-format-code t t)) | |
(defun bazel-format-code () | |
(interactive) | |
(let ((pos (point))) | |
(unwind-protect | |
(call-process-region (point-min) (point-max) | |
bazel-buildifier t (list t nil) nil | |
"-mode=fix")) | |
(goto-char pos))) | |
(provide 'bazel) | |
;;; bazel.el ends here |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment