Skip to content

Commit

Permalink
chore: replace prettier/eslint with biomejs
Browse files Browse the repository at this point in the history
  • Loading branch information
jnoortheen committed Jan 11, 2025
1 parent eec2354 commit 835f224
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 75 deletions.
22 changes: 0 additions & 22 deletions .prettierignore

This file was deleted.

30 changes: 30 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"vcs": {
"enabled": false,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"ignoreUnknown": false,
"ignore": []
},
"formatter": {
"enabled": true,
"indentStyle": "space"
},
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
},
"javascript": {
"formatter": {
"quoteStyle": "double"
}
}
}
Empty file removed dist/tmlang/.gitkeep
Empty file.
57 changes: 27 additions & 30 deletions src/client.ts
Original file line number Diff line number Diff line change
@@ -1,50 +1,47 @@
import { ExtensionContext, window, workspace } from 'vscode';
import * as net from "node:net";
import { type ExtensionContext, window, workspace } from "vscode";
import {
LanguageClient,
LanguageClientOptions,
ServerOptions,
} from 'vscode-languageclient/node';
import * as net from "net";
type LanguageClientOptions,
type ServerOptions,
} from "vscode-languageclient/node";

let client: LanguageClient;

function getClientOptions(): LanguageClientOptions {
const docSelector: { scheme: string; language: string }[] = [
{ scheme: 'file', language: 'xonsh' },
{ scheme: 'untitled', language: 'xonsh' },
{ scheme: "file", language: "xonsh" },
{ scheme: "untitled", language: "xonsh" },
];

return {
return {
documentSelector: docSelector,
synchronize: {
fileEvents: [
workspace.createFileSystemWatcher('**/*.xsh'),
],
configurationSection: 'pylsp',
fileEvents: [workspace.createFileSystemWatcher("**/*.xsh")],
configurationSection: "pylsp",
},
outputChannel: window.createOutputChannel('Xonsh'),
outputChannel: window.createOutputChannel("Xonsh"),
};

}

function startLangServerTCP(addr: number): LanguageClient {
const serverOptions: ServerOptions = () => {
return new Promise((resolve /*, reject */) => {
const clientSocket = new net.Socket();
clientSocket.connect(addr, "127.0.0.1", () => {
resolve({
reader: clientSocket,
writer: clientSocket,
});
});
const serverOptions: ServerOptions = () => {
return new Promise((resolve /*, reject */) => {
const clientSocket = new net.Socket();
clientSocket.connect(addr, "127.0.0.1", () => {
resolve({
reader: clientSocket,
writer: clientSocket,
});
};
});
});
};

return new LanguageClient(
`tcp lang server (port ${addr})`,
serverOptions,
getClientOptions()
);
return new LanguageClient(
`tcp lang server (port ${addr})`,
serverOptions,
getClientOptions(),
);
}

export async function activate(ctx: ExtensionContext): Promise<void> {
Expand All @@ -54,7 +51,7 @@ export async function activate(ctx: ExtensionContext): Promise<void> {
// };

// client = new LanguageClient('xonsh', 'Xonsh', serverOptions, clientOptions);
client = startLangServerTCP(2007)
client = startLangServerTCP(2007);
client.registerProposedFeatures();
await client.start();
ctx.subscriptions.push(client);
Expand Down
36 changes: 18 additions & 18 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,40 @@
*--------------------------------------------------------------------------------------------*/

import {
env,
ExtensionContext,
type ExtensionContext,
IndentAction,
languages,
Uri,
env,
languages,
window,
workspace,
} from 'vscode';
import * as client from './client';
import { which } from './which';
import { UriMessageItem } from './models';
} from "vscode";
import * as client from "./client";
import type { UriMessageItem } from "./models";
import { which } from "./which";

function getExePath(): string | undefined {
const executable = workspace
.getConfiguration('pylsp')
.get<string>('executable');
.getConfiguration("pylsp")
.get<string>("executable");
if (executable) {
const isWindows = process.platform === 'win32';
const isWindows = process.platform === "win32";
return which(
isWindows && !executable.endsWith('.exe')
isWindows && !executable.endsWith(".exe")
? `${executable}.exe`
: executable
: executable,
);
}
}
async function checkServerInstalled(): Promise<string | undefined> {
const executable = getExePath();
if (executable === undefined || executable === '') {
if (executable === undefined || executable === "") {
const selection = await window.showErrorMessage<UriMessageItem>(
'Unable to find Python language server',
"Unable to find Python language server",
{
title: 'Install language server',
uri: Uri.parse('https://github.com/python-lsp/python-lsp-server'),
}
title: "Install language server",
uri: Uri.parse("https://github.com/python-lsp/python-lsp-server"),
},
);
if (selection?.uri !== undefined) {
await env.openExternal(selection?.uri);
Expand All @@ -54,7 +54,7 @@ export async function activate(ctx: ExtensionContext): Promise<void> {
await client.activate(ctx);
}

languages.setLanguageConfiguration('xonsh', {
languages.setLanguageConfiguration("xonsh", {
onEnterRules: [
{
beforeText:
Expand Down
2 changes: 1 addition & 1 deletion src/models.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MessageItem, Uri } from 'vscode';
import type { MessageItem, Uri } from "vscode";

export interface UriMessageItem extends MessageItem {
uri: Uri;
Expand Down
8 changes: 4 additions & 4 deletions src/which.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import * as path from 'path';
import * as fs from 'fs';
import * as fs from "node:fs";
import * as path from "node:path";

export function which(cmd: string): string | undefined {
if (cmd.includes(path.sep)) {
// the cmd is given as full path. check that it exists
if (fs.existsSync(cmd)) {
return cmd;
}
} else if (process.env['PATH']) {
} else if (process.env.PATH) {
// search in path and return
const dirs = process.env['PATH'].split(path.delimiter);
const dirs = process.env.PATH.split(path.delimiter);

for (const folder of dirs) {
const fullpath = path.join(folder, cmd);
Expand Down

0 comments on commit 835f224

Please sign in to comment.