Skip to content

Commit 8f0e076

Browse files
committed
Improve go-dot-work-mode font lock regexp
All the go.work keywords are bounded by the beginning of line and whitespace so we use that as our regexp boundaries instead of word/symbol boundaries.
1 parent 8dce1e3 commit 8f0e076

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

go-mode.el

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2894,6 +2894,10 @@ If BUFFER, return the number of characters in that buffer instead."
28942894
'("go" "toolchain" "use" "replace")
28952895
"All keywords for go.work files. Used for font locking.")
28962896

2897+
(defvar go-dot-work-font-lock-keywords
2898+
`((,(concat "^\\s-*\\(" (regexp-opt go-dot-work-mode-keywords t) "\\)\\s-") 1 font-lock-keyword-face))
2899+
"Keyword highlighting specification for `go-dot-work-mode'.")
2900+
28972901
;;;###autoload
28982902
(define-derived-mode go-dot-work-mode fundamental-mode "Go Work"
28992903
"A major mode for editor go.work files."
@@ -2904,7 +2908,7 @@ If BUFFER, return the number of characters in that buffer instead."
29042908
(set (make-local-variable 'comment-start-skip) "\\(//+\\)\\s *")
29052909

29062910
(set (make-local-variable 'font-lock-defaults)
2907-
'(go-dot-work-mode-keywords))
2911+
'(go-dot-work-font-lock-keywords))
29082912
(set (make-local-variable 'indent-line-function) 'go-mode-indent-line)
29092913

29102914
;; Go style

0 commit comments

Comments
 (0)