|
| 1 | +## Ladfiles |
| 2 | +BMS provides a custom Language Agnostic Declaration format (LAD), which can be used to integrate with other tooling. |
| 3 | + |
| 4 | +If you use `#[script_bindings]` macros, these files will magically contain your code comments, bindings as well as everything else required to drive other powerful integrations. |
| 5 | + |
| 6 | +The declaration file is generated from the type registry and serves as a light abstraction layer simplifying the traversal of all |
| 7 | +available types and globals as well as functions. |
| 8 | + |
| 9 | +You can customize how / where and if these files are stored using the main BMS plugin group: |
| 10 | +```rust,ignore |
| 11 | + app.add_plugins(BMSPlugin.set::<ScriptingFilesGenerationPlugin>( |
| 12 | + ScriptingFilesGenerationPlugin::new( |
| 13 | + true, // enabled, you can use a compilation feature to disable this here |
| 14 | + PathBuf::from("assets").join("definitions"), |
| 15 | + Some(PathBuf::from("bindings.lad.json")), // do also save the ladfile itself |
| 16 | + "Core BMS framework bindings", |
| 17 | + true, |
| 18 | + true, |
| 19 | + ), |
| 20 | + )); |
| 21 | +``` |
| 22 | + |
| 23 | +This plugin is only available when one of the sub features (like `lua_language_server_files`) mentioned in this chapter is enabled. |
| 24 | + |
| 25 | + |
| 26 | +You might not want to run this pipeline in your final binary, but rather bundle some of the generated files into some sort of development pack for modding. You can use compiler flags like `#[cfg(not(debug_assertions))]` to disable ladfile generation at runtime, or simply disable the lower level features within BMS to avoid compiling related dependencies too. |
| 27 | + |
| 28 | +## Lua Language Server |
| 29 | + |
| 30 | +<div class="Warning"> |
| 31 | + This feature is in early stages, the definitions provide 90% of the way there, but there are rough edges that will need to be worked out |
| 32 | +</div> |
| 33 | + |
| 34 | +[Luals](https://github.com/LuaLS/lua-language-server) or LLS, is an open source language server which integrates with many IDE's. |
| 35 | + |
| 36 | +It is powered by lua specific annotation or definition files which BMS can generate directly from its own LADfiles. |
| 37 | + |
| 38 | +To enable this simply enable the `lua_language_server_files` feature, and a `bindings.lua` definition file will be generated in the LADfile output directory in the `Startup` schedule. |
| 39 | + |
| 40 | +Script writers can then use this generated file by pointing their `.luarc.json` file to these definitions: |
| 41 | +```json |
| 42 | +{ |
| 43 | + "$schema": "https://raw.githubusercontent.com/LuaLS/vscode-lua/master/setting/schema.json", |
| 44 | + "workspace.library": [ |
| 45 | + "assets/definitions" |
| 46 | + ], |
| 47 | + "runtime.version": "Lua 5.4", |
| 48 | + "hint.enable": false, |
| 49 | +} |
| 50 | +``` |
| 51 | + |
0 commit comments