Skip to content

Commit

Permalink
changing $SHELL_PATH from '/usr/bin/fish' -> to '/usr/local/bin/fish' (
Browse files Browse the repository at this point in the history
…#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 <ndonfris29@gmail.com>
  • Loading branch information
ndonfris committed May 3, 2024
1 parent a1990ec commit 2dfb5fd
Show file tree
Hide file tree
Showing 31 changed files with 141 additions and 136 deletions.
18 changes: 16 additions & 2 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
2 changes: 1 addition & 1 deletion fish_files/generate-global-completions.fish
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/fish
#!/usr/local/bin/fish

# locally scope _x
set -l _x
Expand Down
2 changes: 1 addition & 1 deletion fish_files/generate-suggestion.fish
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/fish -i
#!/usr/local/bin/fish -i


commandline -r "$argv";and commandline -f accept_autosuggestion
Expand Down
2 changes: 1 addition & 1 deletion fish_files/get-all-subcommands.fish
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion fish_files/get-command-options.fish
Original file line number Diff line number Diff line change
@@ -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")
Expand Down
2 changes: 1 addition & 1 deletion fish_files/get-completion.fish
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/fish
#!/usr/local/bin/fish

##
# File takes two arguments:
Expand Down
2 changes: 1 addition & 1 deletion fish_files/get-current-subcommands.fish
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/fish
#!/usr/local/bin/fish


for _sub in (fish -c "complete --do-complete='$argv '")
Expand Down
2 changes: 1 addition & 1 deletion fish_files/get-dependency.fish
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/fish
#!/usr/local/bin/fish



Expand Down
2 changes: 1 addition & 1 deletion fish_files/get-documentation.fish
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 1 addition & 1 deletion fish_files/get-fish-history-completions.fish
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/fish
#!/usr/local/bin/fish

#
# this file prints the first 3 history commands matching the $argv
Expand Down
2 changes: 1 addition & 1 deletion fish_files/get-help-completion.fish
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/fish
#!/usr/local/bin/fish

$argv --help 2>>/dev/null
2 changes: 1 addition & 1 deletion fish_files/get-type.fish
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion fish_files/small_script.fish
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
16 changes: 9 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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": "*",
Expand Down Expand Up @@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 2 additions & 7 deletions scripts/build-fish-wasm.sh → scripts/build-fish-wasm.fish
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion scripts/build-logs.sh → scripts/build-logs.fish
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env fish

echo "" > ./logs.txt
echo "" > ./logs.txt
File renamed without changes.
2 changes: 1 addition & 1 deletion scripts/relink-locally.sh → scripts/relink-locally.fish
Original file line number Diff line number Diff line change
Expand Up @@ -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'
File renamed without changes.
77 changes: 39 additions & 38 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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))
Expand All @@ -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
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -313,7 +316,6 @@ commandBin.command('url')
process.exit(0);
});


// COMPLETE
commandBin.command('complete')
.summary('generate completions file for ~/.config/fish/completions')
Expand Down Expand Up @@ -343,7 +345,6 @@ commandBin.command('complete')
process.exit(0);
});


/**
* PARSE THE SUBCOMMAND/OPTION
*/
Expand Down
28 changes: 13 additions & 15 deletions src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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 {
Expand All @@ -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}`);
}
Expand All @@ -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<T extends Record<string, any>>(objs: T[], ...keys: (keyof T)[]): void {
Expand Down Expand Up @@ -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(),
};
}
}

Expand Down Expand Up @@ -153,4 +151,4 @@ export function createServerLogger(logFilePath: string = '', clear: boolean = tr

export function createJestLogger(): JestLogger {
return new JestLogger();
}
}
Loading

0 comments on commit 2dfb5fd

Please sign in to comment.