Skip to content

Commit 16dd0c4

Browse files
Associate faces instead of colors to symbol kinds
as suggested in issue #8
1 parent e835668 commit 16dd0c4

File tree

1 file changed

+58
-58
lines changed

1 file changed

+58
-58
lines changed

lsp-ivy.el

Lines changed: 58 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -51,73 +51,73 @@
5151
:group 'lsp-ivy
5252
:type '(repeat integer))
5353

54-
(defcustom lsp-ivy-symbol-kind-to-string
55-
[(" " . "red") ;; Unknown - 0
56-
("File" . "red") ;; File - 1
57-
("Modu" . "red") ;; Module - 2
58-
("Nmsp" . "red") ;; Namespace - 3
59-
("Pack" . "red") ;; Package - 4
60-
("Clss" . "red") ;; Class - 5
61-
("Meth" . "violet") ;; Method - 6
62-
("Prop" . "violet") ;; Property - 7
63-
("Fld " . "violet") ;; Field - 8
64-
("Cons" . "red") ;; Constructor - 9
65-
("Enum" . "red") ;; Enum - 10
66-
("Intf" . "red") ;; Interface - 11
67-
("Func" . "darkgreen") ;; Function - 12
68-
("Var " . "blue") ;; Variable - 13
69-
("Cnst" . "blue") ;; Constant - 14
70-
("Str " . "blue") ;; String - 15
71-
("Num " . "blue") ;; Number - 16
72-
("Bool " . "blue") ;; Boolean - 17
73-
("Arr " . "blue") ;; Array - 18
74-
("Obj " . "blue") ;; Object - 19
75-
("Key " . "blue") ;; Key - 20
76-
("Null" . "red") ;; Null - 21
77-
("EmMm" . "violet") ;; EnumMember - 22
78-
("Srct" . "red") ;; Struct - 23
79-
("Evnt" . "red") ;; Event - 24
80-
("Op " . "red") ;; Operator - 25
81-
("TPar" . "red")] ;; TypeParameter - 26
82-
"A vector of 26 cons cells, where the ith cons cell contains the string representation and foreground color to use for the i+1th SymbolKind (defined in the LSP)"
54+
(defcustom lsp-ivy-symbol-kind-to-face
55+
[(" " . nil) ;; Unknown - 0
56+
("File" . 'font-lock-builtin-face) ;; File - 1
57+
("Modu" . 'font-lock-keyword-face) ;; Module - 2
58+
("Nmsp" . 'font-lock-keyword-face) ;; Namespace - 3
59+
("Pack" . 'font-lock-keyword-face) ;; Package - 4
60+
("Clss" . 'font-lock-type-face) ;; Class - 5
61+
("Meth" . 'font-lock-function-name-face) ;; Method - 6
62+
("Prop" . 'font-lock-reference-face) ;; Property - 7
63+
("Fld " . 'font-lock-reference-face) ;; Field - 8
64+
("Cons" . 'font-lock-function-name-face) ;; Constructor - 9
65+
("Enum" . 'font-lock-type-face) ;; Enum - 10
66+
("Intf" . 'font-lock-type-face) ;; Interface - 11
67+
("Func" . 'font-lock-function-name-face) ;; Function - 12
68+
("Var " . 'font-lock-variable-name-face) ;; Variable - 13
69+
("Cnst" . 'font-lock-constant-face) ;; Constant - 14
70+
("Str " . 'font-lock-string-face) ;; String - 15
71+
("Num " . 'font-lock-builtin-face) ;; Number - 16
72+
("Bool " . 'font-lock-builtin-face) ;; Boolean - 17
73+
("Arr " . 'font-lock-builtin-face) ;; Array - 18
74+
("Obj " . 'font-lock-builtin-face) ;; Object - 19
75+
("Key " . 'font-lock-reference-face) ;; Key - 20
76+
("Null" . 'font-lock-builtin-face) ;; Null - 21
77+
("EmMm" . 'font-lock-constant-face) ;; EnumMember - 22
78+
("Srct" . 'font-lock-type-face) ;; Struct - 23
79+
("Evnt" . 'font-lock-builtin-face) ;; Event - 24
80+
("Op " . 'font-lock-function-name-face) ;; Operator - 25
81+
("TPar" . 'font-lock-type-face)] ;; TypeParameter - 26
82+
"A vector of 26 cons cells, where the ith cons cell contains the string representation and face to use for the i+1th SymbolKind (defined in the LSP)"
8383
:group 'lsp-ivy
8484
:type '(vector
85-
(cons string color)
86-
(cons string color)
87-
(cons string color)
88-
(cons string color)
89-
(cons string color)
90-
(cons string color)
91-
(cons string color)
92-
(cons string color)
93-
(cons string color)
94-
(cons string color)
95-
(cons string color)
96-
(cons string color)
97-
(cons string color)
98-
(cons string color)
99-
(cons string color)
100-
(cons string color)
101-
(cons string color)
102-
(cons string color)
103-
(cons string color)
104-
(cons string color)
105-
(cons string color)
106-
(cons string color)
107-
(cons string color)
108-
(cons string color)
109-
(cons string color)
110-
(cons string color)
111-
(cons string color)))
85+
(cons string face)
86+
(cons string face)
87+
(cons string face)
88+
(cons string face)
89+
(cons string face)
90+
(cons string face)
91+
(cons string face)
92+
(cons string face)
93+
(cons string face)
94+
(cons string face)
95+
(cons string face)
96+
(cons string face)
97+
(cons string face)
98+
(cons string face)
99+
(cons string face)
100+
(cons string face)
101+
(cons string face)
102+
(cons string face)
103+
(cons string face)
104+
(cons string face)
105+
(cons string face)
106+
(cons string face)
107+
(cons string face)
108+
(cons string face)
109+
(cons string face)
110+
(cons string face)
111+
(cons string face)))
112112

113113

114114
(defun lsp-ivy--format-symbol-match (match)
115115
"Convert the (hash-valued) MATCH returned by `lsp-mode` into a candidate string."
116116
(let* ((container-name (gethash "containerName" match))
117117
(name (gethash "name" match))
118-
(type (elt lsp-ivy-symbol-kind-to-string (gethash "kind" match) ))
118+
(type (elt lsp-ivy-symbol-kind-to-face (gethash "kind" match) ))
119119
(typestr (if lsp-ivy-show-symbol-kind
120-
(propertize (format "[%s] " (car type)) 'face `(:foreground ,(cdr type)))
120+
(propertize (format "[%s] " (car type)) 'face (cdr type))
121121
"")))
122122
(concat typestr (if (or (null container-name) (string-empty-p container-name))
123123
(format "%s" name)

0 commit comments

Comments
 (0)