Comments (2)
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 spork/fmt
functionality to work are:
- Include a bundled
spork/fmt.janet
file - Include the content of the file as a string
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 spork/fmt.janet
file from time to time. One example of why one might want to update the content is that sometimes things are added to janet that one might want to highlight differently.
from vscode-janet.
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).
from vscode-janet.
Related Issues (7)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vscode-janet.