[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/typescript-mode 1bafd279cf 148/222: Enable more colors (#1
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/typescript-mode 1bafd279cf 148/222: Enable more colors (#110) |
Date: |
Sun, 6 Feb 2022 16:59:28 -0500 (EST) |
branch: elpa/typescript-mode
commit 1bafd279cf5161476aa540267ea0a45684749cbd
Author: Ari Miller <arimiller92@gmail.com>
Commit: Jostein Kjønigsen <jostein@kjonigsen.net>
Enable more colors (#110)
* primitive function call highlighting
* arrow function parameters
* better type hint
* generics and decorator
* extend function call regexp for generics
This closes #79.
---
typescript-mode.el | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 71 insertions(+), 3 deletions(-)
diff --git a/typescript-mode.el b/typescript-mode.el
index 178e4283c8..4a91d5f313 100644
--- a/typescript-mode.el
+++ b/typescript-mode.el
@@ -270,7 +270,7 @@ Match group 1 is MUMBLE.")
"private" "protected" "public" "readonly" "return" "set" "static" "string"
"super" "switch" "this" "throw" "true"
"try" "type" "typeof" "unknown" "var" "void"
- "while")) ; yield is handled separately
+ "while")) ; yield is handled separately
"Regexp matching any typescript keyword.")
(defconst typescript--basic-type-re
@@ -278,12 +278,35 @@ Match group 1 is MUMBLE.")
'("any" "bool" "boolean" "bigint" "never" "number" "string" "unknown"
"void"))
"Regular expression matching any predefined type in typescript.")
+(defconst typescript--access-modifier-re
+ (typescript--regexp-opt-symbol
+ '("private" "protected" "public" "readonly" "static" "extends"
"implements"))
+ "Regular expression matching access modifiers.")
+
+(defconst typescript--generic-type-re
+ "<\\(.*\\)>"
+ "Regular expression matching generic types.")
+
+(defconst typescript--generic-type-extended-re
+ (concat "<\\(.*\\)extends\\(.*\\)>")
+ "Regular expression matching generic types with extension.")
+
+(defconst typescript--decorator-re
+ (concat "\\(@" typescript--name-re "\\)"))
+
(defconst typescript--constant-re
(typescript--regexp-opt-symbol '("false" "null" "undefined"
"Infinity" "NaN"
"true" "arguments" "this"))
"Regular expression matching any future reserved words in typescript.")
+(defconst typescript--builtin-re
+ (typescript--regexp-opt-symbol
+ '("console"))
+ "Regular expression matching builtins.")
+
+(defconst typescript--function-call-re "\\(\\w+\\)\\(<.+>\\)?\s*("
+ "Regular expression matching function calls.")
(defconst typescript--font-lock-keywords-1
(list
@@ -592,6 +615,21 @@ Match group 1 is MUMBLE.")
"Face used to highlight tag values in jsdoc comments."
:group 'typescript)
+(defface typescript-access-modifier-face
+ '((t (:inherit font-lock-keyword-face)))
+ "Face used to highlight access modifiers."
+ :group 'typescript)
+
+(defface typescript-this-face
+ '((t (:inherit font-lock-keyword-face)))
+ "Face used to highlight 'this' keyword."
+ :group 'typescript)
+
+(defface typescript-primitive-face
+ '((t (:inherit font-lock-keyword-face)))
+ "Face used to highlight builtin types."
+ :group 'typescript)
+
;;; User Customization
(defgroup typescript nil
@@ -1966,10 +2004,40 @@ This performs fontification according to
`typescript--class-styles'."
return t
else do (goto-char orig-end)))
+(defconst typescript--font-lock-keywords-4
+ `(
+ ;; highlights that override previous levels
+ ;;
+
+ ;; special highlight for `this' keyword
+ ("\\(this\\)\\."
+ (1 'typescript-this-face))
+
+ (,typescript--access-modifier-re (1 'typescript-access-modifier-face))
+ (,typescript--basic-type-re (1 'typescript-primitive-face))
+
+ ;; highlights that append to previous levels
+ ;;
+ ,@typescript--font-lock-keywords-3
+
+ (,typescript--decorator-re (1 font-lock-function-name-face))
+ (,typescript--function-call-re (1 font-lock-function-name-face))
+ (,typescript--builtin-re (1 font-lock-type-face))
+
+ (,typescript--generic-type-re (1 font-lock-type-face))
+ (,typescript--generic-type-extended-re (1 font-lock-type-face))
+
+ ;; arrow function
+ ("\\(=>\\)"
+ (1 font-lock-keyword-face))
+ )
+ "Level four font lock for `typescript-mode'.")
+
(defconst typescript--font-lock-keywords
- '(typescript--font-lock-keywords-3 typescript--font-lock-keywords-1
+ '(typescript--font-lock-keywords-4 typescript--font-lock-keywords-1
typescript--font-lock-keywords-2
- typescript--font-lock-keywords-3)
+ typescript--font-lock-keywords-3
+ typescript--font-lock-keywords-4)
"Font lock keywords for `typescript-mode'. See `font-lock-keywords'.")
;;; Propertize
- [nongnu] elpa/typescript-mode 9ad892fb22 061/222: Add keyword 'object', (continued)
- [nongnu] elpa/typescript-mode 9ad892fb22 061/222: Add keyword 'object', ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode e3d2fee6de 004/222: unnecessary for single package file, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 7e8b9641ae 096/222: Mark typescript indent variables as safe for file local customizations, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 813cf4fef3 069/222: Fix endless loop (hang) in indentation-code., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode cebfe5952b 114/222: Rename the regexp matching pretty error messages., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 5d5c611e2d 119/222: Add tags in js2-mode, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode e608305ade 137/222: checkdoc fixes, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 85504ce34b 138/222: Update build-badge URL., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode f6330f420e 144/222: Add a test for #107., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode c1aa1b2e7d 149/222: add better generics highlighting, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 1bafd279cf 148/222: Enable more colors (#110),
ELPA Syncer <=
- [nongnu] elpa/typescript-mode 607897d583 151/222: Update Emacs Git to Xenial-build, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 42b366e669 153/222: Merge pull request #111 from tam5/master, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 2405090403 152/222: Handle CI-failures correctly., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 895cd7f425 173/222: Fix indentation infinite looping, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 9db704ec1f 185/222: Fix duplicate test name, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 4832652496 163/222: Support electric-layout-mode., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 710f5425a4 189/222: Add tests for typescript-indent-list-items option, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 1fd835e7f8 205/222: Fix typos in README, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 30391a518a 079/222: Fix indentation issue with conditional operators., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 2d382d8bfb 053/222: Support rule names and severity in tslint reports., ELPA Syncer, 2022/02/06