Skip to content

Commit

Permalink
Ooops, I should use if instead pcase to test token-face-has-foreground
Browse files Browse the repository at this point in the history
  • Loading branch information
manateelazycat committed May 17, 2024
1 parent 2f961fe commit 72b02ec
Showing 1 changed file with 20 additions and 24 deletions.
44 changes: 20 additions & 24 deletions lsp-bridge-semantic-tokens.el
Original file line number Diff line number Diff line change
Expand Up @@ -252,31 +252,27 @@ Faces to use for semantic token modifiers.")
(cdr (aref lsp-bridge-semantic-tokens-type-modifier-faces last-modifier-face-index))
(cdr (aref lsp-bridge-semantic-tokens-type-faces (nth 3 token)))))
(token-face-has-foreground (lsp-bridge-semantic-tokens-get-face-foreground token-face)))
(pcase token-face-has-foreground
;; Override Emacs default face if token face has foreground
('override
(if last-modifier-face-index
(overlay-put ov 'face (cdr (aref lsp-bridge-semantic-tokens-type-modifier-faces last-modifier-face-index)))
(overlay-put ov 'face (cdr (aref lsp-bridge-semantic-tokens-type-faces (nth 3 token))))))
(if token-face-has-foreground
;; Override Emacs default face if token face has foreground
(if last-modifier-face-index
(overlay-put ov 'face (cdr (aref lsp-bridge-semantic-tokens-type-modifier-faces last-modifier-face-index)))
(overlay-put ov 'face (cdr (aref lsp-bridge-semantic-tokens-type-faces (nth 3 token)))))
;; Otherwise use combine policy, example token face's bold attribute combine with Emacs default face
('combine
(let ((faces-alist (cons (aref lsp-bridge-semantic-tokens-type-faces (nth 3 token))
(mapcar #'(lambda (face-index)
(aref lsp-bridge-semantic-tokens-type-modifier-faces face-index))
(nth 4 token))))
(combine-face-name "lsp-bridge-semantic-tokens-combine")
(faces))
(dolist (face-alist faces-alist)
(setq combine-face-name (concat combine-face-name "-" (car face-alist)))
(push (cdr face-alist) faces))
(let ((combine-face-symbol (intern combine-face-name)))
(unless (facep combine-face-symbol)
(make-empty-face combine-face-symbol)
(face-spec-set combine-face-symbol
(lsp-bridge-semantic-tokens--combine-faces faces)))
(overlay-put ov 'face combine-face-symbol))))
(_
(overlay-put ov 'face (cdr (aref lsp-bridge-semantic-tokens-type-faces (nth 3 token)))))))
(let ((faces-alist (cons (aref lsp-bridge-semantic-tokens-type-faces (nth 3 token))
(mapcar #'(lambda (face-index)
(aref lsp-bridge-semantic-tokens-type-modifier-faces face-index))
(nth 4 token))))
(combine-face-name "lsp-bridge-semantic-tokens-combine")
(faces))
(dolist (face-alist faces-alist)
(setq combine-face-name (concat combine-face-name "-" (car face-alist)))
(push (cdr face-alist) faces))
(let ((combine-face-symbol (intern combine-face-name)))
(unless (facep combine-face-symbol)
(make-empty-face combine-face-symbol)
(face-spec-set combine-face-symbol
(lsp-bridge-semantic-tokens--combine-faces faces)))
(overlay-put ov 'face combine-face-symbol)))))

(puthash (list current-line colum (nth 2 token) (nth 3 token) (nth 4 token))
ov lsp-bridge-semantic-tokens--overlays))))))))
Expand Down

0 comments on commit 72b02ec

Please sign in to comment.