align command naming

This commit is contained in:
Aleksey Kladov
2019-01-28 14:43:07 +03:00
parent 7abe1f422c
commit d1a67c1174
18 changed files with 94 additions and 77 deletions

View File

@@ -1,7 +1,7 @@
import * as vscode from 'vscode';
import { Server } from '../server';
const statusUri = vscode.Uri.parse('ra-lsp-status://status');
const statusUri = vscode.Uri.parse('rust-analyzer-status://status');
export class TextDocumentContentProvider
implements vscode.TextDocumentContentProvider {
@@ -15,7 +15,10 @@ export class TextDocumentContentProvider
if (editor == null) {
return '';
}
return Server.client.sendRequest<string>('ra/analyzerStatus', null);
return Server.client.sendRequest<string>(
'rust-analyzer/analyzerStatus',
null
);
}
get onDidChange(): vscode.Event<vscode.Uri> {
@@ -31,7 +34,7 @@ export function makeCommand(context: vscode.ExtensionContext) {
const textDocumentContentProvider = new TextDocumentContentProvider();
context.subscriptions.push(
vscode.workspace.registerTextDocumentContentProvider(
'ra-lsp-status',
'rust-analyzer-status',
textDocumentContentProvider
)
);

View File

@@ -24,7 +24,7 @@ export async function handle() {
textDocument: { uri: editor.document.uri.toString() }
};
const response = await Server.client.sendRequest<ExtendSelectionResult>(
'm/extendSelection',
'rust-analyzer/extendSelection',
request
);
editor.selections = response.selections.map((range: Range) => {

View File

@@ -22,7 +22,7 @@ export async function handle() {
textDocument: { uri: editor.document.uri.toString() }
};
const change = await Server.client.sendRequest<SourceChange>(
'm/joinLines',
'rust-analyzer/joinLines',
request
);
await applySourceChange(change);

View File

@@ -20,7 +20,7 @@ export async function handle() {
})
};
const response = await Server.client.sendRequest<Position[]>(
'm/findMatchingBrace',
'rust-analyzer/findMatchingBrace',
request
);
editor.selections = editor.selections.map((sel, idx) => {

View File

@@ -22,7 +22,7 @@ export async function handle(event: { text: string }): Promise<boolean> {
)
};
const change = await Server.client.sendRequest<undefined | SourceChange>(
'm/onEnter',
'rust-analyzer/onEnter',
request
);
if (!change) {

View File

@@ -15,7 +15,7 @@ export async function handle() {
)
};
const response = await Server.client.sendRequest<lc.Location[]>(
'm/parentModule',
'rust-analyzer/parentModule',
request
);
const loc = response[0];

View File

@@ -83,7 +83,7 @@ export async function handle() {
)
};
const runnables = await Server.client.sendRequest<Runnable[]>(
'm/runnables',
'rust-analyzer/runnables',
params
);
const items: RunnableQuickPick[] = [];

View File

@@ -3,7 +3,7 @@ import { TextDocumentIdentifier } from 'vscode-languageclient';
import { Server } from '../server';
export const syntaxTreeUri = vscode.Uri.parse('ra-lsp://syntaxtree');
export const syntaxTreeUri = vscode.Uri.parse('rust-analyzer://syntaxtree');
export class TextDocumentContentProvider
implements vscode.TextDocumentContentProvider {
@@ -21,7 +21,7 @@ export class TextDocumentContentProvider
textDocument: { uri: editor.document.uri.toString() }
};
return Server.client.sendRequest<SyntaxTreeResult>(
'm/syntaxTree',
'rust-analyzer/syntaxTree',
request
);
}

View File

@@ -16,7 +16,7 @@ export class Config {
}
public userConfigChanged() {
const config = vscode.workspace.getConfiguration('ra-lsp');
const config = vscode.workspace.getConfiguration('rust-analyzer');
if (config.has('highlightingOn')) {
this.highlightingOn = config.get('highlightingOn') as boolean;
}

View File

@@ -16,7 +16,7 @@ export async function handle(editor: TextEditor | undefined) {
uri: editor.document.uri.toString()
};
const decorations = await Server.client.sendRequest<Decoration[]>(
'm/decorationsRequest',
'rust-analyzer/decorationsRequest',
params
);
Server.highlighter.setHighlights(editor, decorations);

View File

@@ -46,31 +46,41 @@ export function activate(context: vscode.ExtensionContext) {
// Commands are requests from vscode to the language server
registerCommand(
'ra-lsp.analyzerStatus',
'rust-analyzer.analyzerStatus',
commands.analyzerStatus.makeCommand(context)
);
registerCommand('ra-lsp.collectGarbage', () =>
Server.client.sendRequest<null>('ra/collectGarbage', null)
registerCommand('rust-analyzer.collectGarbage', () =>
Server.client.sendRequest<null>('rust-analyzer/collectGarbage', null)
);
registerCommand('ra-lsp.syntaxTree', commands.syntaxTree.handle);
registerCommand('ra-lsp.extendSelection', commands.extendSelection.handle);
registerCommand('ra-lsp.matchingBrace', commands.matchingBrace.handle);
registerCommand('ra-lsp.joinLines', commands.joinLines.handle);
registerCommand('ra-lsp.parentModule', commands.parentModule.handle);
registerCommand('ra-lsp.run', commands.runnables.handle);
registerCommand('rust-analyzer.syntaxTree', commands.syntaxTree.handle);
registerCommand(
'ra-lsp.applySourceChange',
'rust-analyzer.extendSelection',
commands.extendSelection.handle
);
registerCommand(
'rust-analyzer.matchingBrace',
commands.matchingBrace.handle
);
registerCommand('rust-analyzer.joinLines', commands.joinLines.handle);
registerCommand('rust-analyzer.parentModule', commands.parentModule.handle);
registerCommand('rust-analyzer.run', commands.runnables.handle);
// Unlike the above this does not send requests to the language server
registerCommand('rust-analyzer.runSingle', commands.runnables.handleSingle);
registerCommand(
'rust-analyzer.applySourceChange',
commands.applySourceChange.handle
);
overrideCommand('type', commands.onEnter.handle);
// Unlike the above this does not send requests to the language server
registerCommand('ra-lsp.run-single', commands.runnables.handleSingle);
// Notifications are events triggered by the language server
const allNotifications: Iterable<
[string, lc.GenericNotificationHandler]
> = [['m/publishDecorations', notifications.publishDecorations.handle]];
> = [
[
'rust-analyzer/publishDecorations',
notifications.publishDecorations.handle
]
];
// The events below are plain old javascript events, triggered and handled by vscode
vscode.window.onDidChangeActiveTextEditor(
@@ -80,7 +90,7 @@ export function activate(context: vscode.ExtensionContext) {
const textDocumentContentProvider = new TextDocumentContentProvider();
disposeOnDeactivation(
vscode.workspace.registerTextDocumentContentProvider(
'ra-lsp',
'rust-analyzer',
textDocumentContentProvider
)
);

View File

@@ -42,8 +42,12 @@ export class Server {
log: (messageOrDataObject: string | any, data?: string) => {
if (typeof messageOrDataObject === 'string') {
if (
messageOrDataObject.includes('m/publishDecorations') ||
messageOrDataObject.includes('m/decorationsRequest')
messageOrDataObject.includes(
'rust-analyzer/publishDecorations'
) ||
messageOrDataObject.includes(
'rust-analyzer/decorationsRequest'
)
) {
// Don't log publish decorations requests
} else {