diff --git a/.eslintrc.js b/.eslintrc.js index f660e39..7c87637 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,20 +1,15 @@ /**@type {import('eslint').Linter.Config} */ // eslint-disable-next-line no-undef module.exports = { - root: true, - parser: '@typescript-eslint/parser', - plugins: [ - '@typescript-eslint', - ], - extends: [ - 'eslint:recommended', - 'plugin:@typescript-eslint/recommended', - ], - rules: { - 'semi': [2, "always"], - '@typescript-eslint/no-unused-vars': 0, - '@typescript-eslint/no-explicit-any': 0, - '@typescript-eslint/explicit-module-boundary-types': 0, - '@typescript-eslint/no-non-null-assertion': 0, - } -}; \ No newline at end of file + root: true, + parser: '@typescript-eslint/parser', + plugins: ['@typescript-eslint'], + extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'], + rules: { + semi: [2, 'always'], + '@typescript-eslint/no-unused-vars': 0, + '@typescript-eslint/no-explicit-any': 0, + '@typescript-eslint/explicit-module-boundary-types': 0, + '@typescript-eslint/no-non-null-assertion': 0, + }, +}; diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index e395b6d..998c8c2 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -2,13 +2,13 @@ name: CI -# Controls when the action will run. +# Controls when the action will run. on: # Triggers the workflow on push or pull request events but only for the main branch push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] # Allows you to run this workflow manually from the Actions tab workflow_dispatch: @@ -27,7 +27,7 @@ jobs: - run: npm install - uses: lannonbr/vsce-action@master with: - args: "package" + args: 'package' # Runs a single command using the runners shell # - name: Run a one-line script diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0529de5..300ff25 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,12 +4,11 @@ # Controls when the action will run. #on: - # Triggers the workflow on push or pull request events but only for the main branch - #push: - # branches: [ main ] - #pull_request: - # branches: [ main ] - +# Triggers the workflow on push or pull request events but only for the main branch +#push: +# branches: [ main ] +#pull_request: +# branches: [ main ] name: Create And Upload Release Asset @@ -17,7 +16,7 @@ on: push: # Sequence of patterns matched against refs/tags tags: - - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 + - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 # Allows you to run this workflow manually from the Actions tab workflow_dispatch: diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..63517ca --- /dev/null +++ b/.prettierignore @@ -0,0 +1,5 @@ +# Ignore artifacts: +build +coverage +out +used_keywords.jsonc \ No newline at end of file diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..84cc551 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,4 @@ +{ + "$schema": "https://json.schemastore.org/prettierrc", + "singleQuote": true +} diff --git a/.vscode/settings.json b/.vscode/settings.json index 940998a..c2ca6dc 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,10 +1,10 @@ { - "editor.insertSpaces": false, - "typescript.tsc.autoDetect": "off", - "typescript.preferences.quoteStyle": "single", - "editor.codeActionsOnSave": { - "source.fixAll.eslint": "explicit" - }, - "editor.formatOnSave": true, - "editor.defaultFormatter": "esbenp.prettier-vscode" -} \ No newline at end of file + "editor.insertSpaces": false, + "typescript.tsc.autoDetect": "off", + "typescript.preferences.quoteStyle": "single", + "editor.codeActionsOnSave": { + "source.fixAll.eslint": "explicit" + }, + "editor.formatOnSave": true, + "editor.defaultFormatter": "esbenp.prettier-vscode" +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 442c31d..b461b59 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,35 +1,31 @@ // See https://go.microsoft.com/fwlink/?LinkId=733558 // for the documentation about the tasks.json format { - "version": "2.0.0", - "tasks": [ - { - "type": "npm", - "script": "compile", - "group": "build", - "presentation": { - "panel": "dedicated", - "reveal": "never" - }, - "problemMatcher": [ - "$tsc" - ] - }, - { - "type": "npm", - "script": "watch", - "isBackground": true, - "group": { - "kind": "build", - "isDefault": true - }, - "presentation": { - "panel": "dedicated", - "reveal": "never" - }, - "problemMatcher": [ - "$tsc-watch" - ] - } - ] -} \ No newline at end of file + "version": "2.0.0", + "tasks": [ + { + "type": "npm", + "script": "compile", + "group": "build", + "presentation": { + "panel": "dedicated", + "reveal": "never" + }, + "problemMatcher": ["$tsc"] + }, + { + "type": "npm", + "script": "watch", + "isBackground": true, + "group": { + "kind": "build", + "isDefault": true + }, + "presentation": { + "panel": "dedicated", + "reveal": "never" + }, + "problemMatcher": ["$tsc-watch"] + } + ] +} diff --git a/CHANGELOG.md b/CHANGELOG.md index 44d90a0..060663a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -166,4 +166,4 @@ All notable changes to the "vscode-nushell-lang" extension will be documented in - 1.9.0 - Add spread to syntax highlighting [#174](https://github.com/nushell/vscode-nushell-lang/pull/174) - fix markdown formatting for hover lsp [#175](https://github.com/nushell/vscode-nushell-lang/pull/175) - - update grammar for nushell 0.91.0 [#177](https://github.com/nushell/vscode-nushell-lang/pull/177) \ No newline at end of file + - update grammar for nushell 0.91.0 [#177](https://github.com/nushell/vscode-nushell-lang/pull/177) diff --git a/client/src/extension.ts b/client/src/extension.ts index 71759f1..360faa9 100644 --- a/client/src/extension.ts +++ b/client/src/extension.ts @@ -4,41 +4,41 @@ * Licensed under the MIT License. See License.txt in the project root for license information. * ------------------------------------------------------------------------------------------ */ -import * as path from "path"; +import * as path from 'path'; // import { workspace, ExtensionContext } from "vscode"; -import * as vscode from "vscode"; +import * as vscode from 'vscode'; import { LanguageClient, LanguageClientOptions, ServerOptions, TransportKind, -} from "vscode-languageclient/node"; +} from 'vscode-languageclient/node'; let client: LanguageClient; export function activate(context: vscode.ExtensionContext) { - console.log("Terminals: " + (vscode.window).terminals.length); + console.log('Terminals: ' + (vscode.window).terminals.length); context.subscriptions.push( - vscode.window.registerTerminalProfileProvider("nushell_default", { + vscode.window.registerTerminalProfileProvider('nushell_default', { provideTerminalProfile( - token: vscode.CancellationToken + token: vscode.CancellationToken, ): vscode.ProviderResult { - const which = require("which"); - const path = require("path"); + const which = require('which'); + const path = require('path'); - const PATH_FROM_ENV = process.env["PATH"]; + const PATH_FROM_ENV = process.env['PATH']; const pathsToCheck = [ PATH_FROM_ENV, // cargo install location - (process.env["CARGO_HOME"] || "~/.cargo") + "/bin", + (process.env['CARGO_HOME'] || '~/.cargo') + '/bin', // winget on Windows install location - "c:\\program files\\nu\\bin", + 'c:\\program files\\nu\\bin', // just add a few other drives for fun - "d:\\program files\\nu\\bin", - "e:\\program files\\nu\\bin", - "f:\\program files\\nu\\bin", + 'd:\\program files\\nu\\bin', + 'e:\\program files\\nu\\bin', + 'f:\\program files\\nu\\bin', // SCOOP:TODO // all user installed programs and scoop itself install to @@ -60,40 +60,40 @@ export function activate(context: vscode.ExtensionContext) { // brew install location mac // intel - "/usr/local/bin", + '/usr/local/bin', // arm - "/opt/homebrew/bin", + '/opt/homebrew/bin', // native package manager install location // standard location should be in `PATH` env var //"/usr/bin/nu", ]; - const found_nushell_path = which.sync("nu", { + const found_nushell_path = which.sync('nu', { nothrow: true, path: pathsToCheck.join(path.delimiter), }); if (found_nushell_path == null) { console.log( - "Nushell not found in env:PATH or any of the heuristic locations." + 'Nushell not found in env:PATH or any of the heuristic locations.', ); // use an async arrow funciton to use `await` inside return (async () => { if ( (await vscode.window.showErrorMessage( - "We cannot find a nushell executable in your path or pre-defined locations", - "install from website" + 'We cannot find a nushell executable in your path or pre-defined locations', + 'install from website', )) && (await vscode.env.openExternal( - vscode.Uri.parse("https://www.nushell.sh/") + vscode.Uri.parse('https://www.nushell.sh/'), )) && (await vscode.window.showInformationMessage( - "after you install nushell, you might need to reload vscode", - "reload now" + 'after you install nushell, you might need to reload vscode', + 'reload now', )) ) { - vscode.commands.executeCommand("workbench.action.reloadWindow"); + vscode.commands.executeCommand('workbench.action.reloadWindow'); } // user has already seen error messages, but they didn't click through // return a promise that never resolve to supress the confusing error @@ -103,26 +103,26 @@ export function activate(context: vscode.ExtensionContext) { return { options: { - name: "Nushell", + name: 'Nushell', shellPath: found_nushell_path, iconPath: vscode.Uri.joinPath( context.extensionUri, - "assets/nu.svg" + 'assets/nu.svg', ), }, }; }, - }) + }), ); // The server is implemented in node const serverModule = context.asAbsolutePath( - path.join("out", "server", "src", "server.js") + path.join('out', 'server', 'src', 'server.js'), ); // The debug options for the server // --inspect=6009: runs the server in Node's Inspector mode so VS Code can attach to the server for debugging - const debugOptions = { execArgv: ["--nolazy", "--inspect=6009"] }; + const debugOptions = { execArgv: ['--nolazy', '--inspect=6009'] }; // If the extension is launched in debug mode then the debug server options are used // Otherwise the run options are used @@ -138,10 +138,10 @@ export function activate(context: vscode.ExtensionContext) { // Options to control the language client const clientOptions: LanguageClientOptions = { // Register the server for plain text documents - documentSelector: [{ scheme: "file", language: "nushell" }], + documentSelector: [{ scheme: 'file', language: 'nushell' }], synchronize: { // Notify the server about file changes to '.clientrc files contained in the workspace - fileEvents: vscode.workspace.createFileSystemWatcher("**/.clientrc"), + fileEvents: vscode.workspace.createFileSystemWatcher('**/.clientrc'), }, markdown: { isTrusted: true @@ -150,10 +150,10 @@ export function activate(context: vscode.ExtensionContext) { // Create the language client and start the client. client = new LanguageClient( - "nushellLanguageServer", - "Nushell Language Server", + 'nushellLanguageServer', + 'Nushell Language Server', serverOptions, - clientOptions + clientOptions, ); // Start the client. This will also launch the server diff --git a/client/src/test/completion.test.ts b/client/src/test/completion.test.ts index f355078..37d036e 100644 --- a/client/src/test/completion.test.ts +++ b/client/src/test/completion.test.ts @@ -8,36 +8,36 @@ import * as assert from 'assert'; import { getDocUri, activate } from './helper'; suite('Should do completion', () => { - const docUri = getDocUri('completion.txt'); + const docUri = getDocUri('completion.txt'); - test('Completes JS/TS in txt file', async () => { - await testCompletion(docUri, new vscode.Position(0, 0), { - items: [ - { label: 'JavaScript', kind: vscode.CompletionItemKind.Text }, - { label: 'TypeScript', kind: vscode.CompletionItemKind.Text } - ] - }); - }); + test('Completes JS/TS in txt file', async () => { + await testCompletion(docUri, new vscode.Position(0, 0), { + items: [ + { label: 'JavaScript', kind: vscode.CompletionItemKind.Text }, + { label: 'TypeScript', kind: vscode.CompletionItemKind.Text }, + ], + }); + }); }); async function testCompletion( - docUri: vscode.Uri, - position: vscode.Position, - expectedCompletionList: vscode.CompletionList + docUri: vscode.Uri, + position: vscode.Position, + expectedCompletionList: vscode.CompletionList, ) { - await activate(docUri); + await activate(docUri); - // Executing the command `vscode.executeCompletionItemProvider` to simulate triggering completion - const actualCompletionList = (await vscode.commands.executeCommand( - 'vscode.executeCompletionItemProvider', - docUri, - position - )) as vscode.CompletionList; + // Executing the command `vscode.executeCompletionItemProvider` to simulate triggering completion + const actualCompletionList = (await vscode.commands.executeCommand( + 'vscode.executeCompletionItemProvider', + docUri, + position, + )) as vscode.CompletionList; - assert.ok(actualCompletionList.items.length >= 2); - expectedCompletionList.items.forEach((expectedItem, i) => { - const actualItem = actualCompletionList.items[i]; - assert.equal(actualItem.label, expectedItem.label); - assert.equal(actualItem.kind, expectedItem.kind); - }); + assert.ok(actualCompletionList.items.length >= 2); + expectedCompletionList.items.forEach((expectedItem, i) => { + const actualItem = actualCompletionList.items[i]; + assert.equal(actualItem.label, expectedItem.label); + assert.equal(actualItem.kind, expectedItem.kind); + }); } diff --git a/client/src/test/diagnostics.test.ts b/client/src/test/diagnostics.test.ts index 1aa8a36..d262f87 100644 --- a/client/src/test/diagnostics.test.ts +++ b/client/src/test/diagnostics.test.ts @@ -8,34 +8,52 @@ import * as assert from 'assert'; import { getDocUri, activate } from './helper'; suite('Should get diagnostics', () => { - const docUri = getDocUri('diagnostics.txt'); - - test('Diagnoses uppercase texts', async () => { - await testDiagnostics(docUri, [ - { message: 'ANY is all uppercase.', range: toRange(0, 0, 0, 3), severity: vscode.DiagnosticSeverity.Warning, source: 'ex' }, - { message: 'ANY is all uppercase.', range: toRange(0, 14, 0, 17), severity: vscode.DiagnosticSeverity.Warning, source: 'ex' }, - { message: 'OS is all uppercase.', range: toRange(0, 18, 0, 20), severity: vscode.DiagnosticSeverity.Warning, source: 'ex' } - ]); - }); + const docUri = getDocUri('diagnostics.txt'); + + test('Diagnoses uppercase texts', async () => { + await testDiagnostics(docUri, [ + { + message: 'ANY is all uppercase.', + range: toRange(0, 0, 0, 3), + severity: vscode.DiagnosticSeverity.Warning, + source: 'ex', + }, + { + message: 'ANY is all uppercase.', + range: toRange(0, 14, 0, 17), + severity: vscode.DiagnosticSeverity.Warning, + source: 'ex', + }, + { + message: 'OS is all uppercase.', + range: toRange(0, 18, 0, 20), + severity: vscode.DiagnosticSeverity.Warning, + source: 'ex', + }, + ]); + }); }); function toRange(sLine: number, sChar: number, eLine: number, eChar: number) { - const start = new vscode.Position(sLine, sChar); - const end = new vscode.Position(eLine, eChar); - return new vscode.Range(start, end); + const start = new vscode.Position(sLine, sChar); + const end = new vscode.Position(eLine, eChar); + return new vscode.Range(start, end); } -async function testDiagnostics(docUri: vscode.Uri, expectedDiagnostics: vscode.Diagnostic[]) { - await activate(docUri); +async function testDiagnostics( + docUri: vscode.Uri, + expectedDiagnostics: vscode.Diagnostic[], +) { + await activate(docUri); - const actualDiagnostics = vscode.languages.getDiagnostics(docUri); + const actualDiagnostics = vscode.languages.getDiagnostics(docUri); - assert.equal(actualDiagnostics.length, expectedDiagnostics.length); + assert.equal(actualDiagnostics.length, expectedDiagnostics.length); - expectedDiagnostics.forEach((expectedDiagnostic, i) => { - const actualDiagnostic = actualDiagnostics[i]; - assert.equal(actualDiagnostic.message, expectedDiagnostic.message); - assert.deepEqual(actualDiagnostic.range, expectedDiagnostic.range); - assert.equal(actualDiagnostic.severity, expectedDiagnostic.severity); - }); -} \ No newline at end of file + expectedDiagnostics.forEach((expectedDiagnostic, i) => { + const actualDiagnostic = actualDiagnostics[i]; + assert.equal(actualDiagnostic.message, expectedDiagnostic.message); + assert.deepEqual(actualDiagnostic.range, expectedDiagnostic.range); + assert.equal(actualDiagnostic.severity, expectedDiagnostic.severity); + }); +} diff --git a/client/src/test/helper.ts b/client/src/test/helper.ts index 6e6724d..5c63f66 100644 --- a/client/src/test/helper.ts +++ b/client/src/test/helper.ts @@ -15,33 +15,33 @@ export let platformEol: string; * Activates the vscode.lsp-sample extension */ export async function activate(docUri: vscode.Uri) { - // The extensionId is `publisher.name` from package.json - const ext = vscode.extensions.getExtension('vscode-samples.lsp-sample')!; - await ext.activate(); - try { - doc = await vscode.workspace.openTextDocument(docUri); - editor = await vscode.window.showTextDocument(doc); - await sleep(2000); // Wait for server activation - } catch (e) { - console.error(e); - } + // The extensionId is `publisher.name` from package.json + const ext = vscode.extensions.getExtension('vscode-samples.lsp-sample')!; + await ext.activate(); + try { + doc = await vscode.workspace.openTextDocument(docUri); + editor = await vscode.window.showTextDocument(doc); + await sleep(2000); // Wait for server activation + } catch (e) { + console.error(e); + } } async function sleep(ms: number) { - return new Promise(resolve => setTimeout(resolve, ms)); + return new Promise((resolve) => setTimeout(resolve, ms)); } export const getDocPath = (p: string) => { - return path.resolve(__dirname, '../../testFixture', p); + return path.resolve(__dirname, '../../testFixture', p); }; export const getDocUri = (p: string) => { - return vscode.Uri.file(getDocPath(p)); + return vscode.Uri.file(getDocPath(p)); }; export async function setTestContent(content: string): Promise { - const all = new vscode.Range( - doc.positionAt(0), - doc.positionAt(doc.getText().length) - ); - return editor.edit(eb => eb.replace(all, content)); + const all = new vscode.Range( + doc.positionAt(0), + doc.positionAt(doc.getText().length), + ); + return editor.edit((eb) => eb.replace(all, content)); } diff --git a/client/src/test/index.ts b/client/src/test/index.ts index b9de4dc..d5cbae5 100644 --- a/client/src/test/index.ts +++ b/client/src/test/index.ts @@ -7,37 +7,37 @@ import * as Mocha from 'mocha'; import * as glob from 'glob'; export function run(): Promise { - // Create the mocha test - const mocha = new Mocha({ - ui: 'tdd', - color: true - }); - mocha.timeout(100000); + // Create the mocha test + const mocha = new Mocha({ + ui: 'tdd', + color: true, + }); + mocha.timeout(100000); - const testsRoot = __dirname; + const testsRoot = __dirname; - return new Promise((resolve, reject) => { - glob('**.test.js', { cwd: testsRoot }, (err, files) => { - if (err) { - return reject(err); - } + return new Promise((resolve, reject) => { + glob('**.test.js', { cwd: testsRoot }, (err, files) => { + if (err) { + return reject(err); + } - // Add files to the test suite - files.forEach(f => mocha.addFile(path.resolve(testsRoot, f))); + // Add files to the test suite + files.forEach((f) => mocha.addFile(path.resolve(testsRoot, f))); - try { - // Run the mocha test - mocha.run(failures => { - if (failures > 0) { - reject(new Error(`${failures} tests failed.`)); - } else { - resolve(); - } - }); - } catch (err) { - console.error(err); - reject(err); - } - }); - }); -} \ No newline at end of file + try { + // Run the mocha test + mocha.run((failures) => { + if (failures > 0) { + reject(new Error(`${failures} tests failed.`)); + } else { + resolve(); + } + }); + } catch (err) { + console.error(err); + reject(err); + } + }); + }); +} diff --git a/client/src/test/runTest.ts b/client/src/test/runTest.ts index f06f788..339afee 100644 --- a/client/src/test/runTest.ts +++ b/client/src/test/runTest.ts @@ -7,21 +7,21 @@ import * as path from 'path'; import { runTests } from '@vscode/test-electron'; async function main() { - try { - // The folder containing the Extension Manifest package.json - // Passed to `--extensionDevelopmentPath` - const extensionDevelopmentPath = path.resolve(__dirname, '../../../'); + try { + // The folder containing the Extension Manifest package.json + // Passed to `--extensionDevelopmentPath` + const extensionDevelopmentPath = path.resolve(__dirname, '../../../'); - // The path to test runner - // Passed to --extensionTestsPath - const extensionTestsPath = path.resolve(__dirname, './index'); + // The path to test runner + // Passed to --extensionTestsPath + const extensionTestsPath = path.resolve(__dirname, './index'); - // Download VS Code, unzip it and run the integration test - await runTests({ extensionDevelopmentPath, extensionTestsPath }); - } catch (err) { - console.error('Failed to run tests'); - process.exit(1); - } + // Download VS Code, unzip it and run the integration test + await runTests({ extensionDevelopmentPath, extensionTestsPath }); + } catch (err) { + console.error('Failed to run tests'); + process.exit(1); + } } main(); diff --git a/package-lock.json b/package-lock.json index 16f0eb8..9ffb4ae 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "vscode-nushell-lang", - "version": "1.7.1", + "version": "1.8.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "vscode-nushell-lang", - "version": "1.7.1", + "version": "1.8.0", "hasInstallScript": true, "license": "MIT", "dependencies": { @@ -26,6 +26,7 @@ "esbuild": "^0.14.42", "eslint": "^8.35.0", "mocha": "^9.2.1", + "prettier": "3.2.5", "ts-loader": "^9.2.8", "typescript": "^5.0.2", "webpack": "^5.70.0", @@ -3872,6 +3873,21 @@ "node": ">= 0.8.0" } }, + "node_modules/prettier": { + "version": "3.2.5", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.2.5.tgz", + "integrity": "sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==", + "dev": true, + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, "node_modules/process-nextick-args": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", diff --git a/package.json b/package.json index 23d608a..8ef574b 100644 --- a/package.json +++ b/package.json @@ -139,25 +139,27 @@ "install": "cd server && npm install && cd ../client && npm install && cd ..", "watch": "npm run esbuild-base -- --sourcemap --watch", "lint": "npx eslint ./client/src ./server/src --ext .ts,.tsx", - "test": "sh ./scripts/e2e.sh" + "test": "sh ./scripts/e2e.sh", + "fmt": "prettier . --write" }, "dependencies": { "glob": "^7.2.0", - "os": "^0.1.2", + "nushell-lsp-client": "file:client", "nushell-lsp-server": "file:server", - "nushell-lsp-client": "file:client" + "os": "^0.1.2" }, "devDependencies": { "@types/mocha": "^9.1.0", "@types/node": "^16.11.7", - "@types/vscode": "^1.65.0", "@types/tmp": "^0.2.3", + "@types/vscode": "^1.65.0", "@typescript-eslint/eslint-plugin": "^5.54.0", "@typescript-eslint/parser": "^5.54.0", "@vscode/vsce": "^2.15.0", "esbuild": "^0.14.42", "eslint": "^8.35.0", "mocha": "^9.2.1", + "prettier": "3.2.5", "ts-loader": "^9.2.8", "typescript": "^5.0.2", "webpack": "^5.70.0", diff --git a/server/src/server.ts b/server/src/server.ts index ab0a83c..03a3206 100644 --- a/server/src/server.ts +++ b/server/src/server.ts @@ -18,7 +18,7 @@ import { TextDocumentSyncKind, TextDocuments, createConnection, -} from "vscode-languageserver/node"; +} from 'vscode-languageserver/node'; import { InlayHint, @@ -26,26 +26,25 @@ import { InlayHintLabelPart, InlayHintParams, Position, -} from "vscode-languageserver-protocol"; +} from 'vscode-languageserver-protocol'; -import { TextEncoder } from "node:util"; -import { TextDocument } from "vscode-languageserver-textdocument"; +import { TextEncoder } from 'node:util'; +import { TextDocument } from 'vscode-languageserver-textdocument'; import { URI } from 'vscode-uri'; - interface NuTextDocument extends TextDocument { nuInlayHints?: InlayHint[]; } -import fs = require("fs"); -import tmp = require("tmp"); -import path = require("path"); +import fs = require('fs'); +import tmp = require('tmp'); +import path = require('path'); -import util = require("node:util"); +import util = require('node:util'); // eslint-disable-next-line @typescript-eslint/no-var-requires -const exec = util.promisify(require("node:child_process").exec); +const exec = util.promisify(require('node:child_process').exec); -const tmpFile = tmp.fileSync({ prefix: "nushell", keep: false }); +const tmpFile = tmp.fileSync({ prefix: 'nushell', keep: false }); // Create a connection for the server, using Node's IPC as a transport. // Also include all preview / proposed LSP features. @@ -60,10 +59,10 @@ let hasDiagnosticRelatedInformationCapability = false; function includeFlagForPath(file_path: string): string { const parsed = URI.parse(file_path); - if (parsed.scheme === "file") { - return "-I " + '"' + path.dirname(parsed.fsPath); + if (parsed.scheme === 'file') { + return '-I ' + '"' + path.dirname(parsed.fsPath); } - return "-I " + '"' + file_path; + return '-I ' + '"' + file_path; } connection.onExit(() => { @@ -117,16 +116,16 @@ function createLabel(name: string): string { } async function durationLogWrapper( name: string, - fn: (label: string) => Promise + fn: (label: string) => Promise, ): Promise { - console.log("Triggered " + name + ": ..."); + console.log('Triggered ' + name + ': ...'); const label = createLabel(name); console.time(label); const result = await fn(label); // This purposefully has the same prefix length as the "Triggered " log above, // also does not add a newline at the end. - process.stdout.write("Finished "); + process.stdout.write('Finished '); console.timeEnd(label); return new Promise((resolve) => resolve(result)); } @@ -136,12 +135,12 @@ connection.onInitialized(() => { // Register for all configuration changes. connection.client.register( DidChangeConfigurationNotification.type, - undefined + undefined, ); } if (hasWorkspaceFolderCapability) { connection.workspace.onDidChangeWorkspaceFolders((_event) => { - connection.console.log("Workspace folder change event received."); + connection.console.log('Workspace folder change event received.'); }); } }); @@ -163,7 +162,7 @@ interface NushellIDESettings { const defaultSettings: NushellIDESettings = { maxNumberOfProblems: 1000, hints: { showInferredTypes: true }, - nushellExecutablePath: "nu", + nushellExecutablePath: 'nu', maxNushellInvocationTime: 10000000, includeDirs: [], }; @@ -194,7 +193,7 @@ function getDocumentSettings(resource: string): Thenable { if (!result) { result = connection.workspace.getConfiguration({ scopeUri: resource, - section: "nushellLanguageServer", + section: 'nushellLanguageServer', }); documentSettings.set(resource, result); } @@ -230,24 +229,24 @@ documents.onDidChangeContent( const throttledValidateTextDocument = debounce( validateTextDocument, 500, - false + false, ); return (change) => { throttledValidateTextDocument(change.document); }; - })() + })(), ); async function validateTextDocument( - textDocument: NuTextDocument + textDocument: NuTextDocument, ): Promise { return await durationLogWrapper( `validateTextDocument ${textDocument.uri}`, async (label) => { if (!hasDiagnosticRelatedInformationCapability) { console.error( - "Trying to validate a document with no diagnostic capability" + 'Trying to validate a document with no diagnostic capability', ); return; } @@ -261,10 +260,10 @@ async function validateTextDocument( const stdout = await runCompiler( text, - "--ide-check", + '--ide-check', settings, textDocument.uri, - { label: label } + { label: label }, ); textDocument.nuInlayHints = []; @@ -274,26 +273,26 @@ async function validateTextDocument( // It'd be nicer if it didn't give duplicate hints in the first place. const seenTypeHintPositions = new Set(); - const lines = stdout.split("\n").filter((l) => l.length > 0); + const lines = stdout.split('\n').filter((l) => l.length > 0); for (const line of lines) { - connection.console.log("line: " + line); + connection.console.log('line: ' + line); try { const obj = JSON.parse(line); - if (obj.type == "diagnostic") { + if (obj.type == 'diagnostic') { let severity: DiagnosticSeverity = DiagnosticSeverity.Error; switch (obj.severity) { - case "Information": + case 'Information': severity = DiagnosticSeverity.Information; break; - case "Hint": + case 'Hint': severity = DiagnosticSeverity.Hint; break; - case "Warning": + case 'Warning': severity = DiagnosticSeverity.Warning; break; - case "Error": + case 'Error': severity = DiagnosticSeverity.Error; break; } @@ -314,15 +313,15 @@ async function validateTextDocument( // connection.console.log(diagnostic.message); diagnostics.push(diagnostic); - } else if (obj.type == "hint" && settings.hints.showInferredTypes) { + } else if (obj.type == 'hint' && settings.hints.showInferredTypes) { if (!seenTypeHintPositions.has(obj.position)) { seenTypeHintPositions.add(obj.position); const position = convertSpan(obj.position.end, lineBreaks); - const hint_string = ": " + obj.typename; + const hint_string = ': ' + obj.typename; const hint = InlayHint.create( position, [InlayHintLabelPart.create(hint_string)], - InlayHintKind.Type + InlayHintKind.Type, ); textDocument.nuInlayHints.push(hint); @@ -335,13 +334,13 @@ async function validateTextDocument( // Send the computed diagnostics to VSCode. connection.sendDiagnostics({ uri: textDocument.uri, diagnostics }); - } + }, ); } connection.onDidChangeWatchedFiles((_change) => { // Monitored files have change in VSCode - connection.console.log("We received an file change event"); + connection.console.log('We received an file change event'); }); function lowerBoundBinarySearch(arr: number[], num: number): number { @@ -404,7 +403,7 @@ async function runCompiler( flags: string, settings: NushellIDESettings, uri: string, - options: { allowErrors?: boolean, label: string } = { label: "runCompiler" }, + options: { allowErrors?: boolean; label: string } = { label: 'runCompiler' }, ): Promise { const allowErrors = options.allowErrors === undefined ? true : options.allowErrors; @@ -413,32 +412,34 @@ async function runCompiler( fs.writeFileSync(tmpFile.name, text); // eslint-disable-next-line @typescript-eslint/no-explicit-any } catch (e: any) { - connection.console.error(`[${options.label}] error writing to tmp file: ${e}`); + connection.console.error( + `[${options.label}] error writing to tmp file: ${e}`, + ); } - let stdout = ""; + let stdout = ''; try { const script_path_flag = includeFlagForPath(uri) + - "\x1e" + // \x1e is the record separator character (a character that is unlikely to appear in a path) - settings.includeDirs.join("\x1e") + + '\x1e' + // \x1e is the record separator character (a character that is unlikely to appear in a path) + settings.includeDirs.join('\x1e') + '"'; const max_errors = settings.maxNumberOfProblems; - if (flags.includes("ide-check")) { - flags = flags + " " + max_errors; + if (flags.includes('ide-check')) { + flags = flags + ' ' + max_errors; } connection.console.log( - `[${options.label}] running: ${settings.nushellExecutablePath} ${flags} ${script_path_flag} ${tmpFile.name}` + `[${options.label}] running: ${settings.nushellExecutablePath} ${flags} ${script_path_flag} ${tmpFile.name}`, ); const output = await exec( `${settings.nushellExecutablePath} ${flags} ${script_path_flag} ${tmpFile.name}`, { timeout: settings.maxNushellInvocationTime, - } + }, ); stdout = output.stdout; console.log(`[${options.label}] stdout: ${stdout}`); @@ -461,19 +462,19 @@ connection.onHover(async (request: HoverParams) => { const text = document?.getText(); - if (!(typeof text == "string")) return null; + if (!(typeof text == 'string')) return null; // connection.console.log("request: "); // connection.console.log(request.textDocument.uri); // connection.console.log("index: " + convertPosition(request.position, text)); const stdout = await runCompiler( text, - "--ide-hover " + convertPosition(request.position, text), + '--ide-hover ' + convertPosition(request.position, text), settings, - request.textDocument.uri + request.textDocument.uri, ); - const lines = stdout.split("\n").filter((l) => l.length > 0); + const lines = stdout.split('\n').filter((l) => l.length > 0); for (const line of lines) { const obj = JSON.parse(line); // connection.console.log("hovering"); @@ -486,12 +487,12 @@ connection.onHover(async (request: HoverParams) => { kind: "markdown" }; - if (obj.hover != "") { + if (obj.hover != '') { if (obj.span) { const lineBreaks = findLineBreaks( obj.file ? (await fs.promises.readFile(obj.file)).toString() - : document?.getText() ?? "" + : document?.getText() ?? '', ); return { @@ -522,20 +523,20 @@ connection.onCompletion( const text = document?.getText(); - if (typeof text == "string") { + if (typeof text == 'string') { // connection.console.log("completion request: "); // connection.console.log(request.textDocument.uri); const index = convertPosition(request.position, text); // connection.console.log("index: " + index); const stdout = await runCompiler( text, - "--ide-complete " + index, + '--ide-complete ' + index, settings, - request.textDocument.uri + request.textDocument.uri, ); // connection.console.log("got: " + stdout); - const lines = stdout.split("\n").filter((l) => l.length > 0); + const lines = stdout.split('\n').filter((l) => l.length > 0); for (const line of lines) { const obj = JSON.parse(line); // connection.console.log("completions"); @@ -546,7 +547,7 @@ connection.onCompletion( for (const completion of obj.completions) { output.push({ label: completion, - kind: completion.includes("(") + kind: completion.includes('(') ? CompletionItemKind.Function : CompletionItemKind.Field, data: index, @@ -559,7 +560,7 @@ connection.onCompletion( return []; }); - } + }, ); connection.onDefinition(async (request) => { @@ -574,10 +575,10 @@ connection.onDefinition(async (request) => { // connection.console.log("index: " + convertPosition(request.position, text)); const stdout = await runCompiler( text, - "--ide-goto-def " + convertPosition(request.position, text), + '--ide-goto-def ' + convertPosition(request.position, text), settings, request.textDocument.uri, - { label: label } + { label: label }, ); return goToDefinition(document, stdout); }); @@ -591,19 +592,21 @@ connection.onCompletionResolve((item: CompletionItem): CompletionItem => { async function goToDefinition( document: TextDocument, - nushellOutput: string + nushellOutput: string, ): Promise | undefined> { - const lines = nushellOutput.split("\n").filter((l) => l.length > 0); + const lines = nushellOutput.split('\n').filter((l) => l.length > 0); for (const line of lines) { const obj = JSON.parse(line); // connection.console.log("going to type definition"); // connection.console.log(obj); - if (obj.file === "" || obj.file === "__prelude__") return; + if (obj.file === '' || obj.file === '__prelude__') return; let documentText: string; if (obj.file) { if (fs.existsSync(obj.file)) { - documentText = await fs.promises.readFile(obj.file).then((b) => b.toString()); + documentText = await fs.promises + .readFile(obj.file) + .then((b) => b.toString()); } else { connection.console.log(`File ${obj.file} does not exist`); return; @@ -614,7 +617,7 @@ async function goToDefinition( const lineBreaks: number[] = findLineBreaks(documentText); - let uri = ""; + let uri = ''; if (obj.file == tmpFile.name) { uri = document.uri; } else { diff --git a/snippets/convention.md b/snippets/convention.md index ee0fb0a..418104b 100644 --- a/snippets/convention.md +++ b/snippets/convention.md @@ -54,11 +54,11 @@ is no snippet for this command without subcommands. Write this: ```json { - "hash builtin": { - "prefix": "hash", - "description": "\"hash\" invocation", - "body": "${1:command} | hash ${2|md5,sha256|}" - } + "hash builtin": { + "prefix": "hash", + "description": "\"hash\" invocation", + "body": "${1:command} | hash ${2|md5,sha256|}" + } } ``` @@ -66,15 +66,15 @@ instead of: ```json { - "hash md5 builtin": { - "prefix": "hash-md5", - "description": "\"hash md5\" invocation", - "body": "${1:command} | hash md5" - }, - "hash sha256 builtin": { - "prefix": "hash-sha256", - "description": "\"hash sha256\" invocation", - "body": "${1:command} | hash sha256" - } + "hash md5 builtin": { + "prefix": "hash-md5", + "description": "\"hash md5\" invocation", + "body": "${1:command} | hash md5" + }, + "hash sha256 builtin": { + "prefix": "hash-sha256", + "description": "\"hash sha256\" invocation", + "body": "${1:command} | hash sha256" + } } ``` diff --git a/snippets/nushell.json b/snippets/nushell.json index 9d23cb3..051155c 100644 --- a/snippets/nushell.json +++ b/snippets/nushell.json @@ -1,1467 +1,1406 @@ { - "shebang": { - "prefix": "shebang", - "description": "shebang", - "body": "#!/usr/bin/env nu" - }, - "hexadecimal": { - "prefix": [ - "hexadecimal", - "0x" - ], - "description": "hexadecimal", - "body": "0x[${1:ff}]" - }, - "binary": { - "prefix": [ - "binary", - "0b" - ], - "description": "binary", - "body": "0b[${1:1}]" - }, - "octal": { - "prefix": [ - "octal", - "0o" - ], - "description": "octal", - "body": "0o[${1:1}]" - }, - "date": { - "prefix": "date", - "description": "date", - "body": "${1:2000}-${2|01,02,03,04,05,06,07,08,09,10,11,12|}-${3|01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31|}" - }, - "duration": { - "prefix": "duration", - "description": "duration", - "body": "${1:value}${2|ns,us,ms,sec,min,hr,day,wk|}" - }, - "filesize": { - "prefix": "size", - "description": "size", - "body": "${1:value}${2|b,kb,mb,gb,tb,pb,eb,zb,kib,mib,gib,tib,pib,eib,zib|}" - }, - "in": { - "prefix": "in", - "description": "\"in\" operator", - "body": "${1:value} in ${2:list}" - }, - "not-in": { - "prefix": "not-in", - "description": "\"not-in\" operator", - "body": "${1:value} not-in ${2:list}" - }, - "flag": { - "prefix": [ - "flag", - "--" - ], - "description": "flag", - "body": "--${1:long} (-${2:short}): ${3:type}" - }, - "rest": { - "prefix": [ - "rest", - "..." - ], - "description": "flag", - "body": "...${1:name}: ${2:type}" - }, - "year": { - "prefix": "year", - "description": "year", - "body": "%${1|y,Y|}" - }, - "month": { - "prefix": "month", - "description": "month", - "body": "%${1|m,b,B|}" - }, - "day": { - "prefix": "day", - "description": "day", - "body": "%${1|d,j|}" - }, - "weekday": { - "prefix": "weekday", - "description": "weekday", - "body": "%${1|a,A|}" - }, - "hour": { - "prefix": "hour", - "description": "hour", - "body": "%${1|H,I,P,p|}" - }, - "minute": { - "prefix": "minute", - "description": "minute", - "body": "%M" - }, - "second": { - "prefix": "second", - "description": "second", - "body": "%${1|S,f|}" - }, - "time": { - "prefix": "time", - "description": "time", - "body": "${1|%H-%M-%S,%H-%M,%H:%M:%S,%H:%M|}" - }, - "capture group": { - "prefix": "capture-group", - "description": "regex group", - "body": "(?<${1:name}>${2:value})" - }, - "non-capturing group": { - "prefix": "non-capturing-group", - "description": "regex group", - "body": "(?:${1:value})" - }, - "alias": { - "prefix": "alias", - "description": "\"alias\" invocation", - "body": "alias ${1:name} = ${2:value}" - }, - "@alias": { - "prefix": "@alias", - "description": "\"alias\" invocation", - "body": [ - "# ${1:documentation}", - "alias ${2:name} = ${3:value}" - ] - }, - "all": { - "prefix": "all", - "description": "\"all\" invocation", - "body": "${1:command} | all {|${2:el}| ${3:predicate} }" - }, - "ansi": { - "prefix": "ansi", - "description": "\"ansi\" invocation", - "body": "ansi ${3|black,red,green,yellow,blue,magenta,cyan,white,default,reset|}" - }, - "ansi gradient": { - "prefix": "ansi-gradient", - "description": "\"ansi gradient\" invocation", - "body": "ansi gradient --${1|fg,bg|}start ${2:0xffffff} --$1end ${3:0xffffff}" - }, - "ansi link": { - "prefix": "ansi-link", - "description": "\"ansi link\" invocation", - "body": "ansi link --text ${1:value}" - }, - "any": { - "prefix": "any", - "description": "\"any\" invocation", - "body": "${1:command} | any {|${2:el}| ${3:predicate} }" - }, - "append": { - "prefix": "append", - "description": "\"append\" invocation", - "body": "${1:command} | append ${2:row}" - }, - "ast": { - "prefix": "ast", - "description": "\"ast\" invocation", - "body": "ast ${1:pipeline}" - }, - "bits": { - "prefix": "bits", - "description": "\"bits\" invocation", - "body": "${1:command} | bits ${2|and,or,rol,ror,shl,shr,xor|} ${3:value}" - }, - "bits not": { - "prefix": "bits-not", - "description": "\"bits not\" invocation", - "body": "${1:command} | bits not" - }, - "bytes": { - "prefix": "bytes", - "description": "\"bytes\" invocation", - "body": "${1:command} | bytes ${2|add,collect,ends-with,index-of,remove,starts-with|} ${3:value}" - }, - "bytes at": { - "prefix": "bytes-at", - "description": "\"bytes at\" invocation", - "body": "${1:command} | bytes at ${2:from}..${3:to}" - }, - "bytes replace": { - "prefix": "bytes-replace", - "description": "\"bytes replace\" invocation", - "body": "${1:command} | bytes replace ${2:search} ${3:replacement}" - }, - "cd": { - "prefix": "cd", - "description": "\"cd\" invocation", - "body": "cd ${1:path/to/directory}" - }, - "char": { - "prefix": "char", - "description": "\"char\" invocation", - "body": "char ${1|newline,enter,nl,line_feed,lf,carriage_return,cr,crlf,tab|}" - }, - "collect": { - "prefix": "collect", - "description": "\"collect\" invocation", - "body": "${1:command} | collect {|${2:el}| ${3:command ...} }" - }, - "commandline": { - "prefix": "commandline", - "description": "\"commandline\" invocation", - "body": "commandline ${1:command}" - }, - "complete": { - "prefix": "complete", - "description": "\"complete\" invocation", - "body": "^${1:command} | complete" - }, - "compact": { - "prefix": "compact", - "description": "\"compact\" invocation", - "body": "${1:command} | compact" - }, - "config": { - "prefix": "config", - "description": "\"config\" invocation", - "body": "config ${1|env,nu,reset|}" - }, - "const": { - "prefix": "const", - "description": "\"const\" invocation", - "body": "const ${1:name} = ${2:value}" - }, - "@const": { - "prefix": "@const", - "description": "\"const\" invocation", - "body": [ - "# ${1:documentation}", - "const ${2:name} = ${3:value}" - ] - }, - "cp": { - "prefix": "cp", - "description": "\"cp\" invocation", - "body": "cp ${1:path/to/from} ${2:path/to/to}" - }, - "date format": { - "prefix": "date-format", - "description": "\"date format\" invocation", - "body": "date format ${1:%Y-%m-%d %H:%M:%S}" - }, - "date humanize": { - "prefix": "date-humanize", - "description": "\"date humanize\" invocation", - "body": "${1:command} | date humanize" - }, - "decode": { - "prefix": "decode", - "description": "\"decode\" invocation", - "body": "${1:command} | decode ${1|big5,euc-jp,euc-kr,gbk,iso-8859-1,utf-16,cp1252,latin5|}" - }, - "decode base64": { - "prefix": "decode-base64", - "description": "\"decode base64\" invocation", - "body": "${1:command} | decode base64" - }, - "decode hex": { - "prefix": "decode-hex", - "description": "\"decode hex\" invocation", - "body": "${1:command} | decode hex" - }, - "def": { - "prefix": "def", - "description": "\"def\" invocation", - "body": [ - "def ${1:name} [${2:param}: ${3:type}${4:, }] {", - "\t${5:command ...}$0", - "}" - ] - }, - "@def": { - "prefix": "@def", - "description": "\"def\" invocation", - "body": [ - "# ${1:documentation}", - "def ${2:name} [${3:param}: ${4:type}${5:, }] {", - "\t${6:command}$0", - "}" - ] - }, - "def-env": { - "prefix": "def-env", - "description": "\"def-env\" invocation", - "body": [ - "def --env ${1:name} [${2:param}: ${3:type}${4:, }] {", - "\t${5:command ...}$0", - "}" - ] - }, - "@def-env": { - "prefix": "@def-env", - "description": "\"def-env\" invocation", - "body": [ - "# ${1:documentation}", - "def --env ${2:name} [${3:param}: ${4:type}${5:, }] {", - "\t${6:command ...}$0", - "}" - ] - }, - "def-wrapped": { - "prefix": "def-wrapped", - "description": "\"def-wrapped\" invocation", - "body": [ - "def --wrapped ${1:name} [...${2:rest}] {", - "\t${3:command ...}$0", - "}" - ] - }, - "@def-wrapped": { - "prefix": "@def-wrapped", - "description": "\"def-wrapped\" invocation", - "body": [ - "# ${1:documentation}", - "def --wrapped ${2:name} [...${3:rest}] {", - "\t${4:command ...}$0", - "}" - ] - }, - "default": { - "prefix": "default", - "description": "\"default\" invocation", - "body": "${1:command} | default ${2:default} ${3:column}" - }, - "describe": { - "prefix": "describe", - "description": "\"describe\" invocation", - "body": "${1:command} | describe" - }, - "detect columns": { - "prefix": "detect-columns", - "description": "\"detect columns\" invocation", - "body": "${1:command} | detect columns" - }, - "do": { - "prefix": "do", - "description": "\"do\" invocation", - "body": "do { ${1:command ...} }" - }, - "drop": { - "prefix": "drop", - "description": "\"drop\" invocation", - "body": "${1:command} | drop ${2:rows}" - }, - "drop columns": { - "prefix": "drop-columns", - "description": "\"drop columns\" invocation", - "body": "${1:command} | drop columns ${2:numbers}" - }, - "drop nth": { - "prefix": "drop-nth", - "description": "\"drop nth\" invocation", - "body": "${1:command} | drop nth ${2:rows}" - }, - "du": { - "prefix": "du", - "description": "\"du\" invocation", - "body": "du ${1:path/to/directory}" - }, - "each": { - "prefix": "each", - "description": "\"each\" invocation", - "body": "${1:command} | each {|${2:el}| ${3:command ...} }" - }, - "each while": { - "prefix": "each-while", - "description": "\"each while\" invocation", - "body": "${1:command} | each while {|${2:el}| ${3:command ...} }" - }, - "encode": { - "prefix": "encode", - "description": "\"encode\" invocation", - "body": "${1:command} | encode ${2|big5,euc-jp,euc-kr,gbk,iso-8859-1,utf-16,cp1252,latin5|}" - }, - "encode base64": { - "prefix": "encode-base64", - "description": "\"encode base64\" invocation", - "body": "${1:command} | encode base64" - }, - "encode hex": { - "prefix": "encode-hex", - "description": "\"encode hex\" invocation", - "body": "${1:command} | encode hex" - }, - "enter": { - "prefix": "enter", - "description": "\"enter\" invocation", - "body": "enter ${1:path/to/directory}" - }, - "enumerate": { - "prefix": "enumerate", - "description": "\"enumerate\" invocation", - "body": "${1:command} | enumerate" - }, - "error make": { - "prefix": "error-make", - "description": "\"error make\" invocation", - "body": "error make {${1:msg}: ${2:message}${3:, }}" - }, - "every": { - "prefix": "every", - "description": "\"every\" invocation", - "body": "${1:command} | every ${2:stride}" - }, - "exec": { - "prefix": "exec", - "description": "\"exec\" invocation", - "body": "exec ${1:command}" - }, - "exit": { - "prefix": "exit", - "description": "\"exit\" invocation", - "body": "exit ${1:code}" - }, - "explain": { - "prefix": "explain", - "description": "\"explain\" invocation", - "body": "explain {|| ${1:command ...} }" - }, - "explore": { - "prefix": "explore", - "description": "\"explore\" invocation", - "body": "${1:command} | explore" - }, - "export": { - "prefix": "export", - "description": "\"export\" invocation", - "body": "export ${1:definition}" - }, - "export alias": { - "prefix": "export-alias", - "description": "\"export alias\" invocation", - "body": "export alias ${1:name} = ${2:value}" - }, - "export def": { - "prefix": "export-def", - "description": "\"export def\" invocation", - "body": [ - "export def ${1:name} [${2:param}: ${3:type}${4:, }] {", - "\t${5:command ...}", - "}" - ] - }, - "export def-env": { - "prefix": "export-def-env", - "description": "\"export def-env\" invocation", - "body": [ - "export def --env ${1:name} [${2:param}: ${3:type}${4:, }] {", - "\t${5:command ...}", - "}" - ] - }, - "export extern": { - "prefix": "export-extern", - "description": "\"export extern\" invocation", - "body": "export extern ${1:name} [${2:param}: string${3:, }]" - }, - "export old-alias": { - "prefix": "export-old-alias", - "description": "\"export old-alias\" invocation", - "body": "export old-alias ${1:name} = ${2:value}" - }, - "export use": { - "prefix": "export-use", - "description": "\"export use\" invocation", - "body": "export use ${1:module} ${2:members}" - }, - "export env": { - "prefix": "export-env", - "description": "\"export env\" invocation", - "body": "export env { ${1:command ...} }" - }, - "extern": { - "prefix": "extern", - "description": "\"extern\" invocation", - "body": "extern ${1:name} [${2:param}: string${3:, }]" - }, - "fill": { - "prefix": "fill", - "description": "\"fill\" invocation", - "body": "${1:command} | fill --width ${2:value}" - }, - "filter": { - "prefix": "filter", - "description": "\"filter\" invocation", - "body": "${1:command} | filter {|${2:el}| ${3:predicate} }" - }, - "find": { - "prefix": "find", - "description": "\"find\" invocation", - "body": "${1:command} | find" - }, - "first": { - "prefix": "first", - "description": "\"first\" invocation", - "body": "${1:command} | first ${2:count}" - }, - "flatten": { - "prefix": "flatten", - "description": "\"flatten\" invocation", - "body": "${1:command} | flatten" - }, - "fmt": { - "prefix": "fmt", - "description": "\"fmt\" invocation", - "body": "${1:command} | fmt" - }, - "for": { - "prefix": "for", - "description": "for operator", - "body": [ - "for ${1:variable} in ${2:list} {", - "\t${3:command ...}", - "}" - ] - }, - "for-range": { - "prefix": "for-range", - "description": "for with range", - "body": [ - "for ${1:item} in ${2:from}..${3:to} {", - "\t${4:command ...}", - "}" - ] - }, - "for-stepped-range": { - "prefix": "for-stepped-range", - "description": "for with stepped range", - "body": [ - "for ${1:item} in ${2:from}..${3:step}..${4:to}) {", - "\t${5:command ...}", - "}" - ] - }, - "for-files": { - "prefix": "for-files", - "description": "for with files", - "body": [ - "for ${1:item} in (ls *.${2:extension})", - "\t${3:command ...}", - "}" - ] - }, - "format": { - "prefix": "format", - "description": "\"format\" invocation", - "body": "${1:command} | format ${2:value}" - }, - "format filesize": { - "prefix": "format-filesize", - "description": "\"format filesize\" invocation", - "body": "${1:command} | format filesize ${2|b,kb,mb,gb,tb,pb,eb,zb,kib,mib,gib,tib,pib,eib,zib|} ${3:column}" - }, - "from": { - "prefix": "from", - "description": "\"from\" invocation", - "body": "${1:command} | from ${2|csv,eml,ics,ini,json,nuon,ods,ssv,toml,tsc,url,vcf,xlsx,xml,yaml,yml|}" - }, - "g": { - "prefix": "g", - "description": "\"g\" invocation", - "body": "g ${1:shell}" - }, - "get": { - "prefix": "get", - "description": "\"get\" invocation", - "body": "${1:command} | get ${2:path/to/cell}" - }, - "glob": { - "prefix": "glob", - "description": "\"glob\" invocation", - "body": "glob ${1:pattern}" - }, - "grid": { - "prefix": "grid", - "description": "\"grid\" invocation", - "body": "${1:command} | grid" - }, - "group": { - "prefix": "group", - "description": "\"group\" invocation", - "body": "${1:command} | group ${2:count}" - }, - "group-by": { - "prefix": "group-by", - "description": "\"group-by\" invocation", - "body": "${1:command} | group-by ${2:grouper}" - }, - "gstat": { - "prefix": "gstat", - "description": "\"gstat\" invocation", - "body": "gstat ${1:path/to/repository}" - }, - "hash": { - "prefix": "hash", - "description": "\"hash\" invocation", - "body": "${1:command} | hash ${2|md5,sha256|}" - }, - "headers": { - "prefix": "headers", - "description": "\"headers\" invocation", - "body": "${1:command} | headers" - }, - "help": { - "prefix": "help", - "description": "\"help\" invocation", - "body": "help ${1|aliases,commands,externs,modules,operators|}" - }, - "hide": { - "prefix": "hide", - "description": "\"hide\" invocation", - "body": "hide ${1:definitions}" - }, - "hide-env": { - "prefix": "hide-env", - "description": "\"hide-env\" invocation", - "body": "hide-env ${1:variables}" - }, - "histogram": { - "prefix": "histogram", - "description": "\"histogram\" invocation", - "body": "${1:command} | histogram ${2:column} ${3:frequency-column}" - }, - "http": { - "prefix": "http", - "description": "\"http\" invocation", - "body": "http ${1|delete,get,head|} ${1:url}" - }, - "http patch": { - "prefix": "http-patch", - "description": "\"http patch\" invocation", - "body": "http patch ${1:url} ${2:data}" - }, - "http post": { - "prefix": "http-post", - "description": "\"http post\" invocation", - "body": "http post ${1:url} ${2:data}" - }, - "http put": { - "prefix": "http-put", - "description": "\"http put\" invocation", - "body": "http put ${1:url} ${2:data}" - }, - "if": { - "prefix": "if", - "description": "if operator", - "body": [ - "if ${1:condition} {", - "\t${2:command ...}", - "}" - ] - }, - "if-else": { - "prefix": "if-else", - "description": "if-else operator", - "body": [ - "if ${1:condition} {", - "\t${2:command ...}", - "} else {", - "\t${3:command ...}", - "}" - ] - }, - "if else if else": { - "prefix": "if-else-if-else operator", - "description": "if-else-if-else operator", - "body": [ - "if ${1:condition} {", - "\t${2:command ...}", - "} else if ${3:condition} {", - "\t${4:command ...}", - "} else {", - "\t${5:command ...}", - "}" - ] - }, - "if-less": { - "prefix": "if-less", - "description": "if with comparison", - "body": [ - "if ${1:first-expression} < ${2:second-expression} {", - "\t${3:command ...}", - "}" - ] - }, - "if-greater": { - "prefix": "if-greater", - "description": "if with comparison", - "body": [ - "if ${1:first-expression} > ${2:second-expression} {", - "\t${3:command ...}", - "}" - ] - }, - "if-less-or-equal": { - "prefix": "if-less-or-equal", - "description": "if with comparison", - "body": [ - "if ${1:first-expression} <= ${2:second-expression} {", - "\t${3:command ...}", - "}" - ] - }, - "if-greater-or-equal": { - "prefix": "if-greater-or-equal", - "description": "if with comparison", - "body": [ - "if ${1:first-expression} >= ${2:second-expression} {", - "\t${3:command ...}", - "}" - ] - }, - "if-equal": { - "prefix": "if-equal", - "description": "if with comparison", - "body": [ - "if ${1:first-expression} == ${2:second-expression} {", - "\t${3:command ...}", - "}" - ] - }, - "if-not-equal": { - "prefix": "if-not-equal", - "description": "if with comparison", - "body": [ - "if ${1:first-expression} != ${2:second-expression} {", - "\t${3:command ...}", - "}" - ] - }, - "ignore": { - "prefix": "ignore", - "description": "\"ignore\" invocation", - "body": "${1:command} | ignore" - }, - "inc": { - "prefix": "inc", - "description": "\"inc\" invocation", - "body": "${1:command} | inc" - }, - "input": { - "prefix": "input", - "description": "\"input\" invocation", - "body": "input ${1:prompt}" - }, - "insert": { - "prefix": "insert", - "description": "\"insert\" invocation", - "body": "${1:command} | insert ${2:column} ${3:value}" - }, - "inspect": { - "prefix": "inspect", - "description": "\"inspect\" invocation", - "body": "${1:command} | inspect" - }, - "into": { - "prefix": "into", - "description": "\"into\" invocation", - "body": "${1:command} | into ${2|binary,bool,datetime,decimal,duration,filesize,int,record,sqlite,string|}" - }, - "is-empty": { - "prefix": "is-empty", - "description": "\"is-empty\" invocation", - "body": "${1:command} | is-empty" - }, - "join": { - "prefix": "join", - "description": "\"join\" invocation", - "body": "${1:command} | join ${2:table} ${3:column}" - }, - "kill": { - "prefix": "kill", - "description": "\"kill\" invocation", - "body": "kill ${1:pid}" - }, - "last": { - "prefix": "last", - "description": "\"last\" invocation", - "body": "${1:command} | last ${2:count}" - }, - "length": { - "prefix": "length", - "description": "\"length\" invocation", - "body": "${1:command} | length" - }, - "let": { - "prefix": "let", - "description": "\"let\" invocation", - "body": "let ${1:name} = ${2:value}" - }, - "@let": { - "prefix": "@let", - "description": "\"let\" invocation", - "body": [ - "# ${1:documentation}", - "let ${2:name} = ${3:value}" - ] - }, - "let-env": { - "prefix": "let-env", - "description": "\"let-env\" invocation", - "body": "let-env ${1:name} = ${2:value}" - }, - "@let-env": { - "prefix": "@let-env", - "description": "\"let-env\" invocation", - "body": [ - "# ${1:documentation}", - "let-env ${2:name} = ${3:value}" - ] - }, - "loop": { - "prefix": "loop", - "description": "\"loop\" invocation", - "body": "loop { ${1:command ...} }" - }, - "ls": { - "prefix": "ls", - "description": "\"ls\" invocation", - "body": "ls ${1:pattern}" - }, - "lines": { - "prefix": "lines", - "description": "\"lines\" invocation", - "body": "${1:command} | lines" - }, - "match": { - "prefix": "match", - "description": "\"match\" invocation", - "body": "match ${1:value} { ${2:pattern} => ${3:value}${4:, }, _ => ${5:value} }" - }, - "math": { - "prefix": "math", - "description": "\"math\" invocation", - "body": "${1:command} | math ${2|abs,arccos,arccosh,arcsin,arcsinh,arctan,arctanh,avg,ceil,cos,cosh,e,eval,exp,floor,ln,log,max,median,min,mode,pi,product,round,sin,sinh,sqrt,stddev,sum,tan,tanh,tau,variance|}" - }, - "merge": { - "prefix": "merge", - "description": "\"merge\" invocation", - "body": "${1:command} | merge ${2:value}" - }, - "metadata": { - "prefix": "metadata", - "description": "\"metadata\" invocation", - "body": "${1:command} | metadata" - }, - "mkdir": { - "prefix": "mkdir", - "description": "\"mkdir\" invocation", - "body": "mkdir ${1:path/to/directory}" - }, - "module": { - "prefix": "module", - "description": "\"module\" invocation", - "body": "module ${1:name} { ${1:command ...} }" - }, - "move": { - "prefix": "move", - "description": "\"move\" invocation", - "body": "${1:command} | move ${2:column} --${3|before,after|} ${4:column}" - }, - "mut": { - "prefix": "mut", - "description": "\"mut\" invocation", - "body": "mut ${1:name} = ${2:value}" - }, - "@mut": { - "prefix": "@mut", - "description": "\"mut\" invocation", - "body": [ - "# ${1:documentation}", - "mut ${2:name} = ${3:value}" - ] - }, - "mv": { - "prefix": "mv", - "description": "\"mv\" invocation", - "body": "mv ${1:path/to/source} ${2:path/to/destination}" - }, - "nu-check": { - "prefix": "nu-check", - "description": "\"nu-check\" invocation", - "body": "${1:command} | nu-check" - }, - "nu-highlight": { - "prefix": "nu-highlight", - "description": "\"nu-highlight\" invocation", - "body": "${1:command} | nu-highlight" - }, - "old-alias": { - "prefix": "old-alias", - "description": "\"old-alias\" invocation", - "body": "old-alias ${1:name} = ${2:value}" - }, - "@old-alias": { - "prefix": "@old-alias", - "description": "\"old-alias\" invocation", - "body": [ - "# ${1:documentation}", - "old-alias ${2:name} = ${3:value}" - ] - }, - "open": { - "prefix": "open", - "description": "\"open\" invocation", - "body": "${1:command} | open" - }, - "overlay hide": { - "prefix": "overlay-hide", - "description": "\"overlay hide\" invocation", - "body": "overlay hide ${1:name}" - }, - "overlay new": { - "prefix": "overlay-new", - "description": "\"overlay new\" invocation", - "body": "overlay new ${1:name}" - }, - "overlay use": { - "prefix": "overlay-use", - "description": "\"overlay use\" invocation", - "body": "overlay use ${1:name}" - }, - "par-each": { - "prefix": "par-each", - "description": "\"par-each\" invocation", - "body": "${1:command} | par-each {|${2:el}| ${3:command ...} }" - }, - "parse": { - "prefix": "parse", - "description": "\"parse\" invocation", - "body": "${1:command} | parse ${2:pattern}" - }, - "path": { - "prefix": "path", - "description": "\"path\" invocation", - "body": "${1:command} | path ${2|basename,dirname,exists,expand,parse,split,type|}" - }, - "path join": { - "prefix": "path-join", - "description": "\"path-join\" invocation", - "body": "${1:command} | path join ${2:path/to/file}" - }, - "path relative-to": { - "prefix": "path-relative-to", - "description": "\"path-relative-to\" invocation", - "body": "${1:command} | path relative-to ${2:path/to/directory}" - }, - "port": { - "prefix": "port", - "description": "\"port\" invocation", - "body": "port ${1:from} ${2:to}" - }, - "prepend": { - "prefix": "prepend", - "description": "\"prepend\" invocation", - "body": "${1:command} | prepend ${2:row}" - }, - "profile": { - "prefix": "profile", - "description": "\"profile\" invocation", - "body": "profile {|| ${1:command ...} }" - }, - "query": { - "prefix": "query", - "description": "\"query\" invocation", - "body": "${1:command} | query ${2|db,json,xml|} ${3:expression}" - }, - "query web": { - "prefix": "query-web", - "description": "\"query web\" invocation", - "body": "${1:command} | query web --query ${2:expression}" - }, - "random bool": { - "prefix": "random-bool", - "description": "\"random bool\" invocation", - "body": "random bool --bias ${1:value}" - }, - "random chars": { - "prefix": "random-chars", - "description": "\"random chars\" invocation", - "body": "random chars --length ${1:value}" - }, - "random": { - "prefix": "random", - "description": "\"random\" invocation", - "body": "random ${1|decimal,integer|} ${2:from}..${3:to}" - }, - "random dice": { - "prefix": "random-dice", - "description": "\"random dice\" invocation", - "body": "random dice" - }, - "random uuid": { - "prefix": "random-uuid", - "description": "\"random uuid\" invocation", - "body": "random uuid" - }, - "range": { - "prefix": "range", - "description": "\"range\" invocation", - "body": "${1:command} | range ${2:from}..${3:to}" - }, - "reduce": { - "prefix": "reduce", - "description": "\"reduce\" invocation", - "body": "${1:command} | reduce {|${2:el}, ${3:acc}| ${4:command ...} }" - }, - "register": { - "prefix": "register", - "description": "\"register\" invocation", - "body": "register ${1:path/to/plugin}" - }, - "registry query": { - "prefix": "registry-query", - "description": "\"registry query\" invocation", - "body": "registry query ${1:path/to/key} ${2:value}" - }, - "reject": { - "prefix": "reject", - "description": "\"reject\" invocation", - "body": "${1:command} | reject ${2:columns}" - }, - "rename": { - "prefix": "rename", - "description": "\"rename\" invocation", - "body": "${1:command} | rename ${2:columns}" - }, - "return": { - "prefix": "return", - "description": "\"return\" invocation", - "body": "return ${1:value}" - }, - "reverse": { - "prefix": "reverse", - "description": "\"reverse\" invocation", - "body": "${1:command} | reverse" - }, - "rm": { - "prefix": "rm", - "description": "\"rm\" invocation", - "body": "rm ${1:path/to/file}" - }, - "roll": { - "prefix": "roll", - "description": "\"roll\" invocation", - "body": "${1:command} | roll ${2|down,left,right,up|}" - }, - "rotate": { - "prefix": "rotate", - "description": "\"rotate\" invocation", - "body": "${1:command} | rotate" - }, - "run-external": { - "prefix": "run-external", - "description": "\"run-external\" invocation", - "body": "run-external ${1:command}" - }, - "save": { - "prefix": "save", - "description": "\"save\" invocation", - "body": "${1:command} | save" - }, - "schema": { - "prefix": "schema", - "description": "\"schema\" invocation", - "body": "${1:command} | schema" - }, - "select": { - "prefix": "select", - "description": "\"select\" invocation", - "body": "${1:command} | select ${2:columns}" - }, - "seq": { - "prefix": "seq", - "description": "\"seq\" invocation", - "body": "seq ${1:from} ${2:to}" - }, - "seq char": { - "prefix": "seq-char", - "description": "\"seq char\" invocation", - "body": "seq char ${1:from} ${2:to}" - }, - "seq date": { - "prefix": "seq-date", - "description": "\"seq date\" invocation", - "body": "seq date --begin-date ${1:from} --end-date ${2:to}" - }, - "shuffle": { - "prefix": "shuffle", - "description": "\"shuffle\" invocation", - "body": "${1:command} | shuffle" - }, - "size": { - "prefix": "size", - "description": "\"size\" invocation", - "body": "${1:command} | size" - }, - "skip": { - "prefix": "skip", - "description": "\"skip\" invocation", - "body": "${1:command} | skip ${2:count}" - }, - "skip until": { - "prefix": "skip-until", - "description": "\"skip until\" invocation", - "body": "${1:command} | skip until {|${2:el}| ${3:predicate} }" - }, - "skip while": { - "prefix": "skip-while", - "description": "\"skip while\" invocation", - "body": "${1:command} | skip while {|${2:el}| ${3:predicate} }" - }, - "sleep": { - "prefix": "sleep", - "description": "\"sleep\" invocation", - "body": "sleep ${1:value}${2|ns,us,ms,sec,min,hr,day,wk|}" - }, - "sort": { - "prefix": "sort", - "description": "\"sort\" invocation", - "body": "${1:command} | sort" - }, - "sort-by": { - "prefix": "sort-by", - "description": "\"sort-by\" invocation", - "body": "${1:command} | sort-by ${2:column}" - }, - "source": { - "prefix": "source", - "description": "\"source\" invocation", - "body": "source ${1:path/to/script}" - }, - "source-env": { - "prefix": "source-env", - "description": "\"source-env\" invocation", - "body": "source-env ${1:path/to/script}" - }, - "split": { - "prefix": "split", - "description": "\"split\" invocation", - "body": "${1:command} | split ${2|chars,words|}" - }, - "split column": { - "prefix": "split-column", - "description": "\"split column\" invocation", - "body": "${1:command} | split column ${2:separator}" - }, - "split list": { - "prefix": "split-list", - "description": "\"split list\" invocation", - "body": "${1:command} | split list ${2:separator}" - }, - "split row": { - "prefix": "split-row", - "description": "\"split row\" invocation", - "body": "${1:command} | split row ${2:separator}" - }, - "split-by": { - "prefix": "split-by", - "description": "\"split-by\" invocation", - "body": "${1:command} | split-by ${2:separator}" - }, - "start": { - "prefix": "start", - "description": "\"start\" invocation", - "body": "start ${1:path/to/file}" - }, - "str": { - "prefix": "str", - "description": "\"str\" invocation", - "body": "${1:command} | str ${2|camel-case,capitalize,downcase,kebab-case,length,pascal-case,reverse,screaming-snake-case,snake-case,title-case,trim,upcase|}" - }, - "str contains": { - "prefix": "str-contains", - "description": "\"str-contains\" invocation", - "body": "${1:command} | str contains ${2:value}" - }, - "str distance": { - "prefix": "str-distance", - "description": "\"str-distance\" invocation", - "body": "${1:command} | str distance ${2:value}" - }, - "str ends-with": { - "prefix": "str-ends-with", - "description": "\"str-ends-with\" invocation", - "body": "${1:command} | str ends-with ${2:value}" - }, - "str index-of": { - "prefix": "str-index-of", - "description": "\"str-index-of\" invocation", - "body": "${1:command} | str index-of ${2:value}" - }, - "str join": { - "prefix": "str-join", - "description": "\"str-join\" invocation", - "body": "${1:command} | str join ${2:value}" - }, - "str replace": { - "prefix": "str-replace", - "description": "\"str-replace\" invocation", - "body": "${1:command} | str replace ${2:search} ${3:replacement}" - }, - "table": { - "prefix": "table", - "description": "\"table\" invocation", - "body": "${1:command} | table" - }, - "take": { - "prefix": "take", - "description": "\"take\" invocation", - "body": "${1:command} | table ${2:count}" - }, - "take until": { - "prefix": "take-until", - "description": "\"take until\" invocation", - "body": "${1:command} | take until {|${2:el}| ${3:predicate} }" - }, - "take while": { - "prefix": "take-while", - "description": "\"take while\" invocation", - "body": "${1:command} | take while {|${2:el}| ${3:predicate} }" - }, - "timeit": { - "prefix": "timeit", - "description": "\"timeit\" invocation", - "body": "timeit { ${1:command ...} }" - }, - "to": { - "prefix": "to", - "description": "\"to\" invocation", - "body": "${1:command} | to ${2|csv,html,json,md,nuon,text,toml,tsv,xml,yaml|}" - }, - "touch": { - "prefix": "touch", - "description": "\"touch\" invocation", - "body": "touch ${1:path/to/file}" - }, - "transpose": { - "prefix": "transpose", - "description": "\"transpose\" invocation", - "body": "${1:command} | transpose" - }, - "try": { - "prefix": "try", - "description": "\"try\" invocation", - "body": "try { ${1:command ...} }" - }, - "try catch": { - "prefix": "try-catch", - "description": "\"try catch\" invocation", - "body": "try { ${1:command ...} } catch { ${2:command ...} }" - }, - "tutor": { - "prefix": "tutor", - "description": "\"tutor\" invocation", - "body": "tutor ${1:search}" - }, - "uniq": { - "prefix": "uniq", - "description": "\"uniq\" invocation", - "body": "${1:command} | uniq" - }, - "uniq-by": { - "prefix": "uniq-by", - "description": "\"uniq-by\" invocation", - "body": "${1:command} | uniq-by ${2:columns}" - }, - "update": { - "prefix": "update", - "description": "\"update\" invocation", - "body": "${1:command} | update ${2:column} ${3:value}" - }, - "update cells": { - "prefix": "update-cells", - "description": "\"update cells\" invocation", - "body": "${1:command} | update cells {|${2:el}| ${3:command ...} }" - }, - "upsert": { - "prefix": "upsert", - "description": "\"upsert\" invocation", - "body": "${1:command} | upsert ${2:column} ${3:value}" - }, - "url": { - "prefix": "url", - "description": "\"url\" invocation", - "body": "${1:command} | url ${2|build-query,encode,join,parse|}" - }, - "use": { - "prefix": "use", - "description": "\"use\" invocation", - "body": "use ${2:module} ${3:members}" - }, - "values": { - "prefix": "values", - "description": "\"values\" invocation", - "body": "${1:command} | values" - }, - "view source": { - "prefix": "view-source", - "description": "\"view source\" invocation", - "body": "view source ${1:value}" - }, - "view span": { - "prefix": "view-span", - "description": "\"view span\" invocation", - "body": "view span ${1:from} ${2:to}" - }, - "watch": { - "prefix": "watch", - "description": "\"watch\" invocation", - "body": "watch ${1:path/to/directory} {|${2:op}, ${3:path}, ${4:new_path}| ${5:command ...} }" - }, - "where": { - "prefix": "where", - "description": "\"where\" invocation", - "body": "${1:command} | where ${2:condition}" - }, - "which": { - "prefix": "which", - "description": "\"which\" invocation", - "body": "which ${1:command}" - }, - "while": { - "prefix": "while", - "description": "while operator", - "body": [ - "while ${1:condition} {", - "\t${2:command ...}", - "}" - ] - }, - "while-less": { - "prefix": "while-less", - "description": "while with comparison", - "body": [ - "while ${1:first-expression} < ${2:second-expression} {", - "\t${3:command ...}", - "}" - ] - }, - "while-greater": { - "prefix": "while-greater", - "description": "while with comparison", - "body": [ - "while ${1:first-expression} > ${2:second-expression} {", - "\t${3:command ...}", - "}" - ] - }, - "while-less-or-equal": { - "prefix": "while-less-or-equal", - "description": "while with comparison", - "body": [ - "while ${1:first-expression} <= ${2:second-expression} {", - "\t${3:command ...}", - "}" - ] - }, - "while-greater-or-equal": { - "prefix": "while-greater-or-equal", - "description": "while with comparison", - "body": [ - "while ${1:first-expression} >= ${2:second-expression} {", - "\t${3:command ...}", - "}" - ] - }, - "while-equal": { - "prefix": "while-equal", - "description": "while with comparison", - "body": [ - "while ${1:first-expression} == ${2:second-expression} {", - "\t${3:command ...}", - "}" - ] - }, - "while-not-equal": { - "prefix": "while-not-equal", - "description": "while with comparison", - "body": [ - "while ${1:first-expression} != ${2:second-expression} {", - "\t${3:command ...}", - "}" - ] - }, - "window": { - "prefix": "window", - "description": "\"window\" invocation", - "body": "${1:command} | window ${1:count}" - }, - "with-env": { - "prefix": "with-env", - "description": "\"with-env\" invocation", - "body": "with-env ${1:variables} { ${2:command ...} }" - }, - "wrap": { - "prefix": "wrap", - "description": "\"wrap\" invocation", - "body": "${1:command} | wrap ${2:column}" - }, - "zip": { - "prefix": "zip", - "description": "\"zip\" invocation", - "body": "${1:command} | zip ${2:list}" - }, - "completion": { - "prefix": "completion", - "description": "completion", - "body": [ - "def ${1:name} [${2:param}: ${3:type}@${4:complete}${5:, }] {", - "\t${6:completion ...}$0", - "}" - ] - }, - "@completion": { - "prefix": "@completion", - "description": "completion", - "body": [ - "# ${1:documentation}", - "def ${2:name} [${3:param}: ${4:type}@${5:complete}${6:, }] {", - "\t${7:completion ...}$0", - "}" - ] - }, - "@examples": { - "prefix": "examples", - "description": "examples", - "body": [ - "# ### Examples", - "# - ${1:example}", - "# ${2:...}" - ] - }, - "@notes": { - "prefix": "notes", - "description": "notes", - "body": [ - "# ### Notes", - "# - ${1:note}", - "# ${2:...}" - ] - }, - "@info": { - "prefix": "info", - "description": "info", - "body": [ - "# > **Info** ${1:info}" - ] - }, - "@warning": { - "prefix": "warning", - "description": "warning", - "body": [ - "# > **Warning** ${1:warning}" - ] - } -} \ No newline at end of file + "shebang": { + "prefix": "shebang", + "description": "shebang", + "body": "#!/usr/bin/env nu" + }, + "hexadecimal": { + "prefix": ["hexadecimal", "0x"], + "description": "hexadecimal", + "body": "0x[${1:ff}]" + }, + "binary": { + "prefix": ["binary", "0b"], + "description": "binary", + "body": "0b[${1:1}]" + }, + "octal": { + "prefix": ["octal", "0o"], + "description": "octal", + "body": "0o[${1:1}]" + }, + "date": { + "prefix": "date", + "description": "date", + "body": "${1:2000}-${2|01,02,03,04,05,06,07,08,09,10,11,12|}-${3|01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31|}" + }, + "duration": { + "prefix": "duration", + "description": "duration", + "body": "${1:value}${2|ns,us,ms,sec,min,hr,day,wk|}" + }, + "filesize": { + "prefix": "size", + "description": "size", + "body": "${1:value}${2|b,kb,mb,gb,tb,pb,eb,zb,kib,mib,gib,tib,pib,eib,zib|}" + }, + "in": { + "prefix": "in", + "description": "\"in\" operator", + "body": "${1:value} in ${2:list}" + }, + "not-in": { + "prefix": "not-in", + "description": "\"not-in\" operator", + "body": "${1:value} not-in ${2:list}" + }, + "flag": { + "prefix": ["flag", "--"], + "description": "flag", + "body": "--${1:long} (-${2:short}): ${3:type}" + }, + "rest": { + "prefix": ["rest", "..."], + "description": "flag", + "body": "...${1:name}: ${2:type}" + }, + "year": { + "prefix": "year", + "description": "year", + "body": "%${1|y,Y|}" + }, + "month": { + "prefix": "month", + "description": "month", + "body": "%${1|m,b,B|}" + }, + "day": { + "prefix": "day", + "description": "day", + "body": "%${1|d,j|}" + }, + "weekday": { + "prefix": "weekday", + "description": "weekday", + "body": "%${1|a,A|}" + }, + "hour": { + "prefix": "hour", + "description": "hour", + "body": "%${1|H,I,P,p|}" + }, + "minute": { + "prefix": "minute", + "description": "minute", + "body": "%M" + }, + "second": { + "prefix": "second", + "description": "second", + "body": "%${1|S,f|}" + }, + "time": { + "prefix": "time", + "description": "time", + "body": "${1|%H-%M-%S,%H-%M,%H:%M:%S,%H:%M|}" + }, + "capture group": { + "prefix": "capture-group", + "description": "regex group", + "body": "(?<${1:name}>${2:value})" + }, + "non-capturing group": { + "prefix": "non-capturing-group", + "description": "regex group", + "body": "(?:${1:value})" + }, + "alias": { + "prefix": "alias", + "description": "\"alias\" invocation", + "body": "alias ${1:name} = ${2:value}" + }, + "@alias": { + "prefix": "@alias", + "description": "\"alias\" invocation", + "body": ["# ${1:documentation}", "alias ${2:name} = ${3:value}"] + }, + "all": { + "prefix": "all", + "description": "\"all\" invocation", + "body": "${1:command} | all {|${2:el}| ${3:predicate} }" + }, + "ansi": { + "prefix": "ansi", + "description": "\"ansi\" invocation", + "body": "ansi ${3|black,red,green,yellow,blue,magenta,cyan,white,default,reset|}" + }, + "ansi gradient": { + "prefix": "ansi-gradient", + "description": "\"ansi gradient\" invocation", + "body": "ansi gradient --${1|fg,bg|}start ${2:0xffffff} --$1end ${3:0xffffff}" + }, + "ansi link": { + "prefix": "ansi-link", + "description": "\"ansi link\" invocation", + "body": "ansi link --text ${1:value}" + }, + "any": { + "prefix": "any", + "description": "\"any\" invocation", + "body": "${1:command} | any {|${2:el}| ${3:predicate} }" + }, + "append": { + "prefix": "append", + "description": "\"append\" invocation", + "body": "${1:command} | append ${2:row}" + }, + "ast": { + "prefix": "ast", + "description": "\"ast\" invocation", + "body": "ast ${1:pipeline}" + }, + "bits": { + "prefix": "bits", + "description": "\"bits\" invocation", + "body": "${1:command} | bits ${2|and,or,rol,ror,shl,shr,xor|} ${3:value}" + }, + "bits not": { + "prefix": "bits-not", + "description": "\"bits not\" invocation", + "body": "${1:command} | bits not" + }, + "bytes": { + "prefix": "bytes", + "description": "\"bytes\" invocation", + "body": "${1:command} | bytes ${2|add,collect,ends-with,index-of,remove,starts-with|} ${3:value}" + }, + "bytes at": { + "prefix": "bytes-at", + "description": "\"bytes at\" invocation", + "body": "${1:command} | bytes at ${2:from}..${3:to}" + }, + "bytes replace": { + "prefix": "bytes-replace", + "description": "\"bytes replace\" invocation", + "body": "${1:command} | bytes replace ${2:search} ${3:replacement}" + }, + "cd": { + "prefix": "cd", + "description": "\"cd\" invocation", + "body": "cd ${1:path/to/directory}" + }, + "char": { + "prefix": "char", + "description": "\"char\" invocation", + "body": "char ${1|newline,enter,nl,line_feed,lf,carriage_return,cr,crlf,tab|}" + }, + "collect": { + "prefix": "collect", + "description": "\"collect\" invocation", + "body": "${1:command} | collect {|${2:el}| ${3:command ...} }" + }, + "commandline": { + "prefix": "commandline", + "description": "\"commandline\" invocation", + "body": "commandline ${1:command}" + }, + "complete": { + "prefix": "complete", + "description": "\"complete\" invocation", + "body": "^${1:command} | complete" + }, + "compact": { + "prefix": "compact", + "description": "\"compact\" invocation", + "body": "${1:command} | compact" + }, + "config": { + "prefix": "config", + "description": "\"config\" invocation", + "body": "config ${1|env,nu,reset|}" + }, + "const": { + "prefix": "const", + "description": "\"const\" invocation", + "body": "const ${1:name} = ${2:value}" + }, + "@const": { + "prefix": "@const", + "description": "\"const\" invocation", + "body": ["# ${1:documentation}", "const ${2:name} = ${3:value}"] + }, + "cp": { + "prefix": "cp", + "description": "\"cp\" invocation", + "body": "cp ${1:path/to/from} ${2:path/to/to}" + }, + "date format": { + "prefix": "date-format", + "description": "\"date format\" invocation", + "body": "date format ${1:%Y-%m-%d %H:%M:%S}" + }, + "date humanize": { + "prefix": "date-humanize", + "description": "\"date humanize\" invocation", + "body": "${1:command} | date humanize" + }, + "decode": { + "prefix": "decode", + "description": "\"decode\" invocation", + "body": "${1:command} | decode ${1|big5,euc-jp,euc-kr,gbk,iso-8859-1,utf-16,cp1252,latin5|}" + }, + "decode base64": { + "prefix": "decode-base64", + "description": "\"decode base64\" invocation", + "body": "${1:command} | decode base64" + }, + "decode hex": { + "prefix": "decode-hex", + "description": "\"decode hex\" invocation", + "body": "${1:command} | decode hex" + }, + "def": { + "prefix": "def", + "description": "\"def\" invocation", + "body": [ + "def ${1:name} [${2:param}: ${3:type}${4:, }] {", + "\t${5:command ...}$0", + "}" + ] + }, + "@def": { + "prefix": "@def", + "description": "\"def\" invocation", + "body": [ + "# ${1:documentation}", + "def ${2:name} [${3:param}: ${4:type}${5:, }] {", + "\t${6:command}$0", + "}" + ] + }, + "def-env": { + "prefix": "def-env", + "description": "\"def-env\" invocation", + "body": [ + "def --env ${1:name} [${2:param}: ${3:type}${4:, }] {", + "\t${5:command ...}$0", + "}" + ] + }, + "@def-env": { + "prefix": "@def-env", + "description": "\"def-env\" invocation", + "body": [ + "# ${1:documentation}", + "def --env ${2:name} [${3:param}: ${4:type}${5:, }] {", + "\t${6:command ...}$0", + "}" + ] + }, + "def-wrapped": { + "prefix": "def-wrapped", + "description": "\"def-wrapped\" invocation", + "body": [ + "def --wrapped ${1:name} [...${2:rest}] {", + "\t${3:command ...}$0", + "}" + ] + }, + "@def-wrapped": { + "prefix": "@def-wrapped", + "description": "\"def-wrapped\" invocation", + "body": [ + "# ${1:documentation}", + "def --wrapped ${2:name} [...${3:rest}] {", + "\t${4:command ...}$0", + "}" + ] + }, + "default": { + "prefix": "default", + "description": "\"default\" invocation", + "body": "${1:command} | default ${2:default} ${3:column}" + }, + "describe": { + "prefix": "describe", + "description": "\"describe\" invocation", + "body": "${1:command} | describe" + }, + "detect columns": { + "prefix": "detect-columns", + "description": "\"detect columns\" invocation", + "body": "${1:command} | detect columns" + }, + "do": { + "prefix": "do", + "description": "\"do\" invocation", + "body": "do { ${1:command ...} }" + }, + "drop": { + "prefix": "drop", + "description": "\"drop\" invocation", + "body": "${1:command} | drop ${2:rows}" + }, + "drop columns": { + "prefix": "drop-columns", + "description": "\"drop columns\" invocation", + "body": "${1:command} | drop columns ${2:numbers}" + }, + "drop nth": { + "prefix": "drop-nth", + "description": "\"drop nth\" invocation", + "body": "${1:command} | drop nth ${2:rows}" + }, + "du": { + "prefix": "du", + "description": "\"du\" invocation", + "body": "du ${1:path/to/directory}" + }, + "each": { + "prefix": "each", + "description": "\"each\" invocation", + "body": "${1:command} | each {|${2:el}| ${3:command ...} }" + }, + "each while": { + "prefix": "each-while", + "description": "\"each while\" invocation", + "body": "${1:command} | each while {|${2:el}| ${3:command ...} }" + }, + "encode": { + "prefix": "encode", + "description": "\"encode\" invocation", + "body": "${1:command} | encode ${2|big5,euc-jp,euc-kr,gbk,iso-8859-1,utf-16,cp1252,latin5|}" + }, + "encode base64": { + "prefix": "encode-base64", + "description": "\"encode base64\" invocation", + "body": "${1:command} | encode base64" + }, + "encode hex": { + "prefix": "encode-hex", + "description": "\"encode hex\" invocation", + "body": "${1:command} | encode hex" + }, + "enter": { + "prefix": "enter", + "description": "\"enter\" invocation", + "body": "enter ${1:path/to/directory}" + }, + "enumerate": { + "prefix": "enumerate", + "description": "\"enumerate\" invocation", + "body": "${1:command} | enumerate" + }, + "error make": { + "prefix": "error-make", + "description": "\"error make\" invocation", + "body": "error make {${1:msg}: ${2:message}${3:, }}" + }, + "every": { + "prefix": "every", + "description": "\"every\" invocation", + "body": "${1:command} | every ${2:stride}" + }, + "exec": { + "prefix": "exec", + "description": "\"exec\" invocation", + "body": "exec ${1:command}" + }, + "exit": { + "prefix": "exit", + "description": "\"exit\" invocation", + "body": "exit ${1:code}" + }, + "explain": { + "prefix": "explain", + "description": "\"explain\" invocation", + "body": "explain {|| ${1:command ...} }" + }, + "explore": { + "prefix": "explore", + "description": "\"explore\" invocation", + "body": "${1:command} | explore" + }, + "export": { + "prefix": "export", + "description": "\"export\" invocation", + "body": "export ${1:definition}" + }, + "export alias": { + "prefix": "export-alias", + "description": "\"export alias\" invocation", + "body": "export alias ${1:name} = ${2:value}" + }, + "export def": { + "prefix": "export-def", + "description": "\"export def\" invocation", + "body": [ + "export def ${1:name} [${2:param}: ${3:type}${4:, }] {", + "\t${5:command ...}", + "}" + ] + }, + "export def-env": { + "prefix": "export-def-env", + "description": "\"export def-env\" invocation", + "body": [ + "export def --env ${1:name} [${2:param}: ${3:type}${4:, }] {", + "\t${5:command ...}", + "}" + ] + }, + "export extern": { + "prefix": "export-extern", + "description": "\"export extern\" invocation", + "body": "export extern ${1:name} [${2:param}: string${3:, }]" + }, + "export old-alias": { + "prefix": "export-old-alias", + "description": "\"export old-alias\" invocation", + "body": "export old-alias ${1:name} = ${2:value}" + }, + "export use": { + "prefix": "export-use", + "description": "\"export use\" invocation", + "body": "export use ${1:module} ${2:members}" + }, + "export env": { + "prefix": "export-env", + "description": "\"export env\" invocation", + "body": "export env { ${1:command ...} }" + }, + "extern": { + "prefix": "extern", + "description": "\"extern\" invocation", + "body": "extern ${1:name} [${2:param}: string${3:, }]" + }, + "fill": { + "prefix": "fill", + "description": "\"fill\" invocation", + "body": "${1:command} | fill --width ${2:value}" + }, + "filter": { + "prefix": "filter", + "description": "\"filter\" invocation", + "body": "${1:command} | filter {|${2:el}| ${3:predicate} }" + }, + "find": { + "prefix": "find", + "description": "\"find\" invocation", + "body": "${1:command} | find" + }, + "first": { + "prefix": "first", + "description": "\"first\" invocation", + "body": "${1:command} | first ${2:count}" + }, + "flatten": { + "prefix": "flatten", + "description": "\"flatten\" invocation", + "body": "${1:command} | flatten" + }, + "fmt": { + "prefix": "fmt", + "description": "\"fmt\" invocation", + "body": "${1:command} | fmt" + }, + "for": { + "prefix": "for", + "description": "for operator", + "body": ["for ${1:variable} in ${2:list} {", "\t${3:command ...}", "}"] + }, + "for-range": { + "prefix": "for-range", + "description": "for with range", + "body": ["for ${1:item} in ${2:from}..${3:to} {", "\t${4:command ...}", "}"] + }, + "for-stepped-range": { + "prefix": "for-stepped-range", + "description": "for with stepped range", + "body": [ + "for ${1:item} in ${2:from}..${3:step}..${4:to}) {", + "\t${5:command ...}", + "}" + ] + }, + "for-files": { + "prefix": "for-files", + "description": "for with files", + "body": [ + "for ${1:item} in (ls *.${2:extension})", + "\t${3:command ...}", + "}" + ] + }, + "format": { + "prefix": "format", + "description": "\"format\" invocation", + "body": "${1:command} | format ${2:value}" + }, + "format filesize": { + "prefix": "format-filesize", + "description": "\"format filesize\" invocation", + "body": "${1:command} | format filesize ${2|b,kb,mb,gb,tb,pb,eb,zb,kib,mib,gib,tib,pib,eib,zib|} ${3:column}" + }, + "from": { + "prefix": "from", + "description": "\"from\" invocation", + "body": "${1:command} | from ${2|csv,eml,ics,ini,json,nuon,ods,ssv,toml,tsc,url,vcf,xlsx,xml,yaml,yml|}" + }, + "g": { + "prefix": "g", + "description": "\"g\" invocation", + "body": "g ${1:shell}" + }, + "get": { + "prefix": "get", + "description": "\"get\" invocation", + "body": "${1:command} | get ${2:path/to/cell}" + }, + "glob": { + "prefix": "glob", + "description": "\"glob\" invocation", + "body": "glob ${1:pattern}" + }, + "grid": { + "prefix": "grid", + "description": "\"grid\" invocation", + "body": "${1:command} | grid" + }, + "group": { + "prefix": "group", + "description": "\"group\" invocation", + "body": "${1:command} | group ${2:count}" + }, + "group-by": { + "prefix": "group-by", + "description": "\"group-by\" invocation", + "body": "${1:command} | group-by ${2:grouper}" + }, + "gstat": { + "prefix": "gstat", + "description": "\"gstat\" invocation", + "body": "gstat ${1:path/to/repository}" + }, + "hash": { + "prefix": "hash", + "description": "\"hash\" invocation", + "body": "${1:command} | hash ${2|md5,sha256|}" + }, + "headers": { + "prefix": "headers", + "description": "\"headers\" invocation", + "body": "${1:command} | headers" + }, + "help": { + "prefix": "help", + "description": "\"help\" invocation", + "body": "help ${1|aliases,commands,externs,modules,operators|}" + }, + "hide": { + "prefix": "hide", + "description": "\"hide\" invocation", + "body": "hide ${1:definitions}" + }, + "hide-env": { + "prefix": "hide-env", + "description": "\"hide-env\" invocation", + "body": "hide-env ${1:variables}" + }, + "histogram": { + "prefix": "histogram", + "description": "\"histogram\" invocation", + "body": "${1:command} | histogram ${2:column} ${3:frequency-column}" + }, + "http": { + "prefix": "http", + "description": "\"http\" invocation", + "body": "http ${1|delete,get,head|} ${1:url}" + }, + "http patch": { + "prefix": "http-patch", + "description": "\"http patch\" invocation", + "body": "http patch ${1:url} ${2:data}" + }, + "http post": { + "prefix": "http-post", + "description": "\"http post\" invocation", + "body": "http post ${1:url} ${2:data}" + }, + "http put": { + "prefix": "http-put", + "description": "\"http put\" invocation", + "body": "http put ${1:url} ${2:data}" + }, + "if": { + "prefix": "if", + "description": "if operator", + "body": ["if ${1:condition} {", "\t${2:command ...}", "}"] + }, + "if-else": { + "prefix": "if-else", + "description": "if-else operator", + "body": [ + "if ${1:condition} {", + "\t${2:command ...}", + "} else {", + "\t${3:command ...}", + "}" + ] + }, + "if else if else": { + "prefix": "if-else-if-else operator", + "description": "if-else-if-else operator", + "body": [ + "if ${1:condition} {", + "\t${2:command ...}", + "} else if ${3:condition} {", + "\t${4:command ...}", + "} else {", + "\t${5:command ...}", + "}" + ] + }, + "if-less": { + "prefix": "if-less", + "description": "if with comparison", + "body": [ + "if ${1:first-expression} < ${2:second-expression} {", + "\t${3:command ...}", + "}" + ] + }, + "if-greater": { + "prefix": "if-greater", + "description": "if with comparison", + "body": [ + "if ${1:first-expression} > ${2:second-expression} {", + "\t${3:command ...}", + "}" + ] + }, + "if-less-or-equal": { + "prefix": "if-less-or-equal", + "description": "if with comparison", + "body": [ + "if ${1:first-expression} <= ${2:second-expression} {", + "\t${3:command ...}", + "}" + ] + }, + "if-greater-or-equal": { + "prefix": "if-greater-or-equal", + "description": "if with comparison", + "body": [ + "if ${1:first-expression} >= ${2:second-expression} {", + "\t${3:command ...}", + "}" + ] + }, + "if-equal": { + "prefix": "if-equal", + "description": "if with comparison", + "body": [ + "if ${1:first-expression} == ${2:second-expression} {", + "\t${3:command ...}", + "}" + ] + }, + "if-not-equal": { + "prefix": "if-not-equal", + "description": "if with comparison", + "body": [ + "if ${1:first-expression} != ${2:second-expression} {", + "\t${3:command ...}", + "}" + ] + }, + "ignore": { + "prefix": "ignore", + "description": "\"ignore\" invocation", + "body": "${1:command} | ignore" + }, + "inc": { + "prefix": "inc", + "description": "\"inc\" invocation", + "body": "${1:command} | inc" + }, + "input": { + "prefix": "input", + "description": "\"input\" invocation", + "body": "input ${1:prompt}" + }, + "insert": { + "prefix": "insert", + "description": "\"insert\" invocation", + "body": "${1:command} | insert ${2:column} ${3:value}" + }, + "inspect": { + "prefix": "inspect", + "description": "\"inspect\" invocation", + "body": "${1:command} | inspect" + }, + "into": { + "prefix": "into", + "description": "\"into\" invocation", + "body": "${1:command} | into ${2|binary,bool,datetime,decimal,duration,filesize,int,record,sqlite,string|}" + }, + "is-empty": { + "prefix": "is-empty", + "description": "\"is-empty\" invocation", + "body": "${1:command} | is-empty" + }, + "join": { + "prefix": "join", + "description": "\"join\" invocation", + "body": "${1:command} | join ${2:table} ${3:column}" + }, + "kill": { + "prefix": "kill", + "description": "\"kill\" invocation", + "body": "kill ${1:pid}" + }, + "last": { + "prefix": "last", + "description": "\"last\" invocation", + "body": "${1:command} | last ${2:count}" + }, + "length": { + "prefix": "length", + "description": "\"length\" invocation", + "body": "${1:command} | length" + }, + "let": { + "prefix": "let", + "description": "\"let\" invocation", + "body": "let ${1:name} = ${2:value}" + }, + "@let": { + "prefix": "@let", + "description": "\"let\" invocation", + "body": ["# ${1:documentation}", "let ${2:name} = ${3:value}"] + }, + "let-env": { + "prefix": "let-env", + "description": "\"let-env\" invocation", + "body": "let-env ${1:name} = ${2:value}" + }, + "@let-env": { + "prefix": "@let-env", + "description": "\"let-env\" invocation", + "body": ["# ${1:documentation}", "let-env ${2:name} = ${3:value}"] + }, + "loop": { + "prefix": "loop", + "description": "\"loop\" invocation", + "body": "loop { ${1:command ...} }" + }, + "ls": { + "prefix": "ls", + "description": "\"ls\" invocation", + "body": "ls ${1:pattern}" + }, + "lines": { + "prefix": "lines", + "description": "\"lines\" invocation", + "body": "${1:command} | lines" + }, + "match": { + "prefix": "match", + "description": "\"match\" invocation", + "body": "match ${1:value} { ${2:pattern} => ${3:value}${4:, }, _ => ${5:value} }" + }, + "math": { + "prefix": "math", + "description": "\"math\" invocation", + "body": "${1:command} | math ${2|abs,arccos,arccosh,arcsin,arcsinh,arctan,arctanh,avg,ceil,cos,cosh,e,eval,exp,floor,ln,log,max,median,min,mode,pi,product,round,sin,sinh,sqrt,stddev,sum,tan,tanh,tau,variance|}" + }, + "merge": { + "prefix": "merge", + "description": "\"merge\" invocation", + "body": "${1:command} | merge ${2:value}" + }, + "metadata": { + "prefix": "metadata", + "description": "\"metadata\" invocation", + "body": "${1:command} | metadata" + }, + "mkdir": { + "prefix": "mkdir", + "description": "\"mkdir\" invocation", + "body": "mkdir ${1:path/to/directory}" + }, + "module": { + "prefix": "module", + "description": "\"module\" invocation", + "body": "module ${1:name} { ${1:command ...} }" + }, + "move": { + "prefix": "move", + "description": "\"move\" invocation", + "body": "${1:command} | move ${2:column} --${3|before,after|} ${4:column}" + }, + "mut": { + "prefix": "mut", + "description": "\"mut\" invocation", + "body": "mut ${1:name} = ${2:value}" + }, + "@mut": { + "prefix": "@mut", + "description": "\"mut\" invocation", + "body": ["# ${1:documentation}", "mut ${2:name} = ${3:value}"] + }, + "mv": { + "prefix": "mv", + "description": "\"mv\" invocation", + "body": "mv ${1:path/to/source} ${2:path/to/destination}" + }, + "nu-check": { + "prefix": "nu-check", + "description": "\"nu-check\" invocation", + "body": "${1:command} | nu-check" + }, + "nu-highlight": { + "prefix": "nu-highlight", + "description": "\"nu-highlight\" invocation", + "body": "${1:command} | nu-highlight" + }, + "old-alias": { + "prefix": "old-alias", + "description": "\"old-alias\" invocation", + "body": "old-alias ${1:name} = ${2:value}" + }, + "@old-alias": { + "prefix": "@old-alias", + "description": "\"old-alias\" invocation", + "body": ["# ${1:documentation}", "old-alias ${2:name} = ${3:value}"] + }, + "open": { + "prefix": "open", + "description": "\"open\" invocation", + "body": "${1:command} | open" + }, + "overlay hide": { + "prefix": "overlay-hide", + "description": "\"overlay hide\" invocation", + "body": "overlay hide ${1:name}" + }, + "overlay new": { + "prefix": "overlay-new", + "description": "\"overlay new\" invocation", + "body": "overlay new ${1:name}" + }, + "overlay use": { + "prefix": "overlay-use", + "description": "\"overlay use\" invocation", + "body": "overlay use ${1:name}" + }, + "par-each": { + "prefix": "par-each", + "description": "\"par-each\" invocation", + "body": "${1:command} | par-each {|${2:el}| ${3:command ...} }" + }, + "parse": { + "prefix": "parse", + "description": "\"parse\" invocation", + "body": "${1:command} | parse ${2:pattern}" + }, + "path": { + "prefix": "path", + "description": "\"path\" invocation", + "body": "${1:command} | path ${2|basename,dirname,exists,expand,parse,split,type|}" + }, + "path join": { + "prefix": "path-join", + "description": "\"path-join\" invocation", + "body": "${1:command} | path join ${2:path/to/file}" + }, + "path relative-to": { + "prefix": "path-relative-to", + "description": "\"path-relative-to\" invocation", + "body": "${1:command} | path relative-to ${2:path/to/directory}" + }, + "port": { + "prefix": "port", + "description": "\"port\" invocation", + "body": "port ${1:from} ${2:to}" + }, + "prepend": { + "prefix": "prepend", + "description": "\"prepend\" invocation", + "body": "${1:command} | prepend ${2:row}" + }, + "profile": { + "prefix": "profile", + "description": "\"profile\" invocation", + "body": "profile {|| ${1:command ...} }" + }, + "query": { + "prefix": "query", + "description": "\"query\" invocation", + "body": "${1:command} | query ${2|db,json,xml|} ${3:expression}" + }, + "query web": { + "prefix": "query-web", + "description": "\"query web\" invocation", + "body": "${1:command} | query web --query ${2:expression}" + }, + "random bool": { + "prefix": "random-bool", + "description": "\"random bool\" invocation", + "body": "random bool --bias ${1:value}" + }, + "random chars": { + "prefix": "random-chars", + "description": "\"random chars\" invocation", + "body": "random chars --length ${1:value}" + }, + "random": { + "prefix": "random", + "description": "\"random\" invocation", + "body": "random ${1|decimal,integer|} ${2:from}..${3:to}" + }, + "random dice": { + "prefix": "random-dice", + "description": "\"random dice\" invocation", + "body": "random dice" + }, + "random uuid": { + "prefix": "random-uuid", + "description": "\"random uuid\" invocation", + "body": "random uuid" + }, + "range": { + "prefix": "range", + "description": "\"range\" invocation", + "body": "${1:command} | range ${2:from}..${3:to}" + }, + "reduce": { + "prefix": "reduce", + "description": "\"reduce\" invocation", + "body": "${1:command} | reduce {|${2:el}, ${3:acc}| ${4:command ...} }" + }, + "register": { + "prefix": "register", + "description": "\"register\" invocation", + "body": "register ${1:path/to/plugin}" + }, + "registry query": { + "prefix": "registry-query", + "description": "\"registry query\" invocation", + "body": "registry query ${1:path/to/key} ${2:value}" + }, + "reject": { + "prefix": "reject", + "description": "\"reject\" invocation", + "body": "${1:command} | reject ${2:columns}" + }, + "rename": { + "prefix": "rename", + "description": "\"rename\" invocation", + "body": "${1:command} | rename ${2:columns}" + }, + "return": { + "prefix": "return", + "description": "\"return\" invocation", + "body": "return ${1:value}" + }, + "reverse": { + "prefix": "reverse", + "description": "\"reverse\" invocation", + "body": "${1:command} | reverse" + }, + "rm": { + "prefix": "rm", + "description": "\"rm\" invocation", + "body": "rm ${1:path/to/file}" + }, + "roll": { + "prefix": "roll", + "description": "\"roll\" invocation", + "body": "${1:command} | roll ${2|down,left,right,up|}" + }, + "rotate": { + "prefix": "rotate", + "description": "\"rotate\" invocation", + "body": "${1:command} | rotate" + }, + "run-external": { + "prefix": "run-external", + "description": "\"run-external\" invocation", + "body": "run-external ${1:command}" + }, + "save": { + "prefix": "save", + "description": "\"save\" invocation", + "body": "${1:command} | save" + }, + "schema": { + "prefix": "schema", + "description": "\"schema\" invocation", + "body": "${1:command} | schema" + }, + "select": { + "prefix": "select", + "description": "\"select\" invocation", + "body": "${1:command} | select ${2:columns}" + }, + "seq": { + "prefix": "seq", + "description": "\"seq\" invocation", + "body": "seq ${1:from} ${2:to}" + }, + "seq char": { + "prefix": "seq-char", + "description": "\"seq char\" invocation", + "body": "seq char ${1:from} ${2:to}" + }, + "seq date": { + "prefix": "seq-date", + "description": "\"seq date\" invocation", + "body": "seq date --begin-date ${1:from} --end-date ${2:to}" + }, + "shuffle": { + "prefix": "shuffle", + "description": "\"shuffle\" invocation", + "body": "${1:command} | shuffle" + }, + "size": { + "prefix": "size", + "description": "\"size\" invocation", + "body": "${1:command} | size" + }, + "skip": { + "prefix": "skip", + "description": "\"skip\" invocation", + "body": "${1:command} | skip ${2:count}" + }, + "skip until": { + "prefix": "skip-until", + "description": "\"skip until\" invocation", + "body": "${1:command} | skip until {|${2:el}| ${3:predicate} }" + }, + "skip while": { + "prefix": "skip-while", + "description": "\"skip while\" invocation", + "body": "${1:command} | skip while {|${2:el}| ${3:predicate} }" + }, + "sleep": { + "prefix": "sleep", + "description": "\"sleep\" invocation", + "body": "sleep ${1:value}${2|ns,us,ms,sec,min,hr,day,wk|}" + }, + "sort": { + "prefix": "sort", + "description": "\"sort\" invocation", + "body": "${1:command} | sort" + }, + "sort-by": { + "prefix": "sort-by", + "description": "\"sort-by\" invocation", + "body": "${1:command} | sort-by ${2:column}" + }, + "source": { + "prefix": "source", + "description": "\"source\" invocation", + "body": "source ${1:path/to/script}" + }, + "source-env": { + "prefix": "source-env", + "description": "\"source-env\" invocation", + "body": "source-env ${1:path/to/script}" + }, + "split": { + "prefix": "split", + "description": "\"split\" invocation", + "body": "${1:command} | split ${2|chars,words|}" + }, + "split column": { + "prefix": "split-column", + "description": "\"split column\" invocation", + "body": "${1:command} | split column ${2:separator}" + }, + "split list": { + "prefix": "split-list", + "description": "\"split list\" invocation", + "body": "${1:command} | split list ${2:separator}" + }, + "split row": { + "prefix": "split-row", + "description": "\"split row\" invocation", + "body": "${1:command} | split row ${2:separator}" + }, + "split-by": { + "prefix": "split-by", + "description": "\"split-by\" invocation", + "body": "${1:command} | split-by ${2:separator}" + }, + "start": { + "prefix": "start", + "description": "\"start\" invocation", + "body": "start ${1:path/to/file}" + }, + "str": { + "prefix": "str", + "description": "\"str\" invocation", + "body": "${1:command} | str ${2|camel-case,capitalize,downcase,kebab-case,length,pascal-case,reverse,screaming-snake-case,snake-case,title-case,trim,upcase|}" + }, + "str contains": { + "prefix": "str-contains", + "description": "\"str-contains\" invocation", + "body": "${1:command} | str contains ${2:value}" + }, + "str distance": { + "prefix": "str-distance", + "description": "\"str-distance\" invocation", + "body": "${1:command} | str distance ${2:value}" + }, + "str ends-with": { + "prefix": "str-ends-with", + "description": "\"str-ends-with\" invocation", + "body": "${1:command} | str ends-with ${2:value}" + }, + "str index-of": { + "prefix": "str-index-of", + "description": "\"str-index-of\" invocation", + "body": "${1:command} | str index-of ${2:value}" + }, + "str join": { + "prefix": "str-join", + "description": "\"str-join\" invocation", + "body": "${1:command} | str join ${2:value}" + }, + "str replace": { + "prefix": "str-replace", + "description": "\"str-replace\" invocation", + "body": "${1:command} | str replace ${2:search} ${3:replacement}" + }, + "table": { + "prefix": "table", + "description": "\"table\" invocation", + "body": "${1:command} | table" + }, + "take": { + "prefix": "take", + "description": "\"take\" invocation", + "body": "${1:command} | table ${2:count}" + }, + "take until": { + "prefix": "take-until", + "description": "\"take until\" invocation", + "body": "${1:command} | take until {|${2:el}| ${3:predicate} }" + }, + "take while": { + "prefix": "take-while", + "description": "\"take while\" invocation", + "body": "${1:command} | take while {|${2:el}| ${3:predicate} }" + }, + "timeit": { + "prefix": "timeit", + "description": "\"timeit\" invocation", + "body": "timeit { ${1:command ...} }" + }, + "to": { + "prefix": "to", + "description": "\"to\" invocation", + "body": "${1:command} | to ${2|csv,html,json,md,nuon,text,toml,tsv,xml,yaml|}" + }, + "touch": { + "prefix": "touch", + "description": "\"touch\" invocation", + "body": "touch ${1:path/to/file}" + }, + "transpose": { + "prefix": "transpose", + "description": "\"transpose\" invocation", + "body": "${1:command} | transpose" + }, + "try": { + "prefix": "try", + "description": "\"try\" invocation", + "body": "try { ${1:command ...} }" + }, + "try catch": { + "prefix": "try-catch", + "description": "\"try catch\" invocation", + "body": "try { ${1:command ...} } catch { ${2:command ...} }" + }, + "tutor": { + "prefix": "tutor", + "description": "\"tutor\" invocation", + "body": "tutor ${1:search}" + }, + "uniq": { + "prefix": "uniq", + "description": "\"uniq\" invocation", + "body": "${1:command} | uniq" + }, + "uniq-by": { + "prefix": "uniq-by", + "description": "\"uniq-by\" invocation", + "body": "${1:command} | uniq-by ${2:columns}" + }, + "update": { + "prefix": "update", + "description": "\"update\" invocation", + "body": "${1:command} | update ${2:column} ${3:value}" + }, + "update cells": { + "prefix": "update-cells", + "description": "\"update cells\" invocation", + "body": "${1:command} | update cells {|${2:el}| ${3:command ...} }" + }, + "upsert": { + "prefix": "upsert", + "description": "\"upsert\" invocation", + "body": "${1:command} | upsert ${2:column} ${3:value}" + }, + "url": { + "prefix": "url", + "description": "\"url\" invocation", + "body": "${1:command} | url ${2|build-query,encode,join,parse|}" + }, + "use": { + "prefix": "use", + "description": "\"use\" invocation", + "body": "use ${2:module} ${3:members}" + }, + "values": { + "prefix": "values", + "description": "\"values\" invocation", + "body": "${1:command} | values" + }, + "view source": { + "prefix": "view-source", + "description": "\"view source\" invocation", + "body": "view source ${1:value}" + }, + "view span": { + "prefix": "view-span", + "description": "\"view span\" invocation", + "body": "view span ${1:from} ${2:to}" + }, + "watch": { + "prefix": "watch", + "description": "\"watch\" invocation", + "body": "watch ${1:path/to/directory} {|${2:op}, ${3:path}, ${4:new_path}| ${5:command ...} }" + }, + "where": { + "prefix": "where", + "description": "\"where\" invocation", + "body": "${1:command} | where ${2:condition}" + }, + "which": { + "prefix": "which", + "description": "\"which\" invocation", + "body": "which ${1:command}" + }, + "while": { + "prefix": "while", + "description": "while operator", + "body": ["while ${1:condition} {", "\t${2:command ...}", "}"] + }, + "while-less": { + "prefix": "while-less", + "description": "while with comparison", + "body": [ + "while ${1:first-expression} < ${2:second-expression} {", + "\t${3:command ...}", + "}" + ] + }, + "while-greater": { + "prefix": "while-greater", + "description": "while with comparison", + "body": [ + "while ${1:first-expression} > ${2:second-expression} {", + "\t${3:command ...}", + "}" + ] + }, + "while-less-or-equal": { + "prefix": "while-less-or-equal", + "description": "while with comparison", + "body": [ + "while ${1:first-expression} <= ${2:second-expression} {", + "\t${3:command ...}", + "}" + ] + }, + "while-greater-or-equal": { + "prefix": "while-greater-or-equal", + "description": "while with comparison", + "body": [ + "while ${1:first-expression} >= ${2:second-expression} {", + "\t${3:command ...}", + "}" + ] + }, + "while-equal": { + "prefix": "while-equal", + "description": "while with comparison", + "body": [ + "while ${1:first-expression} == ${2:second-expression} {", + "\t${3:command ...}", + "}" + ] + }, + "while-not-equal": { + "prefix": "while-not-equal", + "description": "while with comparison", + "body": [ + "while ${1:first-expression} != ${2:second-expression} {", + "\t${3:command ...}", + "}" + ] + }, + "window": { + "prefix": "window", + "description": "\"window\" invocation", + "body": "${1:command} | window ${1:count}" + }, + "with-env": { + "prefix": "with-env", + "description": "\"with-env\" invocation", + "body": "with-env ${1:variables} { ${2:command ...} }" + }, + "wrap": { + "prefix": "wrap", + "description": "\"wrap\" invocation", + "body": "${1:command} | wrap ${2:column}" + }, + "zip": { + "prefix": "zip", + "description": "\"zip\" invocation", + "body": "${1:command} | zip ${2:list}" + }, + "completion": { + "prefix": "completion", + "description": "completion", + "body": [ + "def ${1:name} [${2:param}: ${3:type}@${4:complete}${5:, }] {", + "\t${6:completion ...}$0", + "}" + ] + }, + "@completion": { + "prefix": "@completion", + "description": "completion", + "body": [ + "# ${1:documentation}", + "def ${2:name} [${3:param}: ${4:type}@${5:complete}${6:, }] {", + "\t${7:completion ...}$0", + "}" + ] + }, + "@examples": { + "prefix": "examples", + "description": "examples", + "body": ["# ### Examples", "# - ${1:example}", "# ${2:...}"] + }, + "@notes": { + "prefix": "notes", + "description": "notes", + "body": ["# ### Notes", "# - ${1:note}", "# ${2:...}"] + }, + "@info": { + "prefix": "info", + "description": "info", + "body": ["# > **Info** ${1:info}"] + }, + "@warning": { + "prefix": "warning", + "description": "warning", + "body": ["# > **Warning** ${1:warning}"] + } +} diff --git a/syntaxes/nushell.tmLanguage.json b/syntaxes/nushell.tmLanguage.json index c9cf7dc..403b24a 100644 --- a/syntaxes/nushell.tmLanguage.json +++ b/syntaxes/nushell.tmLanguage.json @@ -237,9 +237,7 @@ "1": { "name": "entity.name.type.nushell" } }, "end": ">", - "patterns": [ - { "include": "#types" } - ] + "patterns": [{ "include": "#types" }] }, { "name": "meta.record.nushell", @@ -276,14 +274,12 @@ { "begin": "\\??:\\s*", "end": "(?=(?:\\s+(?:-{0,2}|\\.{3})[\\w-]+)|(?:\\s*(?:,|\\]|\\||@|=|#|$)))", - "patterns": [ - { "include": "#types" } - ] + "patterns": [{ "include": "#types" }] }, { "begin": "@(?=\"|')", "end": "(?<=\"|')", - "patterns": [ {"include": "#string"} ] + "patterns": [{ "include": "#string" }] }, { "name": "default.value.nushell", @@ -310,29 +306,29 @@ }, "function-multiple-inout": { "begin": "(?<=]\\s*)(:)\\s+(\\[)", - "beginCaptures": { - "1": { "name": "punctuation.definition.in-out.nushell" }, - "2": { "name": "meta.brace.square.begin.nushell" } - }, - "end": "\\]", - "endCaptures": { - "0": { "name": "meta.brace.square.end.nushell" } - }, - "patterns": [ - { "include": "#types" }, - { - "match": "\\s*(,)\\s*", - "captures": { - "1": { "name": "punctuation.separator.nushell" } - } - }, - { - "match": "\\s+(->)\\s+", - "captures": { - "1": { "name": "keyword.operator.nushell" } - } - } - ] + "beginCaptures": { + "1": { "name": "punctuation.definition.in-out.nushell" }, + "2": { "name": "meta.brace.square.begin.nushell" } + }, + "end": "\\]", + "endCaptures": { + "0": { "name": "meta.brace.square.end.nushell" } + }, + "patterns": [ + { "include": "#types" }, + { + "match": "\\s*(,)\\s*", + "captures": { + "1": { "name": "punctuation.separator.nushell" } + } + }, + { + "match": "\\s+(->)\\s+", + "captures": { + "1": { "name": "keyword.operator.nushell" } + } + } + ] }, "function-inout": { "patterns": [ @@ -541,7 +537,10 @@ "match": "(\\$\"((?:[^\"\\\\]|\\\\.)*)\")\\s*(:)\\s*", "captures": { "1": { "name": "variable.other.nushell" }, - "2": { "name": "variable.other.nushell", "patterns": [{ "include": "#paren-expression" }] }, + "2": { + "name": "variable.other.nushell", + "patterns": [{ "include": "#paren-expression" }] + }, "3": { "name": "keyword.control.nushell" } }, "name": "meta.record-entry.nushell" @@ -558,7 +557,10 @@ "match": "(\\$'([^']*)')\\s*(:)\\s*", "captures": { "1": { "name": "variable.other.nushell" }, - "2": { "name": "variable.other.nushell", "patterns": [{ "include": "#paren-expression" }] }, + "2": { + "name": "variable.other.nushell", + "patterns": [{ "include": "#paren-expression" }] + }, "3": { "name": "keyword.control.nushell" } }, "name": "meta.record-entry.nushell" diff --git a/webpack.config.js b/webpack.config.js index 329b311..0035d65 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,31 +1,31 @@ /* eslint-disable @typescript-eslint/no-var-requires */ //@ts-check -"use strict"; +'use strict'; // eslint-disable-next-line no-undef -const path = require("path"); +const path = require('path'); /**@type {import('webpack').Configuration}*/ const config = { - target: "node", // vscode extensions run in a Node.js-context 📖 -> https://webpack.js.org/configuration/node/ + target: 'node', // vscode extensions run in a Node.js-context 📖 -> https://webpack.js.org/configuration/node/ - entry: "./client/src/extension.ts", // the entry point of this extension, 📖 -> https://webpack.js.org/configuration/entry-context/ + entry: './client/src/extension.ts', // the entry point of this extension, 📖 -> https://webpack.js.org/configuration/entry-context/ output: { // the bundle is stored in the 'dist' folder (check package.json), 📖 -> https://webpack.js.org/configuration/output/ // eslint-disable-next-line no-undef - path: path.resolve(__dirname, "out"), - filename: "extension.js", - libraryTarget: "commonjs2", - devtoolModuleFilenameTemplate: "../[resource-path]", + path: path.resolve(__dirname, 'out'), + filename: 'extension.js', + libraryTarget: 'commonjs2', + devtoolModuleFilenameTemplate: '../[resource-path]', }, - devtool: "source-map", + devtool: 'source-map', externals: { - vscode: "commonjs vscode", // the vscode-module is created on-the-fly and must be excluded. Add other modules that cannot be webpack'ed, 📖 -> https://webpack.js.org/configuration/externals/ + vscode: 'commonjs vscode', // the vscode-module is created on-the-fly and must be excluded. Add other modules that cannot be webpack'ed, 📖 -> https://webpack.js.org/configuration/externals/ }, resolve: { // support reading TypeScript and JavaScript files, 📖 -> https://github.com/TypeStrong/ts-loader - extensions: [".ts", ".js"], + extensions: ['.ts', '.js'], }, module: { rules: [ @@ -34,7 +34,7 @@ const config = { exclude: /node_modules/, use: [ { - loader: "ts-loader", + loader: 'ts-loader', }, ], },