# Setting up your editor

You can write patches in any text editor, but this is not recommended. PatchManager has a large API, and without help you will be guessing at field names. The **PatchManager Lua** extension for VSCode gives you autocomplete, inline documentation, and type checking for the entire lua modding API. Set it up once and the rest of these docs become a lot easier to follow.

## Install the extension


1. Install [VSCode](https://code.visualstudio.com/) if you do not have it.
2. To install the editor extension, either:

   
   1. Open <https://marketplace.visualstudio.com/items?itemName=infinity-sys.pm-lua> and click Install, or
   2. Open the Extensions panel and search for **PatchManager Lua** (publisher `infinity-sys`). Install it. It depends on the Lua language server extension (`sumneko.lua`) and will pull that in for you.
3. Open the folder where you write your patches as a VSCode workspace.

## Configure the workspace

When you open a folder that contains Lua files, the extension offers to configure it. Accept, or run the command yourself:


1. Open the command palette (`Ctrl+Shift+P`).
2. Run **PatchManager Lua: Configure Workspace**.

That command does two things:

* It drops the API stub files into `.pmlua/stubs/` in your workspace and adds `.pmlua/` to your `.gitignore`, so the generated stubs do not end up in your repository.
* It configures the Lua language server: the right Lua runtime version, the `|lambda|` syntax PatchManager scripts use, and the stubs folder as a library so everything resolves.

After that, open any `.lua` file and type `PM.` You should see the submodules (`Parts`, `Planets`, `Missions`, and so on) offered. Hover any method for its documentation.

## What the stubs give you

The stubs are LuaLS definition files, one per area of the API. You will see their names referenced throughout these docs:

| Stub | Covers |
|------|--------|
| `pm-builtin.d.lua` | `PM`, `J`, the `LuaPatch` chain, `ModId`, `Location` |
| `pm-jsondata.d.lua` | the JSON value you get in a `Do` callback and its methods |
| `pm-parts.d.lua` | `PM.Parts` and the part, module, and data forms |
| `pm-planets.d.lua` | `PM.Planets`, bodies, atmosphere and cloud overrides |
| `pm-resources.d.lua` | `PM.Resources`, resources and recipes |
| `pm-science.d.lua` | `PM.Science`, experiments, regions, discoverables, tech nodes |
| `pm-missions.d.lua` | `PM.Missions`, conditions, actions, stages |
| `pm-vswift.d.lua` | `PM.VSwift`, part variants |
| `pm-audio.d.lua` | `PM.Audio` |
| `pm-types.d.lua` | the enums (engine types, part categories, and so on) |

When a page here says "the full field list is in `pm-parts.d.lua`," it means: type a dot in your editor and read what autocomplete offers. The docs explain the common edits and the forms. The stubs are the exhaustive field-by-field reference, and they update with the API.

## Keeping the stubs current

The stubs ship bundled with the extension, and they are updated when the extension updates. To pull the very latest stubs without waiting for an extension release, run **PatchManager Lua: Update Stubs from Remote**. To go back to the bundled set, run **Reset to Bundled Stubs**.

With the editor set up, move on to [your first patch](/doc/your-first-patch-2TTZEeDRtk).