Skip to content

Commit

Permalink
Improve go-dot-work-mode font lock regexp
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mssdvd committed Aug 23, 2023
1 parent 6e2f5a3 commit cf9af44
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion go-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -2894,6 +2894,10 @@ If BUFFER, return the number of characters in that buffer instead."
'("go" "toolchain" "use" "replace")
"All keywords for go.work files. Used for font locking.")

(defvar go-dot-work-font-lock-keywords
`((,(concat "^\\s-*\\(" (regexp-opt go-dot-work-mode-keywords t) "\\)\\s-") 1 font-lock-keyword-face))
"Keyword highlighting specification for `go-dot-work-mode'.")

;;;###autoload
(define-derived-mode go-dot-work-mode fundamental-mode "Go Work"
"A major mode for editor go.work files."
Expand All @@ -2904,7 +2908,7 @@ If BUFFER, return the number of characters in that buffer instead."
(set (make-local-variable 'comment-start-skip) "\\(//+\\)\\s *")

(set (make-local-variable 'font-lock-defaults)
'(go-dot-work-mode-keywords))
'(go-dot-work-font-lock-keywords))
(set (make-local-variable 'indent-line-function) 'go-mode-indent-line)

;; Go style
Expand Down

0 comments on commit cf9af44

Please sign in to comment.