diff --git a/build.rs b/build.rs index 5ac7672b1..0cbd190fa 100644 --- a/build.rs +++ b/build.rs @@ -21,7 +21,7 @@ fn snapshot_from_fs_path(path: &Path) -> io::Result { // We can skip any TestEZ test files since they aren't necessary for // the plugin to run. - if file_name.ends_with(".spec.lua") { + if file_name.ends_with(".spec.lua") || file_name.ends_with(".spec.luau") { continue; } diff --git a/src/snapshot_middleware/dir.rs b/src/snapshot_middleware/dir.rs index 404b794de..46fff335f 100644 --- a/src/snapshot_middleware/dir.rs +++ b/src/snapshot_middleware/dir.rs @@ -82,8 +82,11 @@ pub fn snapshot_dir_no_meta( // middleware. Should we figure out a way for that function to add // relevant paths to this middleware? path.join("init.lua"), + path.join("init.luau"), path.join("init.server.lua"), + path.join("init.server.luau"), path.join("init.client.lua"), + path.join("init.client.luau"), ]; let snapshot = InstanceSnapshot::new() diff --git a/src/snapshot_middleware/lua.rs b/src/snapshot_middleware/lua.rs index 1b9117625..ba2216263 100644 --- a/src/snapshot_middleware/lua.rs +++ b/src/snapshot_middleware/lua.rs @@ -27,6 +27,12 @@ pub fn snapshot_lua( ("LocalScript", name) } else if let Some(name) = match_trailing(&file_name, ".lua") { ("ModuleScript", name) + } else if let Some(name) = match_trailing(&file_name, ".server.luau") { + ("Script", name) + } else if let Some(name) = match_trailing(&file_name, ".client.luau") { + ("LocalScript", name) + } else if let Some(name) = match_trailing(&file_name, ".luau") { + ("ModuleScript", name) } else { return Ok(None); }; diff --git a/src/snapshot_middleware/mod.rs b/src/snapshot_middleware/mod.rs index a8b348ee2..8d27d5bc5 100644 --- a/src/snapshot_middleware/mod.rs +++ b/src/snapshot_middleware/mod.rs @@ -57,16 +57,31 @@ pub fn snapshot_from_vfs( return snapshot_project(context, vfs, &project_path); } + let init_path = path.join("init.luau"); + if vfs.metadata(&init_path).with_not_found()?.is_some() { + return snapshot_lua_init(context, vfs, &init_path); + } + let init_path = path.join("init.lua"); if vfs.metadata(&init_path).with_not_found()?.is_some() { return snapshot_lua_init(context, vfs, &init_path); } + let init_path = path.join("init.server.luau"); + if vfs.metadata(&init_path).with_not_found()?.is_some() { + return snapshot_lua_init(context, vfs, &init_path); + } + let init_path = path.join("init.server.lua"); if vfs.metadata(&init_path).with_not_found()?.is_some() { return snapshot_lua_init(context, vfs, &init_path); } + let init_path = path.join("init.client.luau"); + if vfs.metadata(&init_path).with_not_found()?.is_some() { + return snapshot_lua_init(context, vfs, &init_path); + } + let init_path = path.join("init.client.lua"); if vfs.metadata(&init_path).with_not_found()?.is_some() { return snapshot_lua_init(context, vfs, &init_path); @@ -74,7 +89,11 @@ pub fn snapshot_from_vfs( snapshot_dir(context, vfs, path) } else { - if let Ok(name) = path.file_name_trim_end(".lua") { + let script_name = path + .file_name_trim_end(".lua") + .or_else(|_| path.file_name_trim_end(".luau")); + + if let Ok(name) = script_name { match name { // init scripts are handled elsewhere and should not turn into // their own children. diff --git a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__dir__test__empty_folder.snap b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__dir__test__empty_folder.snap index f24a53a84..246f9de7a 100644 --- a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__dir__test__empty_folder.snap +++ b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__dir__test__empty_folder.snap @@ -11,10 +11,14 @@ metadata: - /foo - /foo/init.meta.json - /foo/init.lua + - /foo/init.luau - /foo/init.server.lua + - /foo/init.server.luau - /foo/init.client.lua + - /foo/init.client.luau context: {} name: foo class_name: Folder properties: {} children: [] + diff --git a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__dir__test__folder_in_folder.snap b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__dir__test__folder_in_folder.snap index e9bd5b923..cd437643d 100644 --- a/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__dir__test__folder_in_folder.snap +++ b/src/snapshot_middleware/snapshots/librojo__snapshot_middleware__dir__test__folder_in_folder.snap @@ -11,8 +11,11 @@ metadata: - /foo - /foo/init.meta.json - /foo/init.lua + - /foo/init.luau - /foo/init.server.lua + - /foo/init.server.luau - /foo/init.client.lua + - /foo/init.client.luau context: {} name: foo class_name: Folder @@ -27,10 +30,14 @@ children: - /foo/Child - /foo/Child/init.meta.json - /foo/Child/init.lua + - /foo/Child/init.luau - /foo/Child/init.server.lua + - /foo/Child/init.server.luau - /foo/Child/init.client.lua + - /foo/Child/init.client.luau context: {} name: Child class_name: Folder properties: {} children: [] + diff --git a/src/web/api.rs b/src/web/api.rs index 93b1ccb0e..8f500116d 100644 --- a/src/web/api.rs +++ b/src/web/api.rs @@ -244,7 +244,7 @@ impl ApiService { } } -/// If this instance is represented by a script, try to find the correct .lua +/// If this instance is represented by a script, try to find the correct .lua or .luau /// file to open to edit it. fn pick_script_path(instance: InstanceWithMeta<'_>) -> Option { match instance.class_name() { @@ -252,16 +252,17 @@ fn pick_script_path(instance: InstanceWithMeta<'_>) -> Option { _ => return None, } - // Pick the first listed relevant path that has an extension of .lua that + // Pick the first listed relevant path that has an extension of .lua or .luau that // exists. instance .metadata() .relevant_paths .iter() .find(|path| { - // We should only ever open Lua files to be safe. + // We should only ever open Lua or Luau files to be safe. match path.extension().and_then(|ext| ext.to_str()) { Some("lua") => {} + Some("luau") => {} _ => return false, }