Skip to content

Commit b2e5438

Browse files
authored
Provide better Ada semantic highlighting defaults. (#4321)
The Ada Language Server provides numerous semantic token modifiers that can be used, but most of the modifiers should not affect the original base token face. This change provides a mechanism to customize the faces associated with semantic tokens and modifiers that are applied to the buffer, while also providing better defaults for out-of-the-box usage.
1 parent 8105218 commit b2e5438

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

CHANGELOG.org

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
* Add Autotools support
105105
* Add Jsonnet support
106106
* Add support for ~ada-ts-mode~.
107+
* Allow customizing Ada semantic token and token modifier faces.
107108
** Release 8.0.0
108109
* Add ~lsp-clients-angular-node-get-prefix-command~ to get the Angular server from another location which is still has ~/lib/node_modules~ in it.
109110
* Set ~lsp-clients-angular-language-server-command~ after the first connection to speed up subsequent connections.

clients/lsp-ada.el

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
;;; Code:
2626

2727
(require 'lsp-mode)
28+
(require 'lsp-semantic-tokens)
2829

2930
(defgroup lsp-ada nil
3031
"Settings for Ada Language Server."
@@ -68,6 +69,31 @@
6869
:group 'lsp-ada
6970
:package-version '(lsp-mode "8.0.1"))
7071

72+
(defcustom lsp-ada-semantic-token-face-overrides
73+
'(("namespace" . default)
74+
("modifier" . lsp-face-semhl-keyword))
75+
"Semantic token face overrides to be applied."
76+
:type '(alist :key-type string
77+
:value-type (choice (face :tag "Face")
78+
(const :tag "No Face" nil)))
79+
:group 'lsp-ada
80+
:package-version '(lsp-mode "8.0.1"))
81+
82+
(defcustom lsp-ada-semantic-token-modifier-face-overrides
83+
'(("declaration")
84+
("definition")
85+
("implementation")
86+
("static")
87+
("modification")
88+
("documentation")
89+
("defaultLibrary"))
90+
"Semantic token modifier face overrides to be applied."
91+
:type '(alist :key-type string
92+
:value-type (choice (face :tag "Face")
93+
(const :tag "No Face" nil)))
94+
:group 'lsp-ada
95+
:package-version '(lsp-mode "8.0.1"))
96+
7197
(defun lsp-ada--environment ()
7298
"Add environmental variables if needed."
7399
(let ((project-root (lsp-workspace-root)))
@@ -96,6 +122,8 @@
96122
(with-lsp-workspace workspace
97123
(lsp--set-configuration
98124
(lsp-configuration-section "ada"))))
125+
:semantic-tokens-faces-overrides `( :types ,lsp-ada-semantic-token-face-overrides
126+
:modifiers ,lsp-ada-semantic-token-modifier-face-overrides)
99127
:server-id 'ada-ls
100128
:synchronize-sections '("ada")
101129
:environment-fn 'lsp-ada--environment))

0 commit comments

Comments
 (0)