VSCode extension to format LPC (Lars Pensjö C) files with Prettier. It is written mainly for the LDMud flavor of LPC, but includes support for most FluffOS syntax as well.
This extension should still be considered an early release. It may break your code. Use at your own risk.
See CHANGELOG.md.
Install from the VS Code Marketplace: prettier-lpc-vscode
This plugin, like Prettier, is
opinionated. The plugin honors standard prettier config options which
can be set via a .prettierrc
file. In particular, the following
options may be of interest to LPC developers:
API Option | Description |
---|---|
printWidth |
Same option as in Prettier |
tabWidth |
Same option as in Prettier |
useTabs |
Same option as in Prettier |
pairVariables |
See Pair Arrays |
For arrays and functions, this plugin follow's prettier's multi-line objects rule. For tips on how to control whether objects are collapsed to a single line, or not, see: https://prettier.io/docs/en/rationale.html#multi-line-objects
In LDMud flavors of LPC there are often arrays that are treated as pairs. A common example of this is dest_dir
. For example:
dest_dir = ({
"room/pub", "west",
"room/street1", "east",
});
By default, this plugin is set to identify a list of common variable names for which arrays should be formatted in pair mode as shown above. This list can be customized (or set to an empty array to completely disable this feature) by using the pairVariables
setting.
An array can also be forced into pair mode by utilizing the @prettier-pair
hint:
// @prettier-pair
string *pairs = ({
"key 1", "value 1",
"key 2", "value 2",
});
The folowing languages features are not supported yet:
- Lambda parsing works, but is untested. Use extra caution.
- Union types
- Coroutines
- LWobjects
- Support for remaining language features/syntax
- Split AST parsing into separate package
- Split prettier plugin portion into separate package
- Add more options for customization
Also check out the LPC Language Services extension.