aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
Diffstat (limited to 'editors')
-rw-r--r--editors/README.md2
-rw-r--r--editors/code/package.json62
-rw-r--r--editors/code/src/commands/analyzer_status.ts9
-rw-r--r--editors/code/src/commands/extend_selection.ts2
-rw-r--r--editors/code/src/commands/join_lines.ts2
-rw-r--r--editors/code/src/commands/matching_brace.ts2
-rw-r--r--editors/code/src/commands/on_enter.ts2
-rw-r--r--editors/code/src/commands/parent_module.ts2
-rw-r--r--editors/code/src/commands/runnables.ts5
-rw-r--r--editors/code/src/commands/syntaxTree.ts4
-rw-r--r--editors/code/src/config.ts2
-rw-r--r--editors/code/src/events/change_active_text_editor.ts2
-rw-r--r--editors/code/src/extension.ts40
-rw-r--r--editors/code/src/server.ts8
14 files changed, 86 insertions, 58 deletions
diff --git a/editors/README.md b/editors/README.md
index b35a1f367..2d6a3f21d 100644
--- a/editors/README.md
+++ b/editors/README.md
@@ -26,7 +26,7 @@ They are more experimental in nature and work only with VS Code.
26### Syntax highlighting 26### Syntax highlighting
27 27
28It overrides built-in highlighting, and works only with a specific theme 28It overrides built-in highlighting, and works only with a specific theme
29(zenburn). `ra-lsp.highlightingOn` setting can be used to disable it. 29(zenburn). `rust-analyzer.highlightingOn` setting can be used to disable it.
30 30
31### Go to symbol in workspace <kbd>ctrl+t</kbd> 31### Go to symbol in workspace <kbd>ctrl+t</kbd>
32 32
diff --git a/editors/code/package.json b/editors/code/package.json
index 86683eb73..1ed834d62 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -44,7 +44,9 @@
44 "vscode": "^1.1.26" 44 "vscode": "^1.1.26"
45 }, 45 },
46 "activationEvents": [ 46 "activationEvents": [
47 "onLanguage:rust" 47 "onLanguage:rust",
48 "onCommand:rust-analyzer.analyzerStatus",
49 "onCommand:rust-analyzer.collectGarbage"
48 ], 50 ],
49 "main": "./out/extension", 51 "main": "./out/extension",
50 "contributes": { 52 "contributes": {
@@ -72,61 +74,69 @@
72 ], 74 ],
73 "commands": [ 75 "commands": [
74 { 76 {
75 "command": "ra-lsp.syntaxTree", 77 "command": "rust-analyzer.syntaxTree",
76 "title": "Show Rust syntax tree" 78 "title": "Show syntax tree for current file",
79 "category": "Rust Analyzer"
77 }, 80 },
78 { 81 {
79 "command": "ra-lsp.extendSelection", 82 "command": "rust-analyzer.extendSelection",
80 "title": "Rust Extend Selection" 83 "title": "Extend selection",
84 "category": "Rust Analyzer"
81 }, 85 },
82 { 86 {
83 "command": "ra-lsp.matchingBrace", 87 "command": "rust-analyzer.matchingBrace",
84 "title": "Rust Matching Brace" 88 "title": "Find matching brace",
89 "category": "Rust Analyzer"
85 }, 90 },
86 { 91 {
87 "command": "ra-lsp.parentModule", 92 "command": "rust-analyzer.parentModule",
88 "title": "Rust Parent Module" 93 "title": "Locate parent module",
94 "category": "Rust Analyzer"
89 }, 95 },
90 { 96 {
91 "command": "ra-lsp.joinLines", 97 "command": "rust-analyzer.joinLines",
92 "title": "Rust Join Lines" 98 "title": "Join lines",
99 "category": "Rust Analyzer"
93 }, 100 },
94 { 101 {
95 "command": "ra-lsp.run", 102 "command": "rust-analyzer.run",
96 "title": "Rust Run" 103 "title": "Run",
104 "category": "Rust Analyzer"
97 }, 105 },
98 { 106 {
99 "command": "ra-lsp.analyzerStatus", 107 "command": "rust-analyzer.analyzerStatus",
100 "title": "Status of rust-analyzer (debug)" 108 "title": "Status",
109 "category": "Rust Analyzer"
101 }, 110 },
102 { 111 {
103 "command": "ra-lsp.collectGarbage", 112 "command": "rust-analyzer.collectGarbage",
104 "title": "Run rust-analyzer's GC" 113 "title": "Run garbage collection",
114 "category": "Rust Analyzer"
105 } 115 }
106 ], 116 ],
107 "keybindings": [ 117 "keybindings": [
108 { 118 {
109 "command": "ra-lsp.parentModule", 119 "command": "rust-analyzer.parentModule",
110 "key": "ctrl+u", 120 "key": "ctrl+u",
111 "when": "editorTextFocus && editorLangId == rust" 121 "when": "editorTextFocus && editorLangId == rust"
112 }, 122 },
113 { 123 {
114 "command": "ra-lsp.matchingBrace", 124 "command": "rust-analyzer.matchingBrace",
115 "key": "ctrl+shift+m", 125 "key": "ctrl+shift+m",
116 "when": "editorTextFocus && editorLangId == rust" 126 "when": "editorTextFocus && editorLangId == rust"
117 }, 127 },
118 { 128 {
119 "command": "ra-lsp.extendSelection", 129 "command": "rust-analyzer.extendSelection",
120 "key": "shift+alt+right", 130 "key": "shift+alt+right",
121 "when": "editorTextFocus && editorLangId == rust" 131 "when": "editorTextFocus && editorLangId == rust"
122 }, 132 },
123 { 133 {
124 "command": "ra-lsp.joinLines", 134 "command": "rust-analyzer.joinLines",
125 "key": "ctrl+shift+j", 135 "key": "ctrl+shift+j",
126 "when": "editorTextFocus && editorLangId == rust" 136 "when": "editorTextFocus && editorLangId == rust"
127 }, 137 },
128 { 138 {
129 "command": "ra-lsp.run", 139 "command": "rust-analyzer.run",
130 "key": "ctrl+r", 140 "key": "ctrl+r",
131 "when": "editorTextFocus && editorLangId == rust" 141 "when": "editorTextFocus && editorLangId == rust"
132 } 142 }
@@ -135,19 +145,19 @@
135 "type": "object", 145 "type": "object",
136 "title": "Rust Analyzer", 146 "title": "Rust Analyzer",
137 "properties": { 147 "properties": {
138 "ra-lsp.highlightingOn": { 148 "rust-analyzer.highlightingOn": {
139 "type": "boolean", 149 "type": "boolean",
140 "default": true, 150 "default": true,
141 "description": "Highlight Rust code (overrides built-in syntax highlighting)" 151 "description": "Highlight Rust code (overrides built-in syntax highlighting)"
142 }, 152 },
143 "ra-lsp.raLspServerPath": { 153 "rust-analyzer.raLspServerPath": {
144 "type": [ 154 "type": [
145 "string" 155 "string"
146 ], 156 ],
147 "default": "ra_lsp_server", 157 "default": "ra_lsp_server",
148 "description": "Path to ra_lsp_server executable" 158 "description": "Path to ra_lsp_server executable"
149 }, 159 },
150 "ra-lsp.trace.server": { 160 "rust-analyzer.trace.server": {
151 "type": "string", 161 "type": "string",
152 "scope": "window", 162 "scope": "window",
153 "enum": [ 163 "enum": [
@@ -156,7 +166,7 @@
156 "verbose" 166 "verbose"
157 ], 167 ],
158 "default": "off", 168 "default": "off",
159 "description": "Trace requests to the ra-lsp server" 169 "description": "Trace requests to the ra_lsp_server"
160 } 170 }
161 } 171 }
162 }, 172 },
diff --git a/editors/code/src/commands/analyzer_status.ts b/editors/code/src/commands/analyzer_status.ts
index bb46a1990..63f82c92d 100644
--- a/editors/code/src/commands/analyzer_status.ts
+++ b/editors/code/src/commands/analyzer_status.ts
@@ -1,7 +1,7 @@
1import * as vscode from 'vscode'; 1import * as vscode from 'vscode';
2import { Server } from '../server'; 2import { Server } from '../server';
3 3
4const statusUri = vscode.Uri.parse('ra-lsp-status://status'); 4const statusUri = vscode.Uri.parse('rust-analyzer-status://status');
5 5
6export class TextDocumentContentProvider 6export class TextDocumentContentProvider
7 implements vscode.TextDocumentContentProvider { 7 implements vscode.TextDocumentContentProvider {
@@ -15,7 +15,10 @@ export class TextDocumentContentProvider
15 if (editor == null) { 15 if (editor == null) {
16 return ''; 16 return '';
17 } 17 }
18 return Server.client.sendRequest<string>('ra/analyzerStatus', null); 18 return Server.client.sendRequest<string>(
19 'rust-analyzer/analyzerStatus',
20 null
21 );
19 } 22 }
20 23
21 get onDidChange(): vscode.Event<vscode.Uri> { 24 get onDidChange(): vscode.Event<vscode.Uri> {
@@ -31,7 +34,7 @@ export function makeCommand(context: vscode.ExtensionContext) {
31 const textDocumentContentProvider = new TextDocumentContentProvider(); 34 const textDocumentContentProvider = new TextDocumentContentProvider();
32 context.subscriptions.push( 35 context.subscriptions.push(
33 vscode.workspace.registerTextDocumentContentProvider( 36 vscode.workspace.registerTextDocumentContentProvider(
34 'ra-lsp-status', 37 'rust-analyzer-status',
35 textDocumentContentProvider 38 textDocumentContentProvider
36 ) 39 )
37 ); 40 );
diff --git a/editors/code/src/commands/extend_selection.ts b/editors/code/src/commands/extend_selection.ts
index 7b96bbc37..6f4187d15 100644
--- a/editors/code/src/commands/extend_selection.ts
+++ b/editors/code/src/commands/extend_selection.ts
@@ -24,7 +24,7 @@ export async function handle() {
24 textDocument: { uri: editor.document.uri.toString() } 24 textDocument: { uri: editor.document.uri.toString() }
25 }; 25 };
26 const response = await Server.client.sendRequest<ExtendSelectionResult>( 26 const response = await Server.client.sendRequest<ExtendSelectionResult>(
27 'm/extendSelection', 27 'rust-analyzer/extendSelection',
28 request 28 request
29 ); 29 );
30 editor.selections = response.selections.map((range: Range) => { 30 editor.selections = response.selections.map((range: Range) => {
diff --git a/editors/code/src/commands/join_lines.ts b/editors/code/src/commands/join_lines.ts
index 27d263b8a..0d4b12f4d 100644
--- a/editors/code/src/commands/join_lines.ts
+++ b/editors/code/src/commands/join_lines.ts
@@ -22,7 +22,7 @@ export async function handle() {
22 textDocument: { uri: editor.document.uri.toString() } 22 textDocument: { uri: editor.document.uri.toString() }
23 }; 23 };
24 const change = await Server.client.sendRequest<SourceChange>( 24 const change = await Server.client.sendRequest<SourceChange>(
25 'm/joinLines', 25 'rust-analyzer/joinLines',
26 request 26 request
27 ); 27 );
28 await applySourceChange(change); 28 await applySourceChange(change);
diff --git a/editors/code/src/commands/matching_brace.ts b/editors/code/src/commands/matching_brace.ts
index 5e6638e82..d86faf405 100644
--- a/editors/code/src/commands/matching_brace.ts
+++ b/editors/code/src/commands/matching_brace.ts
@@ -20,7 +20,7 @@ export async function handle() {
20 }) 20 })
21 }; 21 };
22 const response = await Server.client.sendRequest<Position[]>( 22 const response = await Server.client.sendRequest<Position[]>(
23 'm/findMatchingBrace', 23 'rust-analyzer/findMatchingBrace',
24 request 24 request
25 ); 25 );
26 editor.selections = editor.selections.map((sel, idx) => { 26 editor.selections = editor.selections.map((sel, idx) => {
diff --git a/editors/code/src/commands/on_enter.ts b/editors/code/src/commands/on_enter.ts
index bb376e3cb..16dcb70c8 100644
--- a/editors/code/src/commands/on_enter.ts
+++ b/editors/code/src/commands/on_enter.ts
@@ -22,7 +22,7 @@ export async function handle(event: { text: string }): Promise<boolean> {
22 ) 22 )
23 }; 23 };
24 const change = await Server.client.sendRequest<undefined | SourceChange>( 24 const change = await Server.client.sendRequest<undefined | SourceChange>(
25 'm/onEnter', 25 'rust-analyzer/onEnter',
26 request 26 request
27 ); 27 );
28 if (!change) { 28 if (!change) {
diff --git a/editors/code/src/commands/parent_module.ts b/editors/code/src/commands/parent_module.ts
index 806c3d34c..9d30b7b59 100644
--- a/editors/code/src/commands/parent_module.ts
+++ b/editors/code/src/commands/parent_module.ts
@@ -15,7 +15,7 @@ export async function handle() {
15 ) 15 )
16 }; 16 };
17 const response = await Server.client.sendRequest<lc.Location[]>( 17 const response = await Server.client.sendRequest<lc.Location[]>(
18 'm/parentModule', 18 'rust-analyzer/parentModule',
19 request 19 request
20 ); 20 );
21 const loc = response[0]; 21 const loc = response[0];
diff --git a/editors/code/src/commands/runnables.ts b/editors/code/src/commands/runnables.ts
index aa5817c21..c0f2ada76 100644
--- a/editors/code/src/commands/runnables.ts
+++ b/editors/code/src/commands/runnables.ts
@@ -83,7 +83,7 @@ export async function handle() {
83 ) 83 )
84 }; 84 };
85 const runnables = await Server.client.sendRequest<Runnable[]>( 85 const runnables = await Server.client.sendRequest<Runnable[]>(
86 'm/runnables', 86 'rust-analyzer/runnables',
87 params 87 params
88 ); 88 );
89 const items: RunnableQuickPick[] = []; 89 const items: RunnableQuickPick[] = [];
@@ -118,7 +118,8 @@ export async function handleSingle(runnable: Runnable) {
118 task.group = vscode.TaskGroup.Build; 118 task.group = vscode.TaskGroup.Build;
119 task.presentationOptions = { 119 task.presentationOptions = {
120 reveal: vscode.TaskRevealKind.Always, 120 reveal: vscode.TaskRevealKind.Always,
121 panel: vscode.TaskPanelKind.Dedicated 121 panel: vscode.TaskPanelKind.Dedicated,
122 clear: true
122 }; 123 };
123 124
124 return vscode.tasks.executeTask(task); 125 return vscode.tasks.executeTask(task);
diff --git a/editors/code/src/commands/syntaxTree.ts b/editors/code/src/commands/syntaxTree.ts
index 5d5cdd7a0..c0baf08c5 100644
--- a/editors/code/src/commands/syntaxTree.ts
+++ b/editors/code/src/commands/syntaxTree.ts
@@ -3,7 +3,7 @@ import { TextDocumentIdentifier } from 'vscode-languageclient';
3 3
4import { Server } from '../server'; 4import { Server } from '../server';
5 5
6export const syntaxTreeUri = vscode.Uri.parse('ra-lsp://syntaxtree'); 6export const syntaxTreeUri = vscode.Uri.parse('rust-analyzer://syntaxtree');
7 7
8export class TextDocumentContentProvider 8export class TextDocumentContentProvider
9 implements vscode.TextDocumentContentProvider { 9 implements vscode.TextDocumentContentProvider {
@@ -21,7 +21,7 @@ export class TextDocumentContentProvider
21 textDocument: { uri: editor.document.uri.toString() } 21 textDocument: { uri: editor.document.uri.toString() }
22 }; 22 };
23 return Server.client.sendRequest<SyntaxTreeResult>( 23 return Server.client.sendRequest<SyntaxTreeResult>(
24 'm/syntaxTree', 24 'rust-analyzer/syntaxTree',
25 request 25 request
26 ); 26 );
27 } 27 }
diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts
index cc7a10f76..d26f5df0a 100644
--- a/editors/code/src/config.ts
+++ b/editors/code/src/config.ts
@@ -16,7 +16,7 @@ export class Config {
16 } 16 }
17 17
18 public userConfigChanged() { 18 public userConfigChanged() {
19 const config = vscode.workspace.getConfiguration('ra-lsp'); 19 const config = vscode.workspace.getConfiguration('rust-analyzer');
20 if (config.has('highlightingOn')) { 20 if (config.has('highlightingOn')) {
21 this.highlightingOn = config.get('highlightingOn') as boolean; 21 this.highlightingOn = config.get('highlightingOn') as boolean;
22 } 22 }
diff --git a/editors/code/src/events/change_active_text_editor.ts b/editors/code/src/events/change_active_text_editor.ts
index 0b7ceb65d..af295b2ec 100644
--- a/editors/code/src/events/change_active_text_editor.ts
+++ b/editors/code/src/events/change_active_text_editor.ts
@@ -16,7 +16,7 @@ export async function handle(editor: TextEditor | undefined) {
16 uri: editor.document.uri.toString() 16 uri: editor.document.uri.toString()
17 }; 17 };
18 const decorations = await Server.client.sendRequest<Decoration[]>( 18 const decorations = await Server.client.sendRequest<Decoration[]>(
19 'm/decorationsRequest', 19 'rust-analyzer/decorationsRequest',
20 params 20 params
21 ); 21 );
22 Server.highlighter.setHighlights(editor, decorations); 22 Server.highlighter.setHighlights(editor, decorations);
diff --git a/editors/code/src/extension.ts b/editors/code/src/extension.ts
index dc7b01403..0b2a6095b 100644
--- a/editors/code/src/extension.ts
+++ b/editors/code/src/extension.ts
@@ -46,31 +46,41 @@ export function activate(context: vscode.ExtensionContext) {
46 46
47 // Commands are requests from vscode to the language server 47 // Commands are requests from vscode to the language server
48 registerCommand( 48 registerCommand(
49 'ra-lsp.analyzerStatus', 49 'rust-analyzer.analyzerStatus',
50 commands.analyzerStatus.makeCommand(context) 50 commands.analyzerStatus.makeCommand(context)
51 ); 51 );
52 registerCommand('ra-lsp.collectGarbage', () => 52 registerCommand('rust-analyzer.collectGarbage', () =>
53 Server.client.sendRequest<null>('ra/collectGarbage', null) 53 Server.client.sendRequest<null>('rust-analyzer/collectGarbage', null)
54 ); 54 );
55 registerCommand('ra-lsp.syntaxTree', commands.syntaxTree.handle); 55 registerCommand('rust-analyzer.syntaxTree', commands.syntaxTree.handle);
56 registerCommand('ra-lsp.extendSelection', commands.extendSelection.handle);
57 registerCommand('ra-lsp.matchingBrace', commands.matchingBrace.handle);
58 registerCommand('ra-lsp.joinLines', commands.joinLines.handle);
59 registerCommand('ra-lsp.parentModule', commands.parentModule.handle);
60 registerCommand('ra-lsp.run', commands.runnables.handle);
61 registerCommand( 56 registerCommand(
62 'ra-lsp.applySourceChange', 57 'rust-analyzer.extendSelection',
58 commands.extendSelection.handle
59 );
60 registerCommand(
61 'rust-analyzer.matchingBrace',
62 commands.matchingBrace.handle
63 );
64 registerCommand('rust-analyzer.joinLines', commands.joinLines.handle);
65 registerCommand('rust-analyzer.parentModule', commands.parentModule.handle);
66 registerCommand('rust-analyzer.run', commands.runnables.handle);
67 // Unlike the above this does not send requests to the language server
68 registerCommand('rust-analyzer.runSingle', commands.runnables.handleSingle);
69 registerCommand(
70 'rust-analyzer.applySourceChange',
63 commands.applySourceChange.handle 71 commands.applySourceChange.handle
64 ); 72 );
65 overrideCommand('type', commands.onEnter.handle); 73 overrideCommand('type', commands.onEnter.handle);
66 74
67 // Unlike the above this does not send requests to the language server
68 registerCommand('ra-lsp.run-single', commands.runnables.handleSingle);
69
70 // Notifications are events triggered by the language server 75 // Notifications are events triggered by the language server
71 const allNotifications: Iterable< 76 const allNotifications: Iterable<
72 [string, lc.GenericNotificationHandler] 77 [string, lc.GenericNotificationHandler]
73 > = [['m/publishDecorations', notifications.publishDecorations.handle]]; 78 > = [
79 [
80 'rust-analyzer/publishDecorations',
81 notifications.publishDecorations.handle
82 ]
83 ];
74 84
75 // The events below are plain old javascript events, triggered and handled by vscode 85 // The events below are plain old javascript events, triggered and handled by vscode
76 vscode.window.onDidChangeActiveTextEditor( 86 vscode.window.onDidChangeActiveTextEditor(
@@ -80,7 +90,7 @@ export function activate(context: vscode.ExtensionContext) {
80 const textDocumentContentProvider = new TextDocumentContentProvider(); 90 const textDocumentContentProvider = new TextDocumentContentProvider();
81 disposeOnDeactivation( 91 disposeOnDeactivation(
82 vscode.workspace.registerTextDocumentContentProvider( 92 vscode.workspace.registerTextDocumentContentProvider(
83 'ra-lsp', 93 'rust-analyzer',
84 textDocumentContentProvider 94 textDocumentContentProvider
85 ) 95 )
86 ); 96 );
diff --git a/editors/code/src/server.ts b/editors/code/src/server.ts
index 35fb7e3f5..0d2632708 100644
--- a/editors/code/src/server.ts
+++ b/editors/code/src/server.ts
@@ -42,8 +42,12 @@ export class Server {
42 log: (messageOrDataObject: string | any, data?: string) => { 42 log: (messageOrDataObject: string | any, data?: string) => {
43 if (typeof messageOrDataObject === 'string') { 43 if (typeof messageOrDataObject === 'string') {
44 if ( 44 if (
45 messageOrDataObject.includes('m/publishDecorations') || 45 messageOrDataObject.includes(
46 messageOrDataObject.includes('m/decorationsRequest') 46 'rust-analyzer/publishDecorations'
47 ) ||
48 messageOrDataObject.includes(
49 'rust-analyzer/decorationsRequest'
50 )
47 ) { 51 ) {
48 // Don't log publish decorations requests 52 // Don't log publish decorations requests
49 } else { 53 } else {