[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/scala-mode 3953269 127/217: Tweaked syntax rules to make h
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/scala-mode 3953269 127/217: Tweaked syntax rules to make highlighting more customizeable |
Date: |
Sun, 29 Aug 2021 11:30:57 -0400 (EDT) |
branch: elpa/scala-mode
commit 3953269c5147f3d2c9cce0fdf4c1dd474d6f6611
Author: Jim Powers <jim@corruptmemory.com>
Commit: Jim Powers <jim@corruptmemory.com>
Tweaked syntax rules to make highlighting more customizeable
---
scala-mode2-fontlock.el | 133 ++++++++++++++++++++++++++++++++++++++----------
scala-mode2-syntax.el | 53 ++++++++++++++++++-
2 files changed, 158 insertions(+), 28 deletions(-)
diff --git a/scala-mode2-fontlock.el b/scala-mode2-fontlock.el
index 1da043d..07e3858 100644
--- a/scala-mode2-fontlock.el
+++ b/scala-mode2-fontlock.el
@@ -320,6 +320,14 @@ Does not continue past limit.
;; syntax propertize
`(;; keywords
+ (,scala-syntax:override-re 2 scala-font-lock:override-face)
+ (,scala-syntax:abstract-re 2 scala-font-lock:abstract-face)
+ (,scala-syntax:final-re 2 scala-font-lock:final-face)
+ (,scala-syntax:sealed-re 2 scala-font-lock:sealed-face)
+ (,scala-syntax:implicit-re 2 scala-font-lock:implicit-face)
+ (,scala-syntax:lazy-re 2 scala-font-lock:lazy-face)
+ (,scala-syntax:private-re 2 scala-font-lock:private-face)
+ (,scala-syntax:protected-re 2 scala-font-lock:protected-face)
(,scala-syntax:other-keywords-re 2 font-lock-keyword-face)
(,scala-syntax:value-keywords-re 2 font-lock-constant-face)
(,scala-syntax:path-keywords-re 2 font-lock-keyword-face)
@@ -329,7 +337,7 @@ Does not continue past limit.
;; Annotations
(, (rx (and "@" (in "a-zA-Z_.") (0+ (in "a-zA-Z0-9_."))))
- . font-lock-preprocessor-face)
+ . font-lock-preprocessor-face)
;; reserved symbols
(scala-font-lock:mark-reserved-symbols 2 font-lock-keyword-face)
@@ -423,70 +431,70 @@ Does not continue past limit.
(group "extends")
(1+ space)
(group (or
- (and (in "a-zA-Z_")
- (0+ (in "a-zA-Z0-9_"))
- (\? (and "_" (1+ (in "!#%&*+-/:<=>?@\\^|~")))))
- (1+ (in "!#%&*+-/:<=>?@\\^|~")))))
- (1 font-lock-keyword-face) (2 font-lock-type-face))
+ (and (in "a-zA-Z_")
+ (0+ (in "a-zA-Z0-9_"))
+ (\? (and "_" (1+ (in "!#%&*+-/:<=>?@\\^|~")))))
+ (1+ (in "!#%&*+-/:<=>?@\\^|~")))))
+ (1 font-lock-keyword-face) (2 font-lock-type-face))
;; with followed by type
(,(rx symbol-start
(group "with")
(1+ space)
(group (or
- (and (in "a-zA-Z_")
- (0+ (in "a-zA-Z0-9_"))
- (\? (and "_" (1+ (in "!#%&*+-/:<=>?@\\^|~")))))
- (1+ (in "!#%&*+-/:<=>?@\\^|~")))))
- (1 font-lock-keyword-face) (2 font-lock-type-face))
+ (and (in "a-zA-Z_")
+ (0+ (in "a-zA-Z0-9_"))
+ (\? (and "_" (1+ (in "!#%&*+-/:<=>?@\\^|~")))))
+ (1+ (in "!#%&*+-/:<=>?@\\^|~")))))
+ (1 font-lock-keyword-face) (2 font-lock-type-face))
;; new followed by type
(,(rx symbol-start
(group "new")
(1+ space)
(group (or
- (and (in "a-zA-Z_")
- (0+ (in "a-zA-Z0-9_"))
- (\? (and "_" (1+ (in "!#%&*+-/:<=>?@\\^|~")))))
- (1+ (in "!#%&*+-/:<=>?@\\^|~")))))
- (1 font-lock-keyword-face) (2 font-lock-type-face))
+ (and (in "a-zA-Z_")
+ (0+ (in "a-zA-Z0-9_"))
+ (\? (and "_" (1+ (in "!#%&*+-/:<=>?@\\^|~")))))
+ (1+ (in "!#%&*+-/:<=>?@\\^|~")))))
+ (1 font-lock-keyword-face) (2 font-lock-type-face))
;; uppercase means a type or object
(,(rx symbol-start
- (and (in "A-Z")
+ (and (in "A-Z")
(0+ (in "a-zA-Z0-9_"))
(\? (and "_" (1+ (in "!#%&*+-/:<=>?@\\^|~"))))))
. font-lock-constant-face)
;; . font-lock-type-face)
- ; uncomment this to go back to highlighting objects as types
+ ; uncomment this to go back to
highlighting objects as types
;; uppercase
(,(rx symbol-start
(group
(and (in "A-Z")
- (0+ (in "a-zA-Z0-9_"))
- (\? (and "_" (1+ (in "!#%&*+-/:<=>?@\\^|~")))))))
+ (0+ (in "a-zA-Z0-9_"))
+ (\? (and "_" (1+ (in "!#%&*+-/:<=>?@\\^|~")))))))
. font-lock-constant-face)
;; package name
(,(rx symbol-start
- (group "package")
- (1+ space)
- (group (and (in "a-zA-Z_.") (0+ (in "a-zA-Z0-9_.")))))
+ (group "package")
+ (1+ space)
+ (group (and (in "a-zA-Z_.") (0+ (in "a-zA-Z0-9_.")))))
(1 font-lock-keyword-face) (2 font-lock-string-face))
;; number literals (have to be here so that other rules take precedence)
(scala-font-lock:mark-floatingPointLiteral . font-lock-constant-face)
(scala-font-lock:mark-integerLiteral . font-lock-constant-face)
-))
+ ))
(defun scala-font-lock:syntactic-face-function (state)
"Return correct face for string or comment"
(if (and (integerp (nth 4 state))
- (save-excursion
- (goto-char (nth 8 state))
- (looking-at "/\\*\\*\\($\\|[^*]\\)")))
+ (save-excursion
+ (goto-char (nth 8 state))
+ (looking-at "/\\*\\*\\($\\|[^*]\\)")))
;; scaladoc (starts with /** only)
font-lock-doc-face
(if (nth 3 state) font-lock-string-face font-lock-comment-face)))
@@ -499,5 +507,76 @@ Does not continue past limit.
(defvar scala-font-lock:var-face 'scala-font-lock:var-face
"Face for scala variable names.")
+(defface scala-font-lock:private-face
+ '((t (:inherit font-lock-builtin-face)))
+ "Font Lock mode face used for the private keyword."
+ :group 'scala)
+
+(defvar scala-font-lock:private-face 'scala-font-lock:private-face
+ "Face for the scala private keyword.")
+
+(defface scala-font-lock:protected-face
+ '((t (:inherit font-lock-builtin-face)))
+ "Font Lock mode face used for the protected keyword."
+ :group 'scala)
+
+(defvar scala-font-lock:protected-face 'scala-font-lock:protected-face
+ "Face for the scala protected keyword.")
+
+(defface scala-font-lock:override-face
+ '((t (:inherit font-lock-builtin-face)))
+ "Font Lock mode face used for the override keyword."
+ :group 'scala)
+
+(defvar scala-font-lock:override-face 'scala-font-lock:override-face
+ "Face for the scala override keyword.")
+
+(defface scala-font-lock:sealed-face
+ '((t (:inherit font-lock-builtin-face)))
+ "Font Lock mode face used for the sealed keyword."
+ :group 'scala)
+
+(defvar scala-font-lock:sealed-face 'scala-font-lock:sealed-face
+ "Face for the scala sealed keyword.")
+
+(defface scala-font-lock:abstract-face
+ '((t (:inherit font-lock-builtin-face)))
+ "Font Lock mode face used for the abstract keyword."
+ :group 'scala)
+
+(defvar scala-font-lock:abstract-face 'scala-font-lock:abstract-face
+ "Face for the scala abstract keyword.")
+
+(defface scala-font-lock:final-face
+ '((t (:inherit font-lock-builtin-face)))
+ "Font Lock mode face used for the final keyword."
+ :group 'scala)
+
+(defvar scala-font-lock:final-face 'scala-font-lock:final-face
+ "Face for the scala final keyword.")
+
+(defface scala-font-lock:implicit-face
+ '((t (:inherit font-lock-builtin-face)))
+ "Font Lock mode face used for the implicit keyword."
+ :group 'scala)
+
+(defvar scala-font-lock:implicit-face 'scala-font-lock:implicit-face
+ "Face for the scala implicit keyword.")
+
+(defface scala-font-lock:lazy-face
+ '((t (:inherit font-lock-builtin-face)))
+ "Font Lock mode face used for the lazy keyword."
+ :group 'scala)
+
+(defvar scala-font-lock:lazy-face 'scala-font-lock:lazy-face
+ "Face for the scala lazy keyword.")
+
+(defface scala-font-lock:var-keyword-face
+ '((t (:inherit font-lock-keyword-face)))
+ "Font Lock mode face used for the var keyword."
+ :group 'scala)
+
+(defvar scala-font-lock:var-keyword-face 'scala-font-lock:var-keyword-face
+ "Face for the scala var keyword.")
(provide 'scala-mode2-fontlock)
diff --git a/scala-mode2-syntax.el b/scala-mode2-syntax.el
index 93f4979..38c4342 100644
--- a/scala-mode2-syntax.el
+++ b/scala-mode2-syntax.el
@@ -319,10 +319,61 @@
"\\(" scala-syntax:after-reserved-symbol-re "\\)"))
-(defconst scala-syntax:modifiers-re
+(defconst scala-syntax:override-unsafe-re
+ (regexp-opt '("override") 'words))
+
+(defconst scala-syntax:override-re
+ (concat "\\(^\\|[^`]\\)\\(" scala-syntax:override-unsafe-re "\\)"))
+
+(defconst scala-syntax:abstract-unsafe-re
+ (regexp-opt '("abstract") 'words))
+
+(defconst scala-syntax:abstract-re
+ (concat "\\(^\\|[^`]\\)\\(" scala-syntax:abstract-unsafe-re "\\)"))
+
+(defconst scala-syntax:final-unsafe-re
+ (regexp-opt '("final") 'words))
+
+(defconst scala-syntax:final-re
+ (concat "\\(^\\|[^`]\\)\\(" scala-syntax:final-unsafe-re "\\)"))
+
+(defconst scala-syntax:sealed-unsafe-re
+ (regexp-opt '("sealed") 'words))
+
+(defconst scala-syntax:sealed-re
+ (concat "\\(^\\|[^`]\\)\\(" scala-syntax:sealed-unsafe-re "\\)"))
+
+(defconst scala-syntax:implicit-unsafe-re
+ (regexp-opt '("implicit") 'words))
+
+(defconst scala-syntax:implicit-re
+ (concat "\\(^\\|[^`]\\)\\(" scala-syntax:implicit-unsafe-re "\\)"))
+
+(defconst scala-syntax:lazy-unsafe-re
+ (regexp-opt '("lazy") 'words))
+
+(defconst scala-syntax:lazy-re
+ (concat "\\(^\\|[^`]\\)\\(" scala-syntax:lazy-unsafe-re "\\)"))
+
+(defconst scala-syntax:private-unsafe-re
+ (regexp-opt '("private") 'words))
+
+(defconst scala-syntax:private-re
+ (concat "\\(^\\|[^`]\\)\\(" scala-syntax:private-unsafe-re "\\)"))
+
+(defconst scala-syntax:protected-unsafe-re
+ (regexp-opt '("protected") 'words))
+
+(defconst scala-syntax:protected-re
+ (concat "\\(^\\|[^`]\\)\\(" scala-syntax:protected-unsafe-re "\\)"))
+
+(defconst scala-syntax:modifiers-unsafe-re
(regexp-opt '("override" "abstract" "final" "sealed" "implicit" "lazy"
"private" "protected") 'words))
+(defconst scala-syntax:modifiers-re
+ (concat "\\(^\\|[^`]\\)\\(" scala-syntax:modifiers-unsafe-re "\\)"))
+
(defconst scala-syntax:body-start-re
(concat "=" scala-syntax:end-of-code-line-re)
"A regexp for detecting if a line ends with '='")
- [nongnu] elpa/scala-mode 9cfc522 110/217: fix to scala-indent:fix-line, (continued)
- [nongnu] elpa/scala-mode 9cfc522 110/217: fix to scala-indent:fix-line, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode cc5b9b0 116/217: typo fix: ident vs. indent, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 0c39da9 114/217: upgraded version to 0.22 since we added new functionality required by sbt-mode, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode df36b5c 117/217: fix README.md text, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode c21f88f 124/217: Merge pull request #61 from nicferrier/marmalade, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode f431bb3 123/217: remove the attempt at checking executables, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 13ad3ac 132/217: Added Jim Powers to list of contributors, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode d27a39b 130/217: added Tillmann Rendel to the list of commiters, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode f5280ad 137/217: forward-token for #75, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode e6967f7 154/217: Add Ivan Malison as a contributor., ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 3953269 127/217: Tweaked syntax rules to make highlighting more customizeable,
ELPA Syncer <=
- [nongnu] elpa/scala-mode c0842f6 157/217: Use cl functions to avoid mapcan missing error., ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode d1fbe2d 171/217: Implemented prettify/conceal with a base set of rules. (#108), ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 2e8fd35 180/217: Fix for fill-paragraph with prefix arg. Fixes #125. (#126), ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 7e63002 182/217: Add "inline" keyword from scalameta (#128), ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 1357eba 183/217: Fix for #94, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 730e16d 186/217: Merge pull request #130 from ensime/fix/120, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 1dd5825 085/217: Added comment syntax for bash preambles (#!...!#) in scala script files, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 16d6f36 067/217: Added a not to README about font-lock-doc-face, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode b55ca83 066/217: Merge pull request #23 from hvesalai/issue22, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode aa38dae 083/217: Fixes #38: 100% CPU usage for multi-line strings in some cases., ELPA Syncer, 2021/08/29