Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/brown/bazel-mode

GNU Emacs mode for editing Bazel BUILD files
https://github.com/brown/bazel-mode

Last synced: 11 days ago
JSON representation

GNU Emacs mode for editing Bazel BUILD files

Awesome Lists containing this project

README

        

Bazel Mode
==========

Bazel Mode is a GNU Emacs major mode for editing Bazel BUILD, WORKSPACE, and
bzl files, which are written in the Starlark language.

To use Bazel Mode, add the following to your .emacs file after replacing
"/path/to/bazel-mode/directory" with the location where you installed Bazel
Mode:

(add-to-list 'load-path "/path/to/bazel-mode/directory")
(autoload 'bazel-mode "bazel-mode" "Major mode for Bazel BUILD files." t)
(add-to-list 'auto-mode-alist '("/BUILD\\(\\..*\\)?\\'" . bazel-mode))
(add-to-list 'auto-mode-alist '("/WORKSPACE\\'" . bazel-mode))
(add-to-list 'auto-mode-alist '("\\.\\(BUILD\\|WORKSPACE\\|bzl\\)\\'" . bazel-mode))

Bazel Mode supports reformatting BUILD files with buildifier. To use this
feature, you'll need to download and install buildifier, which is part of
Google's buildtools package:

git clone https://github.com/bazelbuild/buildtools.git
cd buildtools
bazel build //buildifier

and then install buildifier in some directory that's in your PATH shell
environment variable.

Once buildifier is installed, you can use it in two different ways. First,
Bazel Mode supports reformatting BUILD buffers by running bazel-format, which
is bound to the key sequence C-c C-f. Additionally, you can configure Emacs to
automatically format files with buildifier before saving them by adding the
following to your .emacs file:

(add-hook 'bazel-mode-hook
(lambda ()
(add-hook 'before-save-hook #'bazel-format nil t)))