Last active
August 16, 2019 01:22
-
-
Save davidwalter0/1f859a72352412096208d52b6f9154c8 to your computer and use it in GitHub Desktop.
emacs: go.mod and go.sum highlighting
This file contains hidden or 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
;;; package --- mode for go.mod files | |
;;; Commentary: | |
;;; font-lock syntax for go.mod files | |
;;; | |
(setq vgo-highlights | |
'( | |
;;; go.sum | |
("^\\([^ ]*\\) *[^ ]* h1:*[^ ]*=$" . (1 font-lock-keyword-face)) | |
("^[^ ]* *\\([^ ]*\\) h1:*\\([^ ]*=\\)$" . (1 font-lock-builtin-face)) | |
("^[^ ]* *[^ ]* h1:*\\([^ ]*=\\)$" . (1 font-lock-function-name-face)) | |
("^[^ ]* *[^ ]* h1\\(:\\)*[^ ]*=$" . (1 font-lock-comment-face)) | |
("^[^ ]* *[^ ]* \\(h1\\)*[^ ]*=$" . (1 font-lock-function-name-face)) | |
;; go.mod | |
("\\()\\).*$" . (1 font-lock-comment-face)) | |
("\\((\\).*$" . (1 font-lock-comment-face)) | |
("\\(=>\\).*$" . (1 font-lock-comment-face)) | |
("\\(//.*\\)$" . (1 font-lock-comment-face)) | |
("=> *\\([^ ]*\\) *.*$" . (1 font-lock-keyword-face)) | |
("^\\(module\\|require\\|exclude\\|replace\\|go\\)" . font-lock-function-name-face) | |
("\\([^ ]*\\) *=> *\\([^ ]*\\) *.*$" . (1 font-lock-keyword-face)) | |
("^require *\\([^ ]*\\) *[^ ]* *.*$" . (1 font-lock-keyword-face)) | |
("^require *[^ ]* *\\([^ ]*\\) *.*$" . (1 font-lock-builtin-face)) | |
("^exclude *\\([^ ]*\\) *[^ ]* *.*$" . (1 font-lock-keyword-face)) | |
("^exclude *[^ ]* *\\([^ ]*\\) *.*$" . (1 font-lock-builtin-face)) | |
("^.* => *[^ ]* *\\([^ ]*\\)$" . (1 font-lock-builtin-face)) | |
("^\t*\\([^ ]*\\).*//.*$" . (1 font-lock-keyword-face)) | |
("^\t*\\([^ ]*\\).*$" . (1 font-lock-keyword-face)) | |
("^\t*[^ ]* *\\([^ ]*\\) *//.*$" . (1 font-lock-builtin-face)) | |
("^\t*[^ ]* *\\([^ ]*\\)$" . (1 font-lock-builtin-face)) | |
)) | |
(define-derived-mode vgo-mode fundamental-mode "vgo" | |
"major mode for editing vgo language code." | |
(setq font-lock-defaults '(vgo-highlights))) | |
;;; (delete '("\\.mod$\\'" . vgo-mode) auto-mode-alist) | |
(add-to-list 'auto-mode-alist '("\\go\.mod\\'" . vgo-mode)) | |
(add-to-list 'auto-mode-alist '("\\go\.sum\\'" . vgo-mode)) | |
(provide 'vgo-mode) |
Author
davidwalter0
commented
Aug 16, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment