LPC Language ServicesLanguage server and VSCode extension that provides rich language support for LPC (Lars Pensjö C) - an object-oriented programming language derived from C and developed originally by Lars Pensjö to facilitate MUD building on LPMuds. Currently supports LDMud and FluffOS. Install from the VS Code Marketplace: https://marketplace.visualstudio.com/items?itemName=jlchmura.lpc Features
Doc CommentsLPC Language Services uses JSDoc-style comments to provide additional context during hover and signature help. Example:
If you love this extension, you couldChangelogSee CHANGELOG.md. Setting up your workspaceThe VS Code LPC Language Services extension does not use your MUD driver to compile code. As such, several configuration options are available to help the language server understand the structure of your mudlib. Workspace Root vs Lib RootLPC Language Services will use the location of your For example, see the LIMA mudlib in which the config file should be placed in the Please note: After creating (or moving) your ExampleFor an example mudlib, pre-configured to work with LPC Language Services, see this slightly modified version of the LP 2.4.5 mudlib. LPC Language Services can parse and validate this entire lib without errors. LPC ConfigLanguage services can be customized by creating an Driver Options -
|
Setting | Description |
---|---|
type |
Driver type. Valid options are ldmud or fluffos . |
version |
The driver version string, i.e. "3.6.7" |
File Locations - files
Setting | Description |
---|---|
master |
The location of your master object. Defaults to "/obj/master.c" |
simul_efun |
The location of your simul_efun file. Defaults to "/obj/simul_efun.c" |
init_files |
An array of init files. Defaults to ["/room/init_files"] |
global_include |
When provided, will add this file as an #include to each file. |
player |
The location of your player file. Defaults to "/obj/player.c" |
Include Dirs - include
An array of folders that are searched when including files via the #include
directive.
Defaults to ["/sys", "/obj", "/room"]
Exclude Dirs - exclude
An array of glob patterns of directories and files that are excluded from language services. Excluded files will not report errors unless specifically opened in VS Code.
Predefined Macros - defines
Since your code is not being evaluating in the mud driver, you may need to simulate one or more defines that are normally provided by the driver's compiler. Values are an array of key value pairs. Example:
"defines": [
{ "__HOST_NAME__": "\"localhost\"" },
{ "TLS_PORT": "5555" }
]
In the example above, __HOST_NAME__
will be defined as the string value "localhost"
. TLS_PORT
on the other hand, will be defined as an int value 5555
.
Diagnostics - diagnostics
The severity level of several diagnostics can be controlled through this configuration option. When a LPC language services reports a diagnostic, the code is printed at the end the message and enclosed in lpc()
, i.e. lpc(functionNotFound)
.
For example, to turn off the functionNotFound
error completely:
"diagnostics": {
"functionNotFound": "none"
}
Valid severity levels are:
error
warning
info
hint
none
Disabling Code Diagnostics
All semantic diagnostics can be disabled by setting the config to "off"
. Syntax errors will always be reported. Example:
"diagnostics": "off"
Grammar ToDo's
Language services is a work in progress. Some major areas that have yet to be implemented are:
- LWObjects
- Named object validation
- Coroutines
- Complete FluffOS specific syntax parsing
Credits
Syntax highlighting is based on the LPC Language VS Code extension by Gwenn Reece, adjusted for LDMud.
Original inspiration for the structure of this project came from Mike Lischke's ANTLR4 grammar syntax support. This language server would not have been possible without Mike's work on the ANTLR4-ng package.
Many thanks for the fellow MUD admins, wizards, and LPC aficionados in the LPC Discord for their inspiration.
Contact / Feature Requests / Bugs
Feedback welcome. You can open an issue in the lpc-language-server repo. Otherwise, you can usually find me on the LPC Discord or idling on Infinity Mud.