Skip to content

Commit d93fc5a

Browse files
committed
Deprecate 'semantic_tokens' config in favor of 'augmentsSyntaxTokens'
The `augmentsSyntaxTokens` client capability can be used to indicate that the client is going to combine existing syntax tokens with the semantic tokens of the server. This can not only reduce the amount of data that is transferred over the protocol but can also lead to better highlighting as syntax tokens often more accurately distinguish between different language constructs on the syntax level. An example would be keywords where the LSP protocol has a single standard token type compared to syntax highlighting where different keywords are often differentiated between based on their purpose. The 'semantic_tokens' config had been added for this purpose. The 'partial' option is used to prevent LSP semantic tokens to override existing syntax highlighting of the editor. The benefit of the client capability is that this decision is automatically made by supported editors instead of relying on user to select the right configuration.
1 parent 4aaafc2 commit d93fc5a

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"default": []
3434
},
3535
"semantic_tokens": {
36-
"description": "Set level of semantic tokens. `partial` only includes information that requires semantic analysis.",
36+
"description": "Deprecated. The client should set the 'augmentsSyntaxTokens' capability.\n\nSet level of semantic tokens. `partial` only includes information that requires semantic analysis.",
3737
"type": "string",
3838
"enum": [
3939
"none",

src/Config.zig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ enable_build_on_save: ?bool = null,
2323
/// If the `build.zig` has declared a 'check' step, it will be preferred over the default 'install' step.
2424
build_on_save_args: []const []const u8 = &.{},
2525

26+
/// Deprecated. The client should set the 'augmentsSyntaxTokens' capability.
27+
///
2628
/// Set level of semantic tokens. `partial` only includes information that requires semantic analysis.
2729
semantic_tokens: enum {
2830
none,

src/Server.zig

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ const ClientCapabilities = struct {
7272
supports_publish_diagnostics: bool = false,
7373
supports_code_action_fixall: bool = false,
7474
supports_semantic_tokens_overlapping: bool = false,
75+
semantic_tokens_augment_syntax_tokens: bool = false,
7576
hover_supports_md: bool = false,
7677
signature_help_supports_md: bool = false,
7778
completion_doc_supports_md: bool = false,
@@ -458,6 +459,7 @@ fn initializeHandler(server: *Server, arena: std.mem.Allocator, request: types.I
458459
}
459460
if (textDocument.semanticTokens) |semanticTokens| {
460461
server.client_capabilities.supports_semantic_tokens_overlapping = semanticTokens.overlappingTokenSupport orelse false;
462+
server.client_capabilities.semantic_tokens_augment_syntax_tokens = semanticTokens.augmentsSyntaxTokens orelse false;
461463
}
462464
}
463465

@@ -1254,7 +1256,7 @@ fn semanticTokensFullHandler(server: *Server, arena: std.mem.Allocator, request:
12541256
handle,
12551257
null,
12561258
server.offset_encoding,
1257-
server.config_manager.config.semantic_tokens == .partial,
1259+
server.client_capabilities.semantic_tokens_augment_syntax_tokens or server.config_manager.config.semantic_tokens == .partial,
12581260
server.client_capabilities.supports_semantic_tokens_overlapping,
12591261
);
12601262
}
@@ -1281,7 +1283,7 @@ fn semanticTokensRangeHandler(server: *Server, arena: std.mem.Allocator, request
12811283
handle,
12821284
loc,
12831285
server.offset_encoding,
1284-
server.config_manager.config.semantic_tokens == .partial,
1286+
server.client_capabilities.semantic_tokens_augment_syntax_tokens or server.config_manager.config.semantic_tokens == .partial,
12851287
server.client_capabilities.supports_semantic_tokens_overlapping,
12861288
);
12871289
}

src/tools/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
},
3333
{
3434
"name": "semantic_tokens",
35-
"description": "Set level of semantic tokens. `partial` only includes information that requires semantic analysis.",
35+
"description": "Deprecated. The client should set the 'augmentsSyntaxTokens' capability.\n\nSet level of semantic tokens. `partial` only includes information that requires semantic analysis.",
3636
"type": "enum",
3737
"enum": [
3838
"none",

0 commit comments

Comments
 (0)