Created
September 16, 2016 14:19
-
-
Save kchodorow/082a5175b7edcb42f0e206f19b94993d to your computer and use it in GitHub Desktop.
Emacs 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
(setq-default indent-tabs-mode nil) | |
(setq column-number-mode t) | |
(custom-set-variables | |
'(js2-global-externs (quote ("goog")))) | |
(add-hook 'js2-post-parse-callbacks | |
(lambda () | |
(let ((buf (buffer-string)) | |
(index 0)) | |
(while (string-match "\\(goog\\.require\\|goog\\.provide\\)('\\([^'.]*\\)" buf index) | |
(setq index (+ 1 (match-end 0))) | |
(add-to-list 'js2-additional-externs (match-string 2 buf)))))) | |
(add-hook 'js2-post-parse-callbacks | |
(lambda () | |
(when (> (buffer-size) 0) | |
(let ((btext (replace-regexp-in-string | |
": *true" " " | |
(replace-regexp-in-string "[\n\t ]+" " " (buffer-substring-no-properties 1 (buffer-size)) t t)))) | |
(mapc (apply-partially 'add-to-list 'js2-additional-externs) | |
(split-string | |
(if (string-match "/\\* *global *\\(.*?\\) *\\*/" btext) (match-string-no-properties 1 btext) "") | |
" *, *" t)) | |
)))) | |
(add-hook 'after-save-hook | |
(lambda() | |
(if (string-match "BUILD" (file-name-base (buffer-file-name))) | |
(progn | |
(shell-command (concat "/home/k/buildifier/bazel-bin/buildifier/buildifier " (buffer-file-name))) | |
(find-alternate-file (buffer-file-name)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment