mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
Enable the SemanticTokensFeature by default
This is covered under vscode's "editor.semanticHighlighting.enabled" setting plus the user has to have a theme that has opted into highlighting. Bumps required vscode stable to 1.44
This commit is contained in:
parent
779555c1be
commit
6f0f86d2c5
4 changed files with 8 additions and 18 deletions
|
@ -21,7 +21,7 @@
|
||||||
"Programming Languages"
|
"Programming Languages"
|
||||||
],
|
],
|
||||||
"engines": {
|
"engines": {
|
||||||
"vscode": "^1.43.0"
|
"vscode": "^1.44.0"
|
||||||
},
|
},
|
||||||
"enableProposedApi": true,
|
"enableProposedApi": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -342,11 +342,6 @@
|
||||||
"default": true,
|
"default": true,
|
||||||
"description": "Show function name and docs in parameter hints"
|
"description": "Show function name and docs in parameter hints"
|
||||||
},
|
},
|
||||||
"rust-analyzer.highlighting.semanticTokens": {
|
|
||||||
"type": "boolean",
|
|
||||||
"default": false,
|
|
||||||
"description": "Use proposed semantic tokens API for syntax highlighting"
|
|
||||||
},
|
|
||||||
"rust-analyzer.updates.channel": {
|
"rust-analyzer.updates.channel": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"enum": [
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
import * as lc from 'vscode-languageclient';
|
import * as lc from 'vscode-languageclient';
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
|
|
||||||
import { Config } from './config';
|
|
||||||
import { CallHierarchyFeature } from 'vscode-languageclient/lib/callHierarchy.proposed';
|
import { CallHierarchyFeature } from 'vscode-languageclient/lib/callHierarchy.proposed';
|
||||||
import { SemanticTokensFeature, DocumentSemanticsTokensSignature } from 'vscode-languageclient/lib/semanticTokens.proposed';
|
import { SemanticTokensFeature, DocumentSemanticsTokensSignature } from 'vscode-languageclient/lib/semanticTokens.proposed';
|
||||||
|
|
||||||
export async function createClient(config: Config, serverPath: string, cwd: string): Promise<lc.LanguageClient> {
|
export async function createClient(serverPath: string, cwd: string): Promise<lc.LanguageClient> {
|
||||||
// '.' Is the fallback if no folder is open
|
// '.' Is the fallback if no folder is open
|
||||||
// TODO?: Workspace folders support Uri's (eg: file://test.txt).
|
// TODO?: Workspace folders support Uri's (eg: file://test.txt).
|
||||||
// It might be a good idea to test if the uri points to a file.
|
// It might be a good idea to test if the uri points to a file.
|
||||||
|
@ -73,15 +72,12 @@ export async function createClient(config: Config, serverPath: string, cwd: stri
|
||||||
};
|
};
|
||||||
|
|
||||||
// To turn on all proposed features use: res.registerProposedFeatures();
|
// To turn on all proposed features use: res.registerProposedFeatures();
|
||||||
// Here we want to just enable CallHierarchyFeature since it is available on stable.
|
// Here we want to enable CallHierarchyFeature and SemanticTokensFeature
|
||||||
// Note that while the CallHierarchyFeature is stable the LSP protocol is not.
|
// since they are available on stable.
|
||||||
|
// Note that while these features are stable in vscode their LSP protocol
|
||||||
|
// implementations are still in the "proposed" category for 3.16.
|
||||||
res.registerFeature(new CallHierarchyFeature(res));
|
res.registerFeature(new CallHierarchyFeature(res));
|
||||||
|
res.registerFeature(new SemanticTokensFeature(res));
|
||||||
if (config.package.enableProposedApi) {
|
|
||||||
if (config.highlightingSemanticTokens) {
|
|
||||||
res.registerFeature(new SemanticTokensFeature(res));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,6 @@ export class Config {
|
||||||
get serverPath() { return this.cfg.get<null | string>("serverPath")!; }
|
get serverPath() { return this.cfg.get<null | string>("serverPath")!; }
|
||||||
get channel() { return this.cfg.get<UpdatesChannel>("updates.channel")!; }
|
get channel() { return this.cfg.get<UpdatesChannel>("updates.channel")!; }
|
||||||
get askBeforeDownload() { return this.cfg.get<boolean>("updates.askBeforeDownload")!; }
|
get askBeforeDownload() { return this.cfg.get<boolean>("updates.askBeforeDownload")!; }
|
||||||
get highlightingSemanticTokens() { return this.cfg.get<boolean>("highlighting.semanticTokens")!; }
|
|
||||||
get traceExtension() { return this.cfg.get<boolean>("trace.extension")!; }
|
get traceExtension() { return this.cfg.get<boolean>("trace.extension")!; }
|
||||||
|
|
||||||
get inlayHints() {
|
get inlayHints() {
|
||||||
|
|
|
@ -21,7 +21,7 @@ export class Ctx {
|
||||||
serverPath: string,
|
serverPath: string,
|
||||||
cwd: string,
|
cwd: string,
|
||||||
): Promise<Ctx> {
|
): Promise<Ctx> {
|
||||||
const client = await createClient(config, serverPath, cwd);
|
const client = await createClient(serverPath, cwd);
|
||||||
const res = new Ctx(config, extCtx, client, serverPath);
|
const res = new Ctx(config, extCtx, client, serverPath);
|
||||||
res.pushCleanup(client.start());
|
res.pushCleanup(client.start());
|
||||||
await client.onReady();
|
await client.onReady();
|
||||||
|
|
Loading…
Reference in a new issue