Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ayecue/miniscript-vs
VSCode extension for MiniScript.
https://github.com/ayecue/miniscript-vs
Last synced: 15 days ago
JSON representation
VSCode extension for MiniScript.
- Host: GitHub
- URL: https://github.com/ayecue/miniscript-vs
- Owner: ayecue
- License: mit
- Created: 2023-11-12T17:52:42.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-14T14:34:38.000Z (about 1 month ago)
- Last Synced: 2024-12-14T15:25:37.046Z (about 1 month ago)
- Language: TypeScript
- Homepage: https://marketplace.visualstudio.com/items?itemName=ayecue.miniscript-vs
- Size: 1.36 MB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# miniscript-vs
A toolkit for [MiniScript](https://miniscript.org/) that provides features like syntax highlighting, code execution, bundling, and minification. For the latest changes, check the [changelog](https://github.com/ayecue/miniscript-vs/blob/main/CHANGELOG.md).
**Prefer a different editor?** The [MiniScript language server](https://github.com/ayecue/miniscript-languageserver/blob/main/packages/node/README.md) is also available and works with IDEs like Sublime Text, IntelliJ, nvim, and more. Setup examples are included in the repository.
## Usage
The plugin automatically detects `.ms` files.
Available commands (`CTRL+SHIFT+P`):
- `MiniScript: Build` - [info](#build)You can also access most commands from the context menu.
### Plugin Settings:
- **Autocomplete**: Activate/Deactivate
- **Diagnostic**: Activate/Deactivate
- **Hoverdocs**: Activate/Deactivate
- **Formatter**: Activate/Deactivate
- **Transpiler Settings:**
- **Build Type**: Default, Uglify, Beautify
- **Beautify**
- **Indentation**: Tab or whitespace. What should be used for indentation?
- **Indentation Spaces**: In case whitespace is used this will determine the amount of whitespaces.
- **Keep Parentheses**: Will always use parentheses.
- **Literals Optimizations**: Activate/Deactivate
- **Namespaces Optimizations**: Activate/Deactivate
- **Environment Variables**: JSON used to define environment variables (ENVs)
- **Excluded Namespaces**: List of namespaces that should not be optimized
- **Obfuscation**: Enables minification of namespaces using special characters
- **Interpreter Settings:**
- **Environment Variables**: JSON used to define environment variables (ENVs)
- **Silence Error Popups**: Silences error popups due to execution failure
- **Type Analyzer**
- **Strategy**: Specifies which files are used for type resolution. The "Dependency" strategy resolves types from all files imported into the current file. Alternatively, the "Workspace" strategy resolves types from all files within the workspace.
- **Exclude**: Specifies files to ignore based on matching glob patterns.## Features
- Syntax Highlighting
- [Transform](#transform)
- [Build](#build)
- [Interpreter](#interpreter)
- [Debugger](#debugger)
- [Comment Docs](#comment-docs)
- [Goto Error](#goto-error)
- [Providers](#supporting-providers)### Build
Transforms and bundles your files. It has three possible transformation types (Default, Uglify and Beautify) and supports environment variables as well.
#### Dependency Management (Transpiler)
This extension enables you to split your code into different files which is useful to keep readability and also to make reusable code.
Cyclic dependencies will be detected as well. In case there is one an error will be thrown indicating which file is causing it.
##### Import
Used to import exported namespaces from a file. Features of this import functionality:
- supports relative imports
- only loads code when required
- does not pollute global scope
- only gets imported once regardless of how many times it got imported
- only exports what you wantYou can take a look at the [example code](https://github.com/ayecue/miniscript-vs/blob/main/example/import) to get a better idea of how to use this feature.
##### Include
Used to import the content of a file. Features of this import functionality:
- supports relative includes
- very easy to use
- will pollute global scope
- will include the content of a file every time, which may cause redundant codeTo get a better idea you can take a look at the following [example code](https://github.com/ayecue/miniscript-vs/blob/main/example/include).
#### Environment Variables (Transpiler)
This extension supports the injection of environment variables while transpiling. The environment variables can be configured by using the extension settings.
Here is an [example](https://github.com/ayecue/miniscript-vs/blob/main/example/environment-variables) of environment variable injection.
#### Syntax
Keep in mind that the following syntax is not valid in MiniScript. The transpiler can be used to transform code into valid MiniScript.
##### No trailing comma is required in maps or lists
```
myList = [
false,
null
]myMap = {
"test": {
"level2": {
"bar": true
}
}
}
```##### Block comment
```
/*
My block comment
*/
print("test")
```### Transform
Transform is pretty much a simplified [build](#build). It will only transform the file at hand and ignore any imports.
### Interpreter
Executes MiniScript code. Supports all default MiniScript intrinsics. Also features a [debugger](#debugger).
![Start debug](https://github.com/ayecue/miniscript-vs/blob/main/assets/start-debug.png?raw=true "Start debug")
#### Dependency Management (Interpreter)
Dependencies will be dynamically loaded into the execution without any limitations. Cyclic dependencies are supported as well.
#### Environment Variables (Interpreter)
This extension supports the injection of environment variables while executing code. The environment variables can be configured by using the extension settings.
Here is an [example](https://github.com/ayecue/miniscript-vs/blob/main/example/environment-variables) of environment variable injection.
### Debugger
Enables you to set breakpoints, run code in a breakpoint context, jump to the next line of execution etc. Generally helpful if you want to debug your code.
![Breakpoint](https://github.com/ayecue/miniscript-vs/blob/main/assets/breakpoint.png?raw=true "Breakpoint")
Keep in mind to set the breakpoint on a non-empty line. Otherwise, it will just skip that breakpoint.
![Active breakpoint](https://github.com/ayecue/miniscript-vs/blob/main/assets/active-breakpoint.png?raw=true "Active breakpoint")
A REPL is also available while executing the script or having an active breakpoint.
![REPL](https://github.com/ayecue/miniscript-vs/blob/main/assets/repl.png?raw=true "REPL")
### Comment Docs
Provide signatures for your functions to show better hover tooltips. Additionally, the provided return value will be recognized by the implemented type system, resulting in context-sensitive auto-complete suggestions.
```js
// Hello world
// I am **bold**
// @description Alternative description
// @example test("title", 123)
// @param {string} title - The title of the book.
// @param {string|number} author - The author of the book.
// @return {crypto} - Some info about return
test = function(test, abc)
print(test)
end function
```
There is also the possibility of custom types. Here an example:
```js
// @type Bar
// @property {string} virtualMoo
// @property {string} nested.virtalMoo
Bar = {}
Bar.moo = ""// Hello world
// I am **bold**
// @description Alternative description
// @example test("title", 123)
// @param {string} title - The title of the book.
// @param {string|number} author - The author of the book.
// @return {Bar} - Some info about return
Bar.test = function(test, abc)
print("test")
return self
end function// @type Foo
Foo = new Bar
// @return {Foo}
Foo.New = function(message)
result = new Foo
return result
end functionmyVar = Foo.New
myVar.test // shows defined signature of Bar.test on hover
myVar.virtualMoo // shows virtual property of type string on hover
myVar.nested.virtalMoo // shows nested virtual property of type string on hover
```### Refresh
Will refresh the AST Cache which is used for diagnostics, hover tooltips and autocompletion.
### Goto Error
Jumps to the next existing syntax error.
### Supporting providers
This extension includes several IntelliSense providers to enhance your coding experience with GreyScript:
- **Autocompletion Provider**
Offers context-aware suggestions based on your current position in the code.- **Signature Helper Provider**
Displays function signatures with parameter types and return values as you type, helping you use functions correctly and efficiently without needing to reference documentation.- **Hover Tooltips Provider**
Displays helpful information about functions and types when you hover over them.- **Diagnostics Provider**
Identifies and highlights syntax errors in your code for easier debugging.- **Symbol Provider**
Lists all symbols available in the active file for easy navigation.
![Symbol](https://github.com/ayecue/miniscript-vs/blob/main/assets/symbols.png?raw=true "Symbol")- **Definition Provider**
Locates and displays definitions within the active file and its dependencies.
![Definition](https://github.com/ayecue/miniscript-vs/blob/main/assets/definition-provider.png?raw=true "Definition")- **Color Picker Provider**
Shows a color picker when you use color or mark tags in your code.