-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhancement: Make extension work independently on jpm / spork being installed #13
Comments
I started thinking about how this might be done. Two possibilities (may be there are others) about how the extension might access bits necessary for
The latter might look rather messy if the formatting is accomplished via the current means of sending text to a janet repl. Perhaps the approach of a bundled file would be preferrable. It's been a while since I've done VSCode extension tinkering, but it looks like it is (or at least was) possible to get at a file which the extension bundles. I think the following is an example of a function that can get the absolute path to a relevant file: /**
* Returns the absolute path to a file located in our misc folder.
*
* @param file The base file name.
* @param context The context of this extension to get its path regardless where it is installed.
* @param webview When given format the path for use in this webview.
*
* @returns The computed path.
*/
public static getMiscPath(file: string, context: ExtensionContext, webview?: Webview): string {
if (webview) {
const uri = Uri.file(context.asAbsolutePath(path.join("misc", file)));
return webview.asWebviewUri(uri).toString();
}
return context.asAbsolutePath(path.join("misc", file));
} So with the absolute path in hand presumably we can modify this bit: sendSource(terminal, "(import spork/fmt) (fmt/format-file \""+ to import our bundled file. If that kind of approach works, may be it will also be easier (as compared with storing the functionality in a string) to update the included |
Ok, here is a draft. Have only tried on a Linux box. There may be better ways, but at least it seems doable. The main changes code-wise are here. I tried to arrange for things in a way such that nothing got introduced in one's repl environment that would interfere with other things going on (not sure if I was successful). |
Janet is a small language that can be conveniently installed and used just by copying a single binary, with no other dependencies or libraries.
However, the formatting in the VS Code extension only works if spork is installed. To install spork, jpm has to be installed.
It's trivial to modify the extension so that it runs independently on jpm or spork, requiring just the
janet
binary. I think this would make it easier to use the extension for people who are e.g. just trying Janet out and do not (yet) even know what jpm or spork is.The text was updated successfully, but these errors were encountered: