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

@ -125,13 +125,13 @@ and trait selection) to the existing rustc.
- [x] [textDocument/documentHighlight](https://microsoft.github.io/language-server-protocol/specification#textDocument_documentHighlight) - [x] [textDocument/documentHighlight](https://microsoft.github.io/language-server-protocol/specification#textDocument_documentHighlight)
- [x] [textDocument/documentSymbol](https://microsoft.github.io/language-server-protocol/specification#textDocument_documentSymbol) - [x] [textDocument/documentSymbol](https://microsoft.github.io/language-server-protocol/specification#textDocument_documentSymbol)
- [x] [textDocument/codeAction](https://microsoft.github.io/language-server-protocol/specification#textDocument_codeAction) - [x] [textDocument/codeAction](https://microsoft.github.io/language-server-protocol/specification#textDocument_codeAction)
- ra_lsp.syntaxTree - rust-analyzer.syntaxTree
- ra_lsp.extendSelection - rust-analyzer.extendSelection
- ra_lsp.matchingBrace - rust-analyzer.matchingBrace
- ra_lsp.parentModule - rust-analyzer.parentModule
- ra_lsp.joinLines - rust-analyzer.joinLines
- ra_lsp.run - rust-analyzer.run
- ra_lsp.analyzerStatus - rust-analyzer.analyzerStatus
- [x] [textDocument/codeLens](https://microsoft.github.io/language-server-protocol/specification#textDocument_codeLens) - [x] [textDocument/codeLens](https://microsoft.github.io/language-server-protocol/specification#textDocument_codeLens)
- [ ] [textDocument/documentLink](https://microsoft.github.io/language-server-protocol/specification#codeLens_resolve) - [ ] [textDocument/documentLink](https://microsoft.github.io/language-server-protocol/specification#codeLens_resolve)
- [ ] [documentLink/resolve](https://microsoft.github.io/language-server-protocol/specification#documentLink_resolve) - [ ] [documentLink/resolve](https://microsoft.github.io/language-server-protocol/specification#documentLink_resolve)

View file

@ -581,7 +581,7 @@ pub fn handle_code_action(
let edit = source_edit.try_conv_with(&world)?; let edit = source_edit.try_conv_with(&world)?;
let cmd = Command { let cmd = Command {
title, title,
command: "ra-lsp.applySourceChange".to_string(), command: "rust-analyzer.applySourceChange".to_string(),
arguments: Some(vec![to_value(edit).unwrap()]), arguments: Some(vec![to_value(edit).unwrap()]),
}; };
res.push(cmd); res.push(cmd);
@ -623,7 +623,7 @@ pub fn handle_code_lens(
range, range,
command: Some(Command { command: Some(Command {
title: title.into(), title: title.into(),
command: "ra-lsp.run-single".into(), command: "rust-analyzer.runSingle".into(),
arguments: Some(vec![to_value(r).unwrap()]), arguments: Some(vec![to_value(r).unwrap()]),
}), }),
data: None, data: None,

View file

@ -16,7 +16,7 @@ pub enum AnalyzerStatus {}
impl Request for AnalyzerStatus { impl Request for AnalyzerStatus {
type Params = (); type Params = ();
type Result = String; type Result = String;
const METHOD: &'static str = "ra/analyzerStatus"; const METHOD: &'static str = "rust-analyzer/analyzerStatus";
} }
pub enum CollectGarbage {} pub enum CollectGarbage {}
@ -24,7 +24,7 @@ pub enum CollectGarbage {}
impl Request for CollectGarbage { impl Request for CollectGarbage {
type Params = (); type Params = ();
type Result = (); type Result = ();
const METHOD: &'static str = "ra/collectGarbage"; const METHOD: &'static str = "rust-analyzer/collectGarbage";
} }
pub enum SyntaxTree {} pub enum SyntaxTree {}
@ -32,7 +32,7 @@ pub enum SyntaxTree {}
impl Request for SyntaxTree { impl Request for SyntaxTree {
type Params = SyntaxTreeParams; type Params = SyntaxTreeParams;
type Result = String; type Result = String;
const METHOD: &'static str = "m/syntaxTree"; const METHOD: &'static str = "rust-analyzer/syntaxTree";
} }
#[derive(Deserialize, Debug)] #[derive(Deserialize, Debug)]
@ -46,7 +46,7 @@ pub enum ExtendSelection {}
impl Request for ExtendSelection { impl Request for ExtendSelection {
type Params = ExtendSelectionParams; type Params = ExtendSelectionParams;
type Result = ExtendSelectionResult; type Result = ExtendSelectionResult;
const METHOD: &'static str = "m/extendSelection"; const METHOD: &'static str = "rust-analyzer/extendSelection";
} }
#[derive(Deserialize, Debug)] #[derive(Deserialize, Debug)]
@ -67,7 +67,7 @@ pub enum FindMatchingBrace {}
impl Request for FindMatchingBrace { impl Request for FindMatchingBrace {
type Params = FindMatchingBraceParams; type Params = FindMatchingBraceParams;
type Result = Vec<Position>; type Result = Vec<Position>;
const METHOD: &'static str = "m/findMatchingBrace"; const METHOD: &'static str = "rust-analyzer/findMatchingBrace";
} }
#[derive(Deserialize, Debug)] #[derive(Deserialize, Debug)]
@ -82,14 +82,14 @@ pub enum DecorationsRequest {}
impl Request for DecorationsRequest { impl Request for DecorationsRequest {
type Params = TextDocumentIdentifier; type Params = TextDocumentIdentifier;
type Result = Vec<Decoration>; type Result = Vec<Decoration>;
const METHOD: &'static str = "m/decorationsRequest"; const METHOD: &'static str = "rust-analyzer/decorationsRequest";
} }
pub enum PublishDecorations {} pub enum PublishDecorations {}
impl Notification for PublishDecorations { impl Notification for PublishDecorations {
type Params = PublishDecorationsParams; type Params = PublishDecorationsParams;
const METHOD: &'static str = "m/publishDecorations"; const METHOD: &'static str = "rust-analyzer/publishDecorations";
} }
#[derive(Serialize, Debug)] #[derive(Serialize, Debug)]
@ -112,7 +112,7 @@ pub enum ParentModule {}
impl Request for ParentModule { impl Request for ParentModule {
type Params = TextDocumentPositionParams; type Params = TextDocumentPositionParams;
type Result = Vec<Location>; type Result = Vec<Location>;
const METHOD: &'static str = "m/parentModule"; const METHOD: &'static str = "rust-analyzer/parentModule";
} }
pub enum JoinLines {} pub enum JoinLines {}
@ -120,7 +120,7 @@ pub enum JoinLines {}
impl Request for JoinLines { impl Request for JoinLines {
type Params = JoinLinesParams; type Params = JoinLinesParams;
type Result = SourceChange; type Result = SourceChange;
const METHOD: &'static str = "m/joinLines"; const METHOD: &'static str = "rust-analyzer/joinLines";
} }
#[derive(Deserialize, Debug)] #[derive(Deserialize, Debug)]
@ -135,7 +135,7 @@ pub enum OnEnter {}
impl Request for OnEnter { impl Request for OnEnter {
type Params = TextDocumentPositionParams; type Params = TextDocumentPositionParams;
type Result = Option<SourceChange>; type Result = Option<SourceChange>;
const METHOD: &'static str = "m/onEnter"; const METHOD: &'static str = "rust-analyzer/onEnter";
} }
pub enum Runnables {} pub enum Runnables {}
@ -143,7 +143,7 @@ pub enum Runnables {}
impl Request for Runnables { impl Request for Runnables {
type Params = RunnablesParams; type Params = RunnablesParams;
type Result = Vec<Runnable>; type Result = Vec<Runnable>;
const METHOD: &'static str = "m/runnables"; const METHOD: &'static str = "rust-analyzer/runnables";
} }
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]

View file

@ -246,7 +246,7 @@ fn main() {}
"label": "create module" "label": "create module"
} }
], ],
"command": "ra-lsp.applySourceChange", "command": "rust-analyzer.applySourceChange",
"title": "create module" "title": "create module"
} }
]), ]),

View file

@ -26,7 +26,7 @@ They are more experimental in nature and work only with VS Code.
### Syntax highlighting ### Syntax highlighting
It overrides built-in highlighting, and works only with a specific theme It overrides built-in highlighting, and works only with a specific theme
(zenburn). `ra-lsp.highlightingOn` setting can be used to disable it. (zenburn). `rust-analyzer.highlightingOn` setting can be used to disable it.
### Go to symbol in workspace <kbd>ctrl+t</kbd> ### Go to symbol in workspace <kbd>ctrl+t</kbd>

View file

@ -72,61 +72,61 @@
], ],
"commands": [ "commands": [
{ {
"command": "ra-lsp.syntaxTree", "command": "rust-analyzer.syntaxTree",
"title": "Show Rust syntax tree" "title": "rust-analyzer: syntax tree"
}, },
{ {
"command": "ra-lsp.extendSelection", "command": "rust-analyzer.extendSelection",
"title": "Rust Extend Selection" "title": "rust-analyzer: extend selection"
}, },
{ {
"command": "ra-lsp.matchingBrace", "command": "rust-analyzer.matchingBrace",
"title": "Rust Matching Brace" "title": "rust-analyzer: matching brace"
}, },
{ {
"command": "ra-lsp.parentModule", "command": "rust-analyzer.parentModule",
"title": "Rust Parent Module" "title": "rust-analyzer: parent module"
}, },
{ {
"command": "ra-lsp.joinLines", "command": "rust-analyzer.joinLines",
"title": "Rust Join Lines" "title": "rust-analyzer: join lines"
}, },
{ {
"command": "ra-lsp.run", "command": "rust-analyzer.run",
"title": "Rust Run" "title": "rust-analyzer: run"
}, },
{ {
"command": "ra-lsp.analyzerStatus", "command": "rust-analyzer.analyzerStatus",
"title": "Status of rust-analyzer (debug)" "title": "rust-analyzer: status"
}, },
{ {
"command": "ra-lsp.collectGarbage", "command": "rust-analyzer.collectGarbage",
"title": "Run rust-analyzer's GC" "title": "rust-analyzer: run gc"
} }
], ],
"keybindings": [ "keybindings": [
{ {
"command": "ra-lsp.parentModule", "command": "rust-analyzer.parentModule",
"key": "ctrl+u", "key": "ctrl+u",
"when": "editorTextFocus && editorLangId == rust" "when": "editorTextFocus && editorLangId == rust"
}, },
{ {
"command": "ra-lsp.matchingBrace", "command": "rust-analyzer.matchingBrace",
"key": "ctrl+shift+m", "key": "ctrl+shift+m",
"when": "editorTextFocus && editorLangId == rust" "when": "editorTextFocus && editorLangId == rust"
}, },
{ {
"command": "ra-lsp.extendSelection", "command": "rust-analyzer.extendSelection",
"key": "shift+alt+right", "key": "shift+alt+right",
"when": "editorTextFocus && editorLangId == rust" "when": "editorTextFocus && editorLangId == rust"
}, },
{ {
"command": "ra-lsp.joinLines", "command": "rust-analyzer.joinLines",
"key": "ctrl+shift+j", "key": "ctrl+shift+j",
"when": "editorTextFocus && editorLangId == rust" "when": "editorTextFocus && editorLangId == rust"
}, },
{ {
"command": "ra-lsp.run", "command": "rust-analyzer.run",
"key": "ctrl+r", "key": "ctrl+r",
"when": "editorTextFocus && editorLangId == rust" "when": "editorTextFocus && editorLangId == rust"
} }
@ -135,19 +135,19 @@
"type": "object", "type": "object",
"title": "Rust Analyzer", "title": "Rust Analyzer",
"properties": { "properties": {
"ra-lsp.highlightingOn": { "rust-analyzer.highlightingOn": {
"type": "boolean", "type": "boolean",
"default": true, "default": true,
"description": "Highlight Rust code (overrides built-in syntax highlighting)" "description": "Highlight Rust code (overrides built-in syntax highlighting)"
}, },
"ra-lsp.raLspServerPath": { "rust-analyzer.raLspServerPath": {
"type": [ "type": [
"string" "string"
], ],
"default": "ra_lsp_server", "default": "ra_lsp_server",
"description": "Path to ra_lsp_server executable" "description": "Path to ra_lsp_server executable"
}, },
"ra-lsp.trace.server": { "rust-analyzer.trace.server": {
"type": "string", "type": "string",
"scope": "window", "scope": "window",
"enum": [ "enum": [
@ -156,7 +156,7 @@
"verbose" "verbose"
], ],
"default": "off", "default": "off",
"description": "Trace requests to the ra-lsp server" "description": "Trace requests to the ra_lsp_server"
} }
} }
}, },

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -3,7 +3,7 @@ import { TextDocumentIdentifier } from 'vscode-languageclient';
import { Server } from '../server'; 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 export class TextDocumentContentProvider
implements vscode.TextDocumentContentProvider { implements vscode.TextDocumentContentProvider {
@ -21,7 +21,7 @@ export class TextDocumentContentProvider
textDocument: { uri: editor.document.uri.toString() } textDocument: { uri: editor.document.uri.toString() }
}; };
return Server.client.sendRequest<SyntaxTreeResult>( return Server.client.sendRequest<SyntaxTreeResult>(
'm/syntaxTree', 'rust-analyzer/syntaxTree',
request request
); );
} }

View file

@ -16,7 +16,7 @@ export class Config {
} }
public userConfigChanged() { public userConfigChanged() {
const config = vscode.workspace.getConfiguration('ra-lsp'); const config = vscode.workspace.getConfiguration('rust-analyzer');
if (config.has('highlightingOn')) { if (config.has('highlightingOn')) {
this.highlightingOn = config.get('highlightingOn') as boolean; 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() uri: editor.document.uri.toString()
}; };
const decorations = await Server.client.sendRequest<Decoration[]>( const decorations = await Server.client.sendRequest<Decoration[]>(
'm/decorationsRequest', 'rust-analyzer/decorationsRequest',
params params
); );
Server.highlighter.setHighlights(editor, decorations); 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 // Commands are requests from vscode to the language server
registerCommand( registerCommand(
'ra-lsp.analyzerStatus', 'rust-analyzer.analyzerStatus',
commands.analyzerStatus.makeCommand(context) commands.analyzerStatus.makeCommand(context)
); );
registerCommand('ra-lsp.collectGarbage', () => registerCommand('rust-analyzer.collectGarbage', () =>
Server.client.sendRequest<null>('ra/collectGarbage', null) Server.client.sendRequest<null>('rust-analyzer/collectGarbage', null)
); );
registerCommand('ra-lsp.syntaxTree', commands.syntaxTree.handle); registerCommand('rust-analyzer.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( 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 commands.applySourceChange.handle
); );
overrideCommand('type', commands.onEnter.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 // Notifications are events triggered by the language server
const allNotifications: Iterable< const allNotifications: Iterable<
[string, lc.GenericNotificationHandler] [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 // The events below are plain old javascript events, triggered and handled by vscode
vscode.window.onDidChangeActiveTextEditor( vscode.window.onDidChangeActiveTextEditor(
@ -80,7 +90,7 @@ export function activate(context: vscode.ExtensionContext) {
const textDocumentContentProvider = new TextDocumentContentProvider(); const textDocumentContentProvider = new TextDocumentContentProvider();
disposeOnDeactivation( disposeOnDeactivation(
vscode.workspace.registerTextDocumentContentProvider( vscode.workspace.registerTextDocumentContentProvider(
'ra-lsp', 'rust-analyzer',
textDocumentContentProvider textDocumentContentProvider
) )
); );

View file

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