From 2dfb5fd6bfc801e6ccf4939f421295a3e5d7d7d3 Mon Sep 17 00:00:00 2001 From: nick <49458459+ndonfris@users.noreply.github.com> Date: Fri, 3 May 2024 04:25:25 -0500 Subject: [PATCH] changing $SHELL_PATH from '/usr/bin/fish' -> to '/usr/local/bin/fish' (#21) * chore: fixing macos /usr/bin/fish -> /usr/local/bin/fish - "brew install fish" goes to location -> "/usr/local/bin/fish" on mac - changed various shebangs (one changed in prod, via src/utils/exec.ts) - macos "cp" needs second argument to be a directory -> changed to . in scripts/build-fish-wasm.fish - change fish_files/* in multiple locations * docs: updated cli.ts * chore: hotfix from eslint * feat: fixed abbr in `src/utils/builtins.ts` Signed-off-by: ndonfris --- docs/CHANGELOG.md | 18 ++++- fish_files/generate-global-completions.fish | 2 +- fish_files/generate-suggestion.fish | 2 +- fish_files/get-all-subcommands.fish | 2 +- fish_files/get-command-options.fish | 2 +- fish_files/get-completion.fish | 2 +- fish_files/get-current-subcommands.fish | 2 +- fish_files/get-dependency.fish | 2 +- fish_files/get-documentation.fish | 2 +- fish_files/get-fish-history-completions.fish | 2 +- fish_files/get-help-completion.fish | 2 +- fish_files/get-type.fish | 2 +- fish_files/small_script.fish | 2 +- package.json | 16 ++-- ...-completions.sh => build-completions.fish} | 1 + ...uild-fish-wasm.sh => build-fish-wasm.fish} | 9 +-- scripts/{build-logs.sh => build-logs.fish} | 2 +- scripts/{build-time.sh => build-time.fish} | 0 ...{relink-locally.sh => relink-locally.fish} | 2 +- scripts/{setup.sh => setup.fish} | 0 src/cli.ts | 77 ++++++++++--------- src/logger.ts | 28 ++++--- src/server.ts | 5 +- src/utils/builtins.ts | 1 + src/utils/commander-cli-subcommands.ts | 38 ++++----- src/utils/configuration-manager.ts | 2 +- src/utils/exec.ts | 8 +- src/utils/get-lsp-completions.ts | 34 ++++---- .../fish_files/advanced/variable_scope.fish | 4 +- test-data/node-types.test.ts | 4 +- .../querying-examples-for-future-devs.test.ts | 4 +- 31 files changed, 141 insertions(+), 136 deletions(-) rename scripts/{build-completions.sh => build-completions.fish} (99%) rename scripts/{build-fish-wasm.sh => build-fish-wasm.fish} (64%) rename scripts/{build-logs.sh => build-logs.fish} (50%) rename scripts/{build-time.sh => build-time.fish} (100%) rename scripts/{relink-locally.sh => relink-locally.fish} (92%) rename scripts/{setup.sh => setup.fish} (100%) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 87fd6bdf..1c3b5b91 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -2,10 +2,24 @@ Documenting notable changes across project verisions -## \[1.0.3\] - 2023-05-29 +=== + +## Current + +### [PR #21](https://github.com/unclechu/node-deep-extend/pull/21) -- 2024-05-03 + +- converted `scripts/*.sh` to `scripts/*.fish` + - package.json _run-scripts_ now calls `fish script/file.fish` +- added abbr to [src/utils/builtins.ts](../src/utils/builtins.ts) +- moved shebang to `/usr/bin/fish` to `/usr/local/bin/fish` + - or used `/usr/bin/env fish` +- mam-page updated +- added `--help-*` hidden flags + +## \[1.0.3\] - 2024-05-29 - Added CHANGELOG.md -- Changed [scripts/build-time.sh](../scripts/build-time.sh) to 24 hour format +- Changed [scripts/build-time.sh](../scripts/build-time.fish) to 24 hour format - [README.md](../README.md) major formatting changes - [Wiki](https://github.com/ndonfris/fish-lsp/wiki) additions - added _contributors_ to [CONTRIBUTING](./CONTRIBUTING.md), via `.all-contributorsrc` diff --git a/fish_files/generate-global-completions.fish b/fish_files/generate-global-completions.fish index 80496913..d7120815 100755 --- a/fish_files/generate-global-completions.fish +++ b/fish_files/generate-global-completions.fish @@ -1,4 +1,4 @@ -#!/usr/bin/fish +#!/usr/local/bin/fish # locally scope _x set -l _x diff --git a/fish_files/generate-suggestion.fish b/fish_files/generate-suggestion.fish index 669ad6a4..fa19fadd 100755 --- a/fish_files/generate-suggestion.fish +++ b/fish_files/generate-suggestion.fish @@ -1,4 +1,4 @@ -#!/usr/bin/fish -i +#!/usr/local/bin/fish -i commandline -r "$argv";and commandline -f accept_autosuggestion diff --git a/fish_files/get-all-subcommands.fish b/fish_files/get-all-subcommands.fish index 1e2eae9a..92f3d961 100755 --- a/fish_files/get-all-subcommands.fish +++ b/fish_files/get-all-subcommands.fish @@ -1,4 +1,4 @@ -#!/usr/bin/fish +#!/usr/local/bin/fish set -l ignore_completions "vared" "funced" "begin" "while" "if" "for" "function" "functions" "funcsave" "help" diff --git a/fish_files/get-command-options.fish b/fish_files/get-command-options.fish index 5afed569..94b740a9 100755 --- a/fish_files/get-command-options.fish +++ b/fish_files/get-command-options.fish @@ -1,4 +1,4 @@ -#!/usr/bin/fish +#!/usr/local/bin/fish function backup_input set -a -l _fish_lsp_file_cmps (fish -c "complete --do-complete '$argv -' | uniq") (fish -c "complete --do-complete '$argv ' | uniq") diff --git a/fish_files/get-completion.fish b/fish_files/get-completion.fish index 86764460..7339c7b2 100755 --- a/fish_files/get-completion.fish +++ b/fish_files/get-completion.fish @@ -1,4 +1,4 @@ -#!/usr/bin/fish +#!/usr/local/bin/fish ## # File takes two arguments: diff --git a/fish_files/get-current-subcommands.fish b/fish_files/get-current-subcommands.fish index 94d8e87a..77f1a992 100755 --- a/fish_files/get-current-subcommands.fish +++ b/fish_files/get-current-subcommands.fish @@ -1,4 +1,4 @@ -#!/usr/bin/fish +#!/usr/local/bin/fish for _sub in (fish -c "complete --do-complete='$argv '") diff --git a/fish_files/get-dependency.fish b/fish_files/get-dependency.fish index c28e515f..2c3621db 100755 --- a/fish_files/get-dependency.fish +++ b/fish_files/get-dependency.fish @@ -1,4 +1,4 @@ -#!/usr/bin/fish +#!/usr/local/bin/fish diff --git a/fish_files/get-documentation.fish b/fish_files/get-documentation.fish index 13eb4034..824cbe94 100755 --- a/fish_files/get-documentation.fish +++ b/fish_files/get-documentation.fish @@ -1,4 +1,4 @@ -#!/usr/bin/fish +#!/usr/local/bin/fish ## commands like mkdir or touch should reach this point function _flsp_get_command_without_manpage -d 'fallback for a command passed in without a manpage' diff --git a/fish_files/get-fish-history-completions.fish b/fish_files/get-fish-history-completions.fish index 697ad063..80e0ebb1 100755 --- a/fish_files/get-fish-history-completions.fish +++ b/fish_files/get-fish-history-completions.fish @@ -1,4 +1,4 @@ -#!/usr/bin/fish +#!/usr/local/bin/fish # # this file prints the first 3 history commands matching the $argv diff --git a/fish_files/get-help-completion.fish b/fish_files/get-help-completion.fish index 33193ae6..ff7ef326 100755 --- a/fish_files/get-help-completion.fish +++ b/fish_files/get-help-completion.fish @@ -1,3 +1,3 @@ -#!/usr/bin/fish +#!/usr/local/bin/fish $argv --help 2>>/dev/null diff --git a/fish_files/get-type.fish b/fish_files/get-type.fish index 91923aa1..671dffa4 100755 --- a/fish_files/get-type.fish +++ b/fish_files/get-type.fish @@ -1,4 +1,4 @@ -#!/usr/bin/fish +#!/usr/local/bin/fish function get_type --argument-names str set -l type_result (type -t "$str" 2> /dev/null) diff --git a/fish_files/small_script.fish b/fish_files/small_script.fish index 1e2eae9a..92f3d961 100755 --- a/fish_files/small_script.fish +++ b/fish_files/small_script.fish @@ -1,4 +1,4 @@ -#!/usr/bin/fish +#!/usr/local/bin/fish set -l ignore_completions "vared" "funced" "begin" "while" "if" "for" "function" "functions" "funcsave" "help" diff --git a/package.json b/package.json index 2980a4b0..05f66892 100755 --- a/package.json +++ b/package.json @@ -22,12 +22,12 @@ "scripts": { "setup": "yarn run sh:setup", "postinstall": "yarn run sh:build-wasm && yarn run sh:build-time && yarn run compile && yarn run sh:relink && yarn run sh:build-completions", - "sh:build-completions": "./scripts/build-completions.sh", - "sh:build-logs": "./scripts/build-logs.sh", - "sh:build-time": "./scripts/build-time.sh", - "sh:setup": "./scripts/setup.sh", - "sh:build-wasm": "./scripts/build-fish-wasm.sh", - "sh:relink": "./scripts/relink-locally.sh", + "sh:build-completions": "fish ./scripts/build-completions.fish", + "sh:build-logs": "fish ./scripts/build-logs.fish", + "sh:build-time": "fish ./scripts/build-time.fish", + "sh:setup": "fish ./scripts/setup.fish", + "sh:build-wasm": "fish ./scripts/build-fish-wasm.fish", + "sh:relink": "fish ./scripts/relink-locally.fish", "pre:clean": "yarn exec rimraf lib *.tsbuildinfo out", "clean": "yarn run pre:clean && yarn install", "clean-nodemodules": "yarn rimraf out *.tsbuildinfo node_modules && yarn install", @@ -93,6 +93,7 @@ "husky": "^9.0.11", "lua-json": "^1.0.1", "marked-man": "^1.3.5", + "tree-sitter": "^0.21.0", "ts-jest": "^29.1.2", "tsc": "^2.0.4", "typescript": "*", @@ -128,5 +129,6 @@ "rimraf": "^5.0.5", "tree-sitter-cli": "^0.22.2", "tree-sitter-fish": "https://github.com/ram02z/tree-sitter-fish" - } + }, + "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e" } diff --git a/scripts/build-completions.sh b/scripts/build-completions.fish similarity index 99% rename from scripts/build-completions.sh rename to scripts/build-completions.fish index c7f98476..18067eed 100755 --- a/scripts/build-completions.sh +++ b/scripts/build-completions.fish @@ -3,4 +3,5 @@ if not test -d $HOME/.config/fish/completions mkdir -p $HOME/.config/fish/completions end + fish-lsp complete > $HOME/.config/fish/completions/fish-lsp.fish diff --git a/scripts/build-fish-wasm.sh b/scripts/build-fish-wasm.fish similarity index 64% rename from scripts/build-fish-wasm.sh rename to scripts/build-fish-wasm.fish index 4be02a33..6c791ad8 100755 --- a/scripts/build-fish-wasm.sh +++ b/scripts/build-fish-wasm.fish @@ -1,6 +1,6 @@ #!/usr/bin/env fish -set -l wasm_file "$(find node_modules/ -type f -a -name tree-sitter-fish.wasm)" +set -l wasm_file "$(find node_modules -type f -a -name tree-sitter-fish.wasm)" if test -z "$wasm_file" yarn add @esdmr/tree-sitter-fish @@ -13,10 +13,5 @@ if test -z "$wasm_file" exit 1 end -cp $wasm_file ./tree-sitter-fish.wasm --force +cp -f "$wasm_file" . and echo "SUCCESS: tree-sitter-fish.wasm copied" - -# yarn remove @esdmr/tree-sitter-fish -# npx tree-sitter build -w ./node_modules/tree-sitter-fish/ -o ./tree-sitter-fish.wasm -# -# yarn remove tree-sitter-cli tree-sitter-fish diff --git a/scripts/build-logs.sh b/scripts/build-logs.fish similarity index 50% rename from scripts/build-logs.sh rename to scripts/build-logs.fish index e7758152..fe31fd64 100755 --- a/scripts/build-logs.sh +++ b/scripts/build-logs.fish @@ -1,3 +1,3 @@ #!/usr/bin/env fish -echo "" > ./logs.txt +echo "" > ./logs.txt \ No newline at end of file diff --git a/scripts/build-time.sh b/scripts/build-time.fish similarity index 100% rename from scripts/build-time.sh rename to scripts/build-time.fish diff --git a/scripts/relink-locally.sh b/scripts/relink-locally.fish similarity index 92% rename from scripts/relink-locally.sh rename to scripts/relink-locally.fish index 94009cf2..752a35f4 100755 --- a/scripts/relink-locally.sh +++ b/scripts/relink-locally.fish @@ -20,4 +20,4 @@ if command -vq fish-lsp yarn global remove 'fish-lsp' 2>> /dev/null end yarn link --global "fish-lsp" --force -echo -e '\n"fish-lsp" is now installed and linked' +echo -e '\n"fish-lsp" is now installed and linked' \ No newline at end of file diff --git a/scripts/setup.sh b/scripts/setup.fish similarity index 100% rename from scripts/setup.sh rename to scripts/setup.fish diff --git a/src/cli.ts b/src/cli.ts index 20f6ec1b..5267a1f2 100755 --- a/src/cli.ts +++ b/src/cli.ts @@ -50,7 +50,9 @@ export function startWebscoket() { */ const createFishLspBin = (): Command => { const bin = new Command('fish-lsp'); - bin.description('Description:\n'+ FishLspHelp.description) + + bin.description(`Description:\n${FishLspHelp.description}`) + .version(PackageVersion, '-v, --version', 'output the version number') .enablePositionalOptions(true) .configureHelp({ @@ -60,14 +62,16 @@ const createFishLspBin = (): Command => { }) .showSuggestionAfterError() .showHelpAfterError() - .addHelpText('after', FishLspHelp.after) + + .addHelpText('after', FishLspHelp.after); return bin; }; -// start adding options to the command +// start adding options to the command export const commandBin = createFishLspBin(); -// hidden global options +// hidden global options + commandBin .addOption(new Option('--help-man', 'show special manpage output').hideHelp(true)) .addOption(new Option('--help-all', 'show all help info').hideHelp(true)) @@ -76,37 +80,35 @@ commandBin if (opt.helpMan) { const { path, content } = FishLspManPage(); console.log(content.join('\n').trim()); - } - else if (opt.helpAll) { - console.log("NAME:"); + } else if (opt.helpAll) { + console.log('NAME:'); console.log('fish-lsp - an lsp for the fish shell language'); - console.log() - console.log('USAGE: ', FishLspHelp.beforeAll) - console.log() - console.log('DESCRIPTION:\n'+commandBin.description().split('\n').slice(1).join('\n')) console.log(); - console.log('OPTIONS:') - const globalOpts = commandBin.options.concat(new Option('-h, --help', 'show help')) - console.log(globalOpts.map(o =>' '+o.flags+'\t'+o.description).join('\n')) + console.log('USAGE: ', FishLspHelp.beforeAll); + console.log(); + console.log('DESCRIPTION:\n', commandBin.description().split('\n').slice(1).join('\n')); + console.log(); + console.log('OPTIONS:'); + const globalOpts = commandBin.options.concat(new Option('-h, --help', 'show help')); + console.log(globalOpts.map(o =>' ' + o.flags + '\t' + o.description).join('\n')); console.log('\nSUBCOMMANDS:'); commandBin.commands.forEach((cmd) => { // console.log(` ${cmd.name().toUpperCase()} - ${cmd.summary()}`); console.log(` ${cmd.name()} ${cmd.usage()}\t${cmd.summary()}`); - console.log(cmd.options.map(o => ` ${o.flags}\t\t${o.description}`).join('\n')) + + console.log(cmd.options.map(o => ` ${o.flags}\t\t${o.description}`).join('\n')); console.log(); - }) + }); console.log('EXAMPLES:\n'); - console.log(FishLspHelp.after.split('\n').slice(2).join('\n')) - - } - else if (opt.helpShort) { - console.log('Usage: fish-lsp ' + commandBin.usage().split('\n').slice(0,1)); + console.log(FishLspHelp.after.split('\n').slice(2).join('\n')); + } else if (opt.helpShort) { + console.log('Usage: fish-lsp ', commandBin.usage().split('\n').slice(0, 1)); console.log(); console.log(commandBin.description()); } - process.exit(0) - }) + process.exit(0); + }); // START @@ -187,30 +189,31 @@ commandBin.command('bare [TOGGLE...]') // LOGGER commandBin.command('logger') .summary('test the logger by displaying it') - .option('-s, --show', 'show the logger and don\'t edit it') + .option('-s, --show', 'show the logger and don\'t edit it') .option('-c, --clear', 'clear the logger') - .option('-d, --date', 'write the date') + .option('-d, --date', 'write the date') .option('-q, --quiet', 'silence logging') .option('--config', 'show the logger config') .action(args => { - let logger = createServerLogger(ServerLogsPath, false) - const objArgs = Object.getOwnPropertyNames(args) - const argsQueue = objArgs + const logger = createServerLogger(ServerLogsPath, false); + const objArgs = Object.getOwnPropertyNames(args); + const argsQueue = objArgs; let currentArg: string = ''; while (argsQueue.length !== 0) { - currentArg = argsQueue.shift() || '' + currentArg = argsQueue.shift() || ''; if (currentArg === 'clear') logger.clearLogFile(); - if (currentArg === 'quiet') logger.toggleSilence() - if (currentArg === 'date') logger.log(getBuildTimeString()) - if (currentArg === 'config') console.log(JSON.stringify(logger.getLoggingOpts())) + if (currentArg === 'quiet') logger.toggleSilence(); + if (currentArg === 'date') logger.log(getBuildTimeString()); + if (currentArg === 'config') console.log(JSON.stringify(logger.getLoggingOpts())); if (currentArg === 'show') break; } - if (!args.show) return + if (!args.show) return; // if (args.show) logger.showLogfileText() - logger.showLogfileText() - return - }) + logger.showLogfileText(); + return; + }); + // INFO commandBin.command('info') @@ -313,7 +316,6 @@ commandBin.command('url') process.exit(0); }); - // COMPLETE commandBin.command('complete') .summary('generate completions file for ~/.config/fish/completions') @@ -343,7 +345,6 @@ commandBin.command('complete') process.exit(0); }); - /** * PARSE THE SUBCOMMAND/OPTION */ diff --git a/src/logger.ts b/src/logger.ts index 8c4119a1..3ed188d1 100755 --- a/src/logger.ts +++ b/src/logger.ts @@ -10,8 +10,6 @@ // ExecuteCommandParams, // } from 'vscode-languageserver'; import * as console from 'node:console'; -//private LOGFILE: string = resolve('/home/ndonfris/repos/fish-lang-server/logs.txt') - import fs from 'fs'; import { resolve } from 'path'; @@ -41,16 +39,15 @@ export class Logger { } toggleSilence() { - this._silence = !this._silence + this._silence = !this._silence; } toggleJson() { - this._onlyJson = !this._onlyJson + this._onlyJson = !this._onlyJson; } - hasSilence() { - return this._silence + return this._silence; } hasLogFile(): boolean { @@ -60,7 +57,7 @@ export class Logger { clearLogFile(): void { try { // fs.truncateSync(this.logFilePath, 0); - fs.writeFileSync(this.logFilePath, '') + fs.writeFileSync(this.logFilePath, ''); } catch (error) { this._console.error(`Error clearing log file: ${error}`); } @@ -87,9 +84,10 @@ export class Logger { logAsJson(message: string) { this.logToFile(JSON.stringify({ - "date": new Date().toLocaleString(), - "message": message - })) + date: new Date().toLocaleString(), + message: message, + })); + } logPropertiesForEachObject>(objs: T[], ...keys: (keyof T)[]): void { @@ -118,11 +116,11 @@ export class Logger { this._console.log(fs.readFileSync(this.logFilePath, 'utf-8')); } - getLoggingOpts() { + getLoggingOpts() { return { - 'logFile': this.hasLogFile(), - 'silence': this.hasSilence(), - } + logFile: this.hasLogFile(), + silence: this.hasSilence(), + }; } } @@ -153,4 +151,4 @@ export function createServerLogger(logFilePath: string = '', clear: boolean = tr export function createJestLogger(): JestLogger { return new JestLogger(); -} \ No newline at end of file +} diff --git a/src/server.ts b/src/server.ts index edd4a3e4..1f101045 100755 --- a/src/server.ts +++ b/src/server.ts @@ -94,7 +94,8 @@ export default class FishServer { async initialize(params: InitializeParams): Promise { this.logger.logAsJson( - `Initialized server FISH-LSP with ${params.workspaceFolders || ''}` + `Initialized server FISH-LSP with ${params.workspaceFolders || ''}`, + ); // console.log(`Initialized server FISH-LSP with ${params.workspaceFolders || ""}`); const result: InitializeResult = { @@ -144,7 +145,7 @@ export default class FishServer { }, }; this.config.mergePreferences(params.initializationOptions); - this.logger.logAsJson(JSON.stringify({ 'onInitializedResult': result })); + this.logger.logAsJson(JSON.stringify({ onInitializedResult: result })); return result; } diff --git a/src/utils/builtins.ts b/src/utils/builtins.ts index dbd7292e..8ac38f9b 100755 --- a/src/utils/builtins.ts +++ b/src/utils/builtins.ts @@ -3,6 +3,7 @@ import { exec, execSync, spawn, spawnSync, SpawnSyncOptionsWithBufferEncoding, S export const BuiltInList = [ '[', '_', + 'abbr', 'and', 'argparse', 'begin', diff --git a/src/utils/commander-cli-subcommands.ts b/src/utils/commander-cli-subcommands.ts index b2478db0..ea3cf3f7 100755 --- a/src/utils/commander-cli-subcommands.ts +++ b/src/utils/commander-cli-subcommands.ts @@ -483,7 +483,7 @@ const getOutTime = () => { export const getBuildTimeString = () => { return getOutTime(); }; - + export const FishLspHelp = { beforeAll: ` fish-lsp [-h | --help] [-v | --version] [--help-man] [--help-all] [--help-short] @@ -495,36 +495,36 @@ export const FishLspHelp = { fish-lsp complete`, usage: `fish-lsp [OPTION] fish-lsp [COMMAND [OPTION...]]`, - // fish-lsp [start | logger | info | url | complete] [options] - // fish-lsp [-h | --help] [-v | --version] [--help-man] [--help-all] [--help-short] + // fish-lsp [start | logger | info | url | complete] [options] + // fish-lsp [-h | --help] [-v | --version] [--help-man] [--help-all] [--help-short] description: [ - ` A language server for the \`fish-shell\`, written in typescript. Currently supports`, + ' A language server for the `fish-shell`, written in typescript. Currently supports', ` the following feature set from "'${PackageLspVersion}'" of the language server protocol.`, ' More documentation is available for any command or subcommand via \'-h/--help\'.', '', ' The current language server protocol, reserves stdin/stdout for communication between the ', ' client and server. This means that when the server is started, it will listen for messages on', - ' not displaying any output from the command.', + ' stdin/stdout. Command communitcation will be visible in `logs.txt`.', '', ' For more information, see the github repository:', ` ${RepoUrl}`, ].join('\n'), after: [ - '', - 'Examples:', - ' # Default setup, with all options enabled', - ' > fish-lsp start ', - '', - ' # Generate and store completions file:', - ' > fish-lsp complete > ~/.config/fish/completions/fish-lsp.fish', - ].join('\n') -} + '', + 'Examples:', + ' # Default setup, with all options enabled', + ' > fish-lsp start ', + '', + ' # Generate and store completions file:', + ' > fish-lsp complete > ~/.config/fish/completions/fish-lsp.fish', + ].join('\n'), +}; export function FishLspManPage() { - const manFile = PathObj.manFile - const content = readFileSync(manFile, 'utf8') + const manFile = PathObj.manFile; + const content = readFileSync(manFile, 'utf8'); return { path: resolve(PathObj.root, PathObj.manFile), - content: content.split('\n') - } -} \ No newline at end of file + content: content.split('\n'), + }; +} diff --git a/src/utils/configuration-manager.ts b/src/utils/configuration-manager.ts index dcb170dc..3663d867 100644 --- a/src/utils/configuration-manager.ts +++ b/src/utils/configuration-manager.ts @@ -103,4 +103,4 @@ export function bareStartupManger() { export function mainStartupManager() { const map = new ConfigMap(); return map.setup(true); -} \ No newline at end of file +} diff --git a/src/utils/exec.ts b/src/utils/exec.ts index 4bbd2054..948f2b0d 100755 --- a/src/utils/exec.ts +++ b/src/utils/exec.ts @@ -31,14 +31,8 @@ export async function execEscapedCommand(cmd: string): Promise { export async function execCmd(cmd: string): Promise { const { stdout } = await execAsync(cmd, { - shell: '/usr/bin/fish', + shell: 'fish', encoding: 'buffer', - maxBuffer: 1024 * 1024 * 8, - env: { - PATH: process.env.PATH, - USER: process.env.USER, - HOME: process.env.HOME, - }, // windowsHide: true, // cwd: process.cwd(), // gid: process.getegid(), diff --git a/src/utils/get-lsp-completions.ts b/src/utils/get-lsp-completions.ts index 7cc7b9bc..a737353e 100644 --- a/src/utils/get-lsp-completions.ts +++ b/src/utils/get-lsp-completions.ts @@ -24,7 +24,7 @@ const AUTO_GENERATED_HEADER_STRING = `# # # ~/...install_path.../fish-lsp/src/utils/get-lsp-completions.ts # -` +`; const __fish_lsp_needs_command = ` # Returns exit code of 0 if lsp hasn't received a command yet, e.g. \`start\` @@ -46,7 +46,7 @@ function __fish_lsp_needs_command end return 1 end -` +`; const __fish_lsp_using_command = ` # Returns exit code of 0 if any command (argv[1..-1]) appears once, ignores flags. @@ -78,7 +78,7 @@ function __fish_lsp_using_command end return 1 end -` +`; const __fish_lsp_includes_subcommand = ` # Check if \`commandline\` contains a set of subcommands @@ -91,12 +91,11 @@ function __fish_lsp_includes_subcommand end return 1 end -` +`; - -/** +/** * Syntax for urlCompletions does not match other completions because it is not influenced - * by recieving multiple duplicated arguments + * by recieving multiple duplicated arguments */ const urlCompletions: string = `# fish-lsp url -- complete -c fish-lsp -n "__fish_seen_subcommand_from url" -a " @@ -111,7 +110,7 @@ complete -c fish-lsp -n "__fish_seen_subcommand_from url" -a " --discussions\t'show git discussions url' --clients-repo\t'show git clients-repo url' --sources\t'show useful list of sources'" -` +`; const completeCompletions: string = `# fish-lsp complete complete -c fish-lsp -n __fish_use_subcommand -a complete -d 'completion utils for fish-lsp cli' @@ -119,7 +118,7 @@ complete -c fish-lsp -n '__fish_lsp_using_command complete; and not __fish_conta complete -c fish-lsp -n '__fish_lsp_using_command complete; and not __fish_contains_opt fish' -l fish -d 'show completion/fish-lsp.fish' complete -c fish-lsp -n '__fish_lsp_using_command complete; and not __fish_contains_opt names' -l names -d 'show feature names of completions' complete -c fish-lsp -n '__fish_lsp_using_command complete; and not __fish_contains_opt toggle' -l toggle -d 'show feature names of completions' -` +`; const loggerCompletions: string = `# fish-lsp logger -- complete -c fish-lsp -n __fish_use_subcommand -x -a logger -d 'logger utilities' @@ -128,7 +127,7 @@ complete -c fish-lsp -n '__fish_lsp_using_command logger; and not __fish_contain complete -c fish-lsp -n '__fish_lsp_using_command logger; and not __fish_contains_opt -s q quiet' -s q -l quiet -d 'only write to "logs.txt" file' complete -c fish-lsp -n '__fish_lsp_using_command logger; and not __fish_contains_opt -s d date' -s d -l date -d 'write date to "logs.txt" file' complete -c fish-lsp -n '__fish_lsp_using_command logger; and not __fish_contains_opt config' -l config -d 'show the logger config' -` +`; const infoCompletions: string = `# fish-lsp info -- complete -c fish-lsp -n '__fish_lsp_using_command info; and not __fish_contains_opt bin' -l bin -d 'show the binary path' @@ -140,22 +139,21 @@ complete -c fish-lsp -n '__fish_lsp_using_command info; and not __fish_contains_ complete -c fish-lsp -n '__fish_lsp_using_command info; and not __fish_contains_opt man-file' -l man-file -d 'show man file path' complete -c fish-lsp -n '__fish_lsp_using_command info; and not __fish_contains_opt logs-file' -l logs-file -d 'show logs.txt file path' complete -c fish-lsp -n '__fish_lsp_using_command info; and not __fish_contains_opt more' -l more -d 'show more info' -` - +`; -const mapNames = ConfigMap.configNames.join(' ') +const mapNames = ConfigMap.configNames.join(' '); const featuresCompletions: string = `# print all $fish_lsp_submcommands function _fish_lsp_get_features printf %b\\n ${mapNames} end -` +`; // firefox-dev https://github.com/fish-shell/fish-shell/blob/master/share/completions/cjxl.fish export function buildFishLspCompletions(commandBin: Command) { const subcmdStrs = commandBin.commands.map(cmd => `${cmd.name()}\\t'${cmd.summary()}'`).join('\n'); const output: string[] = []; output.push(AUTO_GENERATED_HEADER_STRING); - output.push(__fish_lsp_using_command) + output.push(__fish_lsp_using_command); output.push('# disable file completions'); output.push('complete -c fish-lsp -f', ''); @@ -184,8 +182,8 @@ export function buildFishLspCompletions(commandBin: Command) { output.push('complete -c fish-lsp -n \'__fish_seen_subcommand_from $__fish_lsp_subcommands\' -l enable -xa \'(_fish_lsp_get_features)\''); output.push('complete -c fish-lsp -n \'__fish_seen_subcommand_from $__fish_lsp_subcommands\' -l disable -xa \'(_fish_lsp_get_features)\''); // output.push('\n# cp ~/.config/fish/completions/fish-lsp.fish ~/.config/fish/completions/fish-lsp.fish.bak'); - output.push('') - output.push('# built by the command: ') + output.push(''); + output.push('# built by the command: '); output.push('# fish-lsp complete ~/.config/fish/completions/fish-lsp.fish'); return output.join('\n'); -} \ No newline at end of file +} diff --git a/test-data/fish_files/advanced/variable_scope.fish b/test-data/fish_files/advanced/variable_scope.fish index cdbc5bf2..51b0532e 100755 --- a/test-data/fish_files/advanced/variable_scope.fish +++ b/test-data/fish_files/advanced/variable_scope.fish @@ -1,4 +1,4 @@ -#!/usr/bin/fish +#!/usr/local/bin/fish # file to show how scope works in fish shell # notice that the variable i is still available after the for loop @@ -33,4 +33,4 @@ begin; set ii 30 end; -echo $ii \ No newline at end of file +echo $ii diff --git a/test-data/node-types.test.ts b/test-data/node-types.test.ts index 88d0ac1c..0e75a47b 100755 --- a/test-data/node-types.test.ts +++ b/test-data/node-types.test.ts @@ -55,7 +55,7 @@ describe("node-types tests", () => { it('isShebang', () => { const testString = [ - "#!/usr/bin/env fish", + "#!/usr/local/bin/env fish", "# this is a comment", "#!/usr/bin/fish", ].join("\n"); @@ -188,4 +188,4 @@ describe("node-types tests", () => { assert.deepEqual(defs.map(d => d.text), ['set_foo', 'param_foo', 'i', 'read_foo']) }) -}) \ No newline at end of file +}) diff --git a/test-data/querying-examples-for-future-devs.test.ts b/test-data/querying-examples-for-future-devs.test.ts index 16a3ecb6..eb490029 100755 --- a/test-data/querying-examples-for-future-devs.test.ts +++ b/test-data/querying-examples-for-future-devs.test.ts @@ -83,7 +83,7 @@ describe("querying examples for future devs", () => { `builtin --names` ].join('\n'); const fishbangTwo = [ - `#!/usr/bin/fish`, + `#!/usr/local/bin/fish`, `echo "executing some fish commands..."` ].join('\n') const fishbangFail = [ @@ -162,4 +162,4 @@ describe("querying examples for future devs", () => { ////forVarScope //}) -}) \ No newline at end of file +})