You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/tools/code-extension.mdx
+53-26Lines changed: 53 additions & 26 deletions
Original file line number
Diff line number
Diff line change
@@ -12,39 +12,66 @@ The Lingua Franca extension for Visual Studio Code (VS Code) provides syntax-dir
12
12
13
13
## Usage
14
14
15
-
### Creating a new file
15
+
### Creating a New Package
16
16
17
-
To create a new LF file, go to <kbd>File > New File...</kbd> and select `New Lingua Franca File`. When saving the file, save it in a directory called `src` to make sure that generated code is placed conveniently in an adjacent `src-gen` directory. For instance, for a file called `Foo.lf`, the directory structure after building should look something like this:
17
+
You can create a new LF package either manually by creating an LF file or by using the [Lingo Package Manager](https://github.com/lf-lang/lingo).
18
+
19
+
#### Option 1: Manually Create an LF File
20
+
1. Go to <kbd>File > New File...</kbd> and select `New Lingua Franca File`.
21
+
2. Save the file in a directory called `src` to ensure that generated code is placed in a parallel `src-gen` directory. For example, if your file is called `Foo.lf`, the directory structure after building will look like this:
18
22
19
23
```
20
-
bin/Foo
21
-
src/
22
-
└ Foo.lf
23
-
src-gen/Foo
24
+
├── LF Package
25
+
│ ├── bin/
26
+
│ │ └── Foo
27
+
│ ├── src/
28
+
│ │ └── Foo.lf
29
+
│ ├── src-gen/
30
+
│ │ ├── Foo/
31
+
...
24
32
```
25
33
26
-
:::note
27
-
We recommend selecting the root of your Lingua Franca package as your workspace in VS Code. This will enable the package explorer.
28
-
:::
34
+
Additionally, it's important to manually create the `Lingo.toml` file adjacent to the `src` folder in the root directory of the package.. This file serves as a configuration for the package, allowing you to specify the package name, version, and other metadata, including any dependencies you want to install.
35
+
36
+
#### Option 2: Create an LF Package Using the Lingo Package Manager
37
+
1. After installing and configuring the Lingo Package Manager, create an empty folder with the desired name for the LF package.
38
+
2. Open the folder in VS Code.
39
+
3. Open the terminal in this folder and run the <kbd>lingo init</kbd> command.
40
+
41
+
This will set up a new LF package with the following structure:
42
+
43
+
```
44
+
├── LF Package
45
+
│ ├── src/
46
+
│ │ └── Main.lf
47
+
└── └── Lingo.toml # Configuration file for current package
48
+
```
49
+
50
+
### Opening an Existing LF package
51
+
52
+
To open an existing LF package in VS Code, select the root directory of your Lingua Franca package as your workspace.
53
+
54
+
The correct structure of the LF package should look like this:
└── └── Lingo.toml # Configuration file for Lingo Package Manager
42
68
```
43
-
If the project structure deviates from the expected format, an error message will appear:
69
+
70
+
To correctly enable the [Package Explorer](#package-explorer), we recommend opening VS Code with the true root of your Lingua Franca package as your workspace. If the package structure deviates from the expected format, an error message will appear when opening the Package Explorer:
To show the diagram for the currently active Lingua Franca file, click on the diagrams icon at the upper right:
50
77
@@ -62,7 +89,7 @@ Running the code can also be done from the VS Code terminal by executing the gen
62
89
The **Lingua Franca Package Explorer** can be accessed by clicking on the **LF icon** in the activity bar on the left side of the screen. Once opened, the **Package Explorer** displays a **Tree View** with the following structure:
63
90
64
91
```
65
-
├── LF Project
92
+
├── LF Package
66
93
│ ├── Installed Packages
67
94
│ ├── Local Libraries
68
95
└── └── Source Files
@@ -74,9 +101,9 @@ The **Lingua Franca Package Explorer** can be accessed by clicking on the **LF i
74
101
75
102
-[**Source Files**](#source-files): Contains the LF source files created by the developer, located in the `src` directory.
76
103
77
-
The **Source Files** section is always present as it reflects the main LF files in the project. However, the **Installed Packages** and **Local Libraries** sections appear only if the respective directories and files exist in the workspace.
104
+
The **Source Files** section is always present as it reflects the main LF files in the package. However, the **Installed Packages** and **Local Libraries** sections appear only if the respective directories and files exist in the workspace.
78
105
79
-
Hovering over the **LF Project** item reveals a terminal icon. Clicking this icon opens a terminal window at the project's root directory, allowing you to execute commands directly within that directory.
106
+
Hovering over the **LF Package** item reveals a terminal icon. Clicking this icon opens a terminal window at the package's root directory, allowing you to execute commands directly within that directory.
80
107
81
108
#### Installed Packages
82
109
@@ -86,10 +113,10 @@ To install libraries:
86
113
1. Configure the `Lingo.toml` file with the desired libraries.
87
114
2. Run `lingo build` to download the specified dependencies.
88
115
89
-
Once the libraries are installed, they will appear in the `{project_name}/build/lfc_include/` directory. The **Installed Packages** section will then be structured as follows:
116
+
Once the libraries are installed, they will appear in the `{package_name}/build/lfc_include/` directory. The **Installed Packages** section will then be structured as follows:
90
117
91
118
```
92
-
├── LF Project
119
+
├── LF Package
93
120
│ ├── Installed Packages
94
121
│ │ ├── installed_library/
95
122
│ │ │ ├── File_1.lf
@@ -102,10 +129,10 @@ Once the libraries are installed, they will appear in the `{project_name}/build/
102
129
```
103
130
104
131
In this structure:
105
-
-**LF Project**: Represents the root folder of the main project.
132
+
-**LF Package**: Represents the root folder of the main package.
106
133
-**installed_library**: Represents each library listed in `Lingo.toml`, which contains one or more LF programs featuring reusable reactors.
107
134
108
-
The image below shows a visual representation of the **Installed Packages** section. The **project** icon indicates the LF Project folder (e.g., `AudioClassification`), while the **root-folder** icon represents the downloaded libraries (e.g., the `edgeai` library in the example). The **code file** icon denotes an LF program within a library, and the **bracket** icon represents individual reactors inside the LF program.
135
+
The image below shows a visual representation of the **Installed Packages** section. The **project** icon indicates the LF Package folder (e.g., `AudioClassification`), while the **root-folder** icon represents the downloaded libraries (e.g., the `edgeai` library in the example). The **code file** icon denotes an LF program within a library, and the **bracket** icon represents individual reactors inside the LF program.
@@ -132,10 +159,10 @@ The **Import Selected Reactor** option is available only if an LF program is ope
132
159
133
160
#### Local Libraries
134
161
135
-
The **Local Libraries** section lists LF programs created by the developer, located in the `{project_name}/src/lib/` directory. These programs serve as local libraries, containing reusable reactors. The directory structure follows this format:
162
+
The **Local Libraries** section lists LF programs created by the developer, located in the `{package_name}/src/lib/` directory. These programs serve as local libraries, containing reusable reactors. The directory structure follows this format:
136
163
137
164
```
138
-
├── LF Project
165
+
├── LF Package
139
166
...
140
167
│ ├── Local Libraries
141
168
│ │ ├── File_1.lf
@@ -147,7 +174,7 @@ The **Local Libraries** section lists LF programs created by the developer, loca
147
174
...
148
175
```
149
176
150
-
The image below illustrates the **Local Libraries** section. In this depiction, the **"project"** icon represents the LF project folder, while the **"code file"** icon represents the LF program, and the **"bracket"** icon denotes individual reactors within the LF program.
177
+
The image below illustrates the **Local Libraries** section. In this depiction, the **"project"** icon represents the LF package folder, while the **"code file"** icon represents the LF program, and the **"bracket"** icon denotes individual reactors within the LF program.
@@ -173,10 +200,10 @@ The **Import Selected Reactor** option is available only if an LF program is ope
173
200
174
201
#### Source Files
175
202
176
-
The **Source Files** section lists all LF programs in the `{project_name}/src/` directory. This section provides direct access to the main source files of the project. The hierarchy for this view is straightforward:
203
+
The **Source Files** section lists all LF programs in the `{package_name}/src/` directory. This section provides direct access to the main source files of the package. The hierarchy for this view is straightforward:
177
204
178
205
```
179
-
├── LF Project
206
+
├── LF Package
180
207
...
181
208
│ ├── Local Libraries
182
209
│ │ ├── File_1.lf
@@ -185,7 +212,7 @@ The **Source Files** section lists all LF programs in the `{project_name}/src/`
185
212
...
186
213
```
187
214
188
-
Clicking on any of the files will open the corresponding LF program in the editor, allowing developers to quickly navigate to and edit the source code of their project.
215
+
Clicking on any of the files will open the corresponding LF program in the editor, allowing developers to quickly navigate to and edit the source code of their package.
0 commit comments