Run prettier on all files

This commit is contained in:
Aleksey Kladov 2019-12-30 18:31:08 +01:00
parent 9bfeac708d
commit ac3d0e8340
7 changed files with 18 additions and 23 deletions

View file

@ -19,7 +19,7 @@
"vscode:prepublish": "rollup -c", "vscode:prepublish": "rollup -c",
"package": "vsce package", "package": "vsce package",
"watch": "tsc -watch -p ./", "watch": "tsc -watch -p ./",
"prettier": "prettier --write **/*.ts" "prettier": "prettier --write '**/*.ts'"
}, },
"dependencies": { "dependencies": {
"jsonc-parser": "^2.1.0", "jsonc-parser": "^2.1.0",

View file

@ -23,10 +23,7 @@ export function analyzerStatus(ctx: Ctx): Cmd {
return async function handle() { return async function handle() {
if (poller == null) { if (poller == null) {
poller = setInterval( poller = setInterval(() => tdcp.eventEmitter.fire(tdcp.uri), 1000);
() => tdcp.eventEmitter.fire(tdcp.uri),
1000,
);
} }
const document = await vscode.workspace.openTextDocument(tdcp.uri); const document = await vscode.workspace.openTextDocument(tdcp.uri);
return vscode.window.showTextDocument( return vscode.window.showTextDocument(
@ -39,13 +36,12 @@ export function analyzerStatus(ctx: Ctx): Cmd {
class TextDocumentContentProvider class TextDocumentContentProvider
implements vscode.TextDocumentContentProvider { implements vscode.TextDocumentContentProvider {
ctx: Ctx;
ctx: Ctx
uri = vscode.Uri.parse('rust-analyzer-status://status'); uri = vscode.Uri.parse('rust-analyzer-status://status');
eventEmitter = new vscode.EventEmitter<vscode.Uri>(); eventEmitter = new vscode.EventEmitter<vscode.Uri>();
constructor(ctx: Ctx) { constructor(ctx: Ctx) {
this.ctx = ctx this.ctx = ctx;
} }
provideTextDocumentContent( provideTextDocumentContent(

View file

@ -1,4 +1,4 @@
import { Ctx, Cmd } from '../ctx' import { Ctx, Cmd } from '../ctx';
import { analyzerStatus } from './analyzer_status'; import { analyzerStatus } from './analyzer_status';
import { matchingBrace } from './matching_brace'; import { matchingBrace } from './matching_brace';
@ -11,7 +11,9 @@ import * as runnables from './runnables';
import * as syntaxTree from './syntaxTree'; import * as syntaxTree from './syntaxTree';
function collectGarbage(ctx: Ctx): Cmd { function collectGarbage(ctx: Ctx): Cmd {
return async () => { ctx.client.sendRequest<null>('rust-analyzer/collectGarbage', null) } return async () => {
ctx.client.sendRequest<null>('rust-analyzer/collectGarbage', null);
};
} }
export { export {
@ -24,5 +26,5 @@ export {
syntaxTree, syntaxTree,
onEnter, onEnter,
inlayHints, inlayHints,
collectGarbage collectGarbage,
}; };

View file

@ -1,8 +1,6 @@
import { Range, TextDocumentIdentifier } from 'vscode-languageclient'; import { Range, TextDocumentIdentifier } from 'vscode-languageclient';
import { Ctx, Cmd } from '../ctx'; import { Ctx, Cmd } from '../ctx';
import { import { applySourceChange, SourceChange } from '../source_change';
applySourceChange, SourceChange
} from '../source_change';
export function joinLines(ctx: Ctx): Cmd { export function joinLines(ctx: Ctx): Cmd {
return async () => { return async () => {
@ -18,7 +16,7 @@ export function joinLines(ctx: Ctx): Cmd {
request, request,
); );
await applySourceChange(ctx, change); await applySourceChange(ctx, change);
} };
} }
interface JoinLinesParams { interface JoinLinesParams {

View file

@ -10,7 +10,9 @@ export function matchingBrace(ctx: Ctx): Cmd {
} }
const request: FindMatchingBraceParams = { const request: FindMatchingBraceParams = {
textDocument: { uri: editor.document.uri.toString() }, textDocument: { uri: editor.document.uri.toString() },
offsets: editor.selections.map(s => ctx.client.code2ProtocolConverter.asPosition(s.active)), offsets: editor.selections.map(s =>
ctx.client.code2ProtocolConverter.asPosition(s.active),
),
}; };
const response = await ctx.client.sendRequest<Position[]>( const response = await ctx.client.sendRequest<Position[]>(
'rust-analyzer/findMatchingBrace', 'rust-analyzer/findMatchingBrace',
@ -24,7 +26,7 @@ export function matchingBrace(ctx: Ctx): Cmd {
return new vscode.Selection(anchor, active); return new vscode.Selection(anchor, active);
}); });
editor.revealRange(editor.selection); editor.revealRange(editor.selection);
} };
} }
interface FindMatchingBraceParams { interface FindMatchingBraceParams {

View file

@ -1,8 +1,5 @@
import * as lc from 'vscode-languageclient'; import * as lc from 'vscode-languageclient';
import { import { applySourceChange, SourceChange } from '../source_change';
applySourceChange,
SourceChange,
} from '../source_change';
import { Cmd, Ctx } from '../ctx'; import { Cmd, Ctx } from '../ctx';
export function onEnter(ctx: Ctx): Cmd { export function onEnter(ctx: Ctx): Cmd {
@ -24,5 +21,5 @@ export function onEnter(ctx: Ctx): Cmd {
await applySourceChange(ctx, change); await applySourceChange(ctx, change);
return true; return true;
} };
} }

View file

@ -28,5 +28,5 @@ export function parentModule(ctx: Ctx): Cmd {
const e = await vscode.window.showTextDocument(doc); const e = await vscode.window.showTextDocument(doc);
e.selection = new vscode.Selection(range.start, range.start); e.selection = new vscode.Selection(range.start, range.start);
e.revealRange(range, vscode.TextEditorRevealType.InCenter); e.revealRange(range, vscode.TextEditorRevealType.InCenter);
} };
} }