Skip to content

Commit

Permalink
style: format files
Browse files Browse the repository at this point in the history
  • Loading branch information
mtshiba committed Jun 26, 2024
1 parent f1f1328 commit 5e9a7f9
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 13 deletions.
6 changes: 5 additions & 1 deletion extension/src/commands.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { Uri, commands } from "vscode";
// copied and modified from https://github.com/rust-lang/rust-analyzer/blob/27239fbb58a115915ffc1ce65ededc951eb00fd2/editors/code/src/commands.ts
import type { LanguageClient, Location, Position } from "vscode-languageclient/node";
import type {
LanguageClient,
Location,
Position,
} from "vscode-languageclient/node";

export async function showReferences(
client: LanguageClient | undefined,
Expand Down
49 changes: 37 additions & 12 deletions extension/src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,40 @@
import { type ExtensionContext, commands, window, workspace } from "vscode";
import { LanguageClient, type LanguageClientOptions, type ServerOptions } from "vscode-languageclient/node";
import {
LanguageClient,
type LanguageClientOptions,
type ServerOptions,
} from "vscode-languageclient/node";
import { showReferences } from "./commands";

let client: LanguageClient | undefined;

async function startLanguageClient(context: ExtensionContext) {
try {
const executablePath = (() => {
const executablePath = workspace.getConfiguration("pylyzer").get<string>("executablePath", "");
const executablePath = workspace
.getConfiguration("pylyzer")
.get<string>("executablePath", "");
return executablePath === "" ? "pylyzer" : executablePath;
})();
const enableDiagnostics = workspace.getConfiguration("pylyzer").get<boolean>("diagnostics", true);
const enableInlayHints = workspace.getConfiguration("pylyzer").get<boolean>("inlayHints", false);
const enableSemanticTokens = workspace.getConfiguration("pylyzer").get<boolean>("semanticTokens", true);
const enableHover = workspace.getConfiguration("pylyzer").get<boolean>("hover", true);
const smartCompletion = workspace.getConfiguration("pylyzer").get<boolean>("smartCompletion", true);
const enableDiagnostics = workspace
.getConfiguration("pylyzer")
.get<boolean>("diagnostics", true);
const enableInlayHints = workspace
.getConfiguration("pylyzer")
.get<boolean>("inlayHints", false);
const enableSemanticTokens = workspace
.getConfiguration("pylyzer")
.get<boolean>("semanticTokens", true);
const enableHover = workspace
.getConfiguration("pylyzer")
.get<boolean>("hover", true);
const smartCompletion = workspace
.getConfiguration("pylyzer")
.get<boolean>("smartCompletion", true);
/* optional features */
const checkOnType = workspace.getConfiguration("pylyzer").get<boolean>("checkOnType", false);
const checkOnType = workspace
.getConfiguration("pylyzer")
.get<boolean>("checkOnType", false);
const args = ["--server"];
args.push("--");
if (!enableDiagnostics) {
Expand Down Expand Up @@ -78,11 +96,18 @@ async function restartLanguageClient() {
}

export async function activate(context: ExtensionContext) {
context.subscriptions.push(commands.registerCommand("pylyzer.restartLanguageServer", () => restartLanguageClient()));
context.subscriptions.push(
commands.registerCommand("pylyzer.showReferences", async (uri, position, locations) => {
await showReferences(client, uri, position, locations);
}),
commands.registerCommand("pylyzer.restartLanguageServer", () =>
restartLanguageClient(),
),
);
context.subscriptions.push(
commands.registerCommand(
"pylyzer.showReferences",
async (uri, position, locations) => {
await showReferences(client, uri, position, locations);
},
),
);
await startLanguageClient(context);
}
Expand Down

0 comments on commit 5e9a7f9

Please sign in to comment.