style: format files

This commit is contained in:
Shunsuke Shibayama 2024-06-26 17:07:32 +09:00
parent f1f13285af
commit 5e9a7f9215
2 changed files with 42 additions and 13 deletions

View File

@ -1,6 +1,10 @@
import { Uri, commands } from "vscode"; import { Uri, commands } from "vscode";
// copied and modified from https://github.com/rust-lang/rust-analyzer/blob/27239fbb58a115915ffc1ce65ededc951eb00fd2/editors/code/src/commands.ts // 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( export async function showReferences(
client: LanguageClient | undefined, client: LanguageClient | undefined,

View File

@ -1,5 +1,9 @@
import { type ExtensionContext, commands, window, workspace } from "vscode"; 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"; import { showReferences } from "./commands";
let client: LanguageClient | undefined; let client: LanguageClient | undefined;
@ -7,16 +11,30 @@ let client: LanguageClient | undefined;
async function startLanguageClient(context: ExtensionContext) { async function startLanguageClient(context: ExtensionContext) {
try { try {
const executablePath = (() => { const executablePath = (() => {
const executablePath = workspace.getConfiguration("pylyzer").get<string>("executablePath", ""); const executablePath = workspace
.getConfiguration("pylyzer")
.get<string>("executablePath", "");
return executablePath === "" ? "pylyzer" : executablePath; return executablePath === "" ? "pylyzer" : executablePath;
})(); })();
const enableDiagnostics = workspace.getConfiguration("pylyzer").get<boolean>("diagnostics", true); const enableDiagnostics = workspace
const enableInlayHints = workspace.getConfiguration("pylyzer").get<boolean>("inlayHints", false); .getConfiguration("pylyzer")
const enableSemanticTokens = workspace.getConfiguration("pylyzer").get<boolean>("semanticTokens", true); .get<boolean>("diagnostics", true);
const enableHover = workspace.getConfiguration("pylyzer").get<boolean>("hover", true); const enableInlayHints = workspace
const smartCompletion = workspace.getConfiguration("pylyzer").get<boolean>("smartCompletion", true); .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 */ /* optional features */
const checkOnType = workspace.getConfiguration("pylyzer").get<boolean>("checkOnType", false); const checkOnType = workspace
.getConfiguration("pylyzer")
.get<boolean>("checkOnType", false);
const args = ["--server"]; const args = ["--server"];
args.push("--"); args.push("--");
if (!enableDiagnostics) { if (!enableDiagnostics) {
@ -78,11 +96,18 @@ async function restartLanguageClient() {
} }
export async function activate(context: ExtensionContext) { export async function activate(context: ExtensionContext) {
context.subscriptions.push(commands.registerCommand("pylyzer.restartLanguageServer", () => restartLanguageClient()));
context.subscriptions.push( context.subscriptions.push(
commands.registerCommand("pylyzer.showReferences", async (uri, position, locations) => { commands.registerCommand("pylyzer.restartLanguageServer", () =>
await showReferences(client, uri, position, locations); restartLanguageClient(),
}), ),
);
context.subscriptions.push(
commands.registerCommand(
"pylyzer.showReferences",
async (uri, position, locations) => {
await showReferences(client, uri, position, locations);
},
),
); );
await startLanguageClient(context); await startLanguageClient(context);
} }