Skip to content
This repository was archived by the owner on Nov 18, 2022. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
150 changes: 89 additions & 61 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,37 @@
"vscode-test": "^0.4.3"
},
"contributes": {
"languages": [
{
"id": "rust",
"extensions": [
".rs"
],
"configuration": "./language-configuration.json"
}
],
"snippets": [
"colors": [{
"id": "rust.typeHintColor",
"description": "Specifies the foreground color of a type hint",
"defaults": {
"dark": "#A0A0A0F0",
"light": "#747474",
"highContrast": "#BEBEBE"
}
},
{
"language": "rust",
"path": "./snippets/rust.json"
"id": "rust.typeHintBackgroundColor",
"description": "Specifies the foreground color of a type hint",
"defaults": {
"dark": "#70707020",
"light": "#74747410",
"highContrast": "#BEBEBE"
}
}
],
"commands": [
{
"languages": [{
"id": "rust",
"extensions": [
".rs"
],
"configuration": "./language-configuration.json"
}],
"snippets": [{
"language": "rust",
"path": "./snippets/rust.json"
}],
"commands": [{
"command": "rls.update",
"title": "Update the RLS",
"description": "Use Rustup to update Rust, the RLS, and required data",
Expand All @@ -96,52 +110,47 @@
"category": "Rust"
}
],
"taskDefinitions": [
{
"type": "cargo",
"properties": {
"subcommand": {
"type": "string"
}
},
"required": [
"subcommand"
]
}
],
"problemMatchers": [
{
"name": "rustc",
"owner": "rust",
"fileLocation": [
"relative",
"${workspaceRoot}"
],
"pattern": [
{
"regexp": "^(warning|warn|error)(\\[(.*)\\])?: (.*)$",
"severity": 1,
"message": 4,
"code": 3
},
{
"regexp": "^([\\s->=]*(.*):(\\d*):(\\d*)|.*)$",
"file": 2,
"line": 3,
"column": 4
},
{
"regexp": "^.*$"
},
{
"regexp": "^([\\s->=]*(.*):(\\d*):(\\d*)|.*)$",
"file": 2,
"line": 3,
"column": 4
}
]
}
],
"taskDefinitions": [{
"type": "cargo",
"properties": {
"subcommand": {
"type": "string"
}
},
"required": [
"subcommand"
]
}],
"problemMatchers": [{
"name": "rustc",
"owner": "rust",
"fileLocation": [
"relative",
"${workspaceRoot}"
],
"pattern": [{
"regexp": "^(warning|warn|error)(\\[(.*)\\])?: (.*)$",
"severity": 1,
"message": 4,
"code": 3
},
{
"regexp": "^([\\s->=]*(.*):(\\d*):(\\d*)|.*)$",
"file": 2,
"line": 3,
"column": 4
},
{
"regexp": "^.*$"
},
{
"regexp": "^([\\s->=]*(.*):(\\d*):(\\d*)|.*)$",
"file": 2,
"line": 3,
"column": 4
}
]
}],
"configuration": {
"type": "object",
"title": "Rust configuration",
Expand Down Expand Up @@ -422,8 +431,27 @@
"default": true,
"description": "Show additional context in hover tooltips when available. This is often the type local variable declaration.",
"scope": "resource"
},
"rust-type_hints.enable": {
"type": "boolean",
"default": true,
"desciption": "Show type hints",
"scope": "resource"
},
"rust-type_hints.max_length": {
"type": "integer",
"default": 40,
"desciption": "Maximum length of type hints",
"scope": "resource"
},
"rust-type_hints.shortening": {
"type": "string",
"enum": ["greedy", "none"],
"default": "greedy",
"desciption": "\"greedy\" will remove all namespace parts from type names, as well as lifetime specifiers, from the hints",
"scope": "resource"
}
}
}
}
}
}
47 changes: 38 additions & 9 deletions src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import * as child_process from 'child_process';
import * as fs from 'fs';
import * as path from 'path';
import {
LanguageClient,
LanguageClientOptions,
NotificationType,
ServerOptions,
} from 'vscode-languageclient';

import {
commands,
Disposable,
Expand All @@ -14,15 +21,9 @@ import {
WorkspaceFolder,
WorkspaceFoldersChangeEvent,
} from 'vscode';
import {
LanguageClient,
LanguageClientOptions,
NotificationType,
ServerOptions,
} from 'vscode-languageclient';

import { RLSConfiguration } from './configuration';
import { SignatureHelpProvider } from './providers/signatureHelpProvider';
import { Decorator } from './providers/typeAnnotationsProvider';
import { checkForRls, ensureToolchain, rustupUpdate } from './rustup';
import { startSpinner, stopSpinner } from './spinner';
import { activateTaskProvider, Execution, runRlsCommand } from './tasks';
Expand Down Expand Up @@ -50,6 +51,24 @@ export async function activate(context: ExtensionContext) {
workspace.onDidChangeWorkspaceFolders(e =>
whenChangingWorkspaceFolders(e, context),
);
window.onDidChangeActiveTextEditor(editor => {
if (editor === undefined || editor === null) {
return;
}
const decorator = Decorator.getInstance();
if (decorator === undefined) {
return;
}
console.log('Attempting to decorate after editor change.');
decorator.decorate(editor);
});
workspace.onDidChangeTextDocument(textDocumentChange => {
for (const editor of window.visibleTextEditors) {
if (editor.document === textDocumentChange.document) {
Decorator.getInstance()!.decorate(editor);
}
}
});
}

export async function deactivate() {
Expand Down Expand Up @@ -256,6 +275,7 @@ class ClientWorkspace {
clientOptions,
);

Decorator.getInstance(this.lc);
const selector = this.config.multiProjectEnabled
? { language: 'rust', scheme: 'file', pattern }
: { language: 'rust' };
Expand Down Expand Up @@ -330,12 +350,18 @@ class ClientWorkspace {
const runningProgress: Set<string> = new Set();
await this.lc.onReady();
stopSpinner('RLS');

this.lc.onNotification(
new NotificationType<ProgressParams, void>('window/progress'),
progress => {
if (progress.done) {
runningProgress.delete(progress.id);
const decorator = Decorator.getInstance();
if (decorator !== undefined) {
console.log('Starting Decoration after progress.done');
for (const editor of window.visibleTextEditors) {
decorator.decorate(editor);
}
}
} else {
runningProgress.add(progress.id);
}
Expand Down Expand Up @@ -517,7 +543,10 @@ function configureLanguage(): Disposable {
// e.g. /** | */ or /*! | */
beforeText: /^\s*\/\*(\*|\!)(?!\/)([^\*]|\*(?!\/))*$/,
afterText: /^\s*\*\/$/,
action: { indentAction: IndentAction.IndentOutdent, appendText: ' * ' },
action: {
indentAction: IndentAction.IndentOutdent,
appendText: ' * ',
},
},
{
// Begins a multi-line comment (standard or parent doc)
Expand Down
Loading