From 573bff937e51bc6ef31ac3082c7d3b903e3d6ce7 Mon Sep 17 00:00:00 2001 From: Amy Jeanes Date: Wed, 19 Aug 2026 10:55:02 +0100 Subject: [PATCH 1/2] feat(glua_doc_cli): add --gmod-annotations flag for parity with glua_check glua_doc_cli could previously only load the GMod annotations by listing them on workspace.library. That double-loads them (the LSP reads gmod.annotationsPath too) and orders them against a project's own .luatypes overrides. glua_check already sidesteps this with a --gmod-annotations flag that registers the directory as a library workspace directly, bypassing config. Mirror that flag here. Without it, a return inherited from a GMod global (e.g. a method returning Vector) resolves to `unknown` in the generated type model. The flag calls the same add_library_workspace + WorkspaceFolder(is_library=true) path the existing library loop uses, so output is identical for callers that still list the annotations as a library. Co-Authored-By: Claude Opus 4.8 (1M context) Claude-Session: https://claude.ai/code/session_018CzM9mxWHmgA5b5d926jBH --- crates/glua_doc_cli/src/cmd_args.rs | 4 ++++ crates/glua_doc_cli/src/init.rs | 19 +++++++++++++++++++ crates/glua_doc_cli/src/lib.rs | 1 + 3 files changed, 24 insertions(+) diff --git a/crates/glua_doc_cli/src/cmd_args.rs b/crates/glua_doc_cli/src/cmd_args.rs index d305364ef..43ca7b659 100644 --- a/crates/glua_doc_cli/src/cmd_args.rs +++ b/crates/glua_doc_cli/src/cmd_args.rs @@ -66,6 +66,10 @@ pub struct CmdArgs { /// Verbose output #[arg(long)] pub verbose: bool, + + /// Path to GMod annotations directory + #[arg(long)] + pub gmod_annotations: Option, } #[derive(Debug, Clone, Eq, PartialEq, ValueEnum)] diff --git a/crates/glua_doc_cli/src/init.rs b/crates/glua_doc_cli/src/init.rs index 2dc3b4b6b..77acea6b7 100644 --- a/crates/glua_doc_cli/src/init.rs +++ b/crates/glua_doc_cli/src/init.rs @@ -68,6 +68,7 @@ pub fn load_workspace( config_paths: Option>, exclude_pattern: Option>, include_pattern: Option>, + gmod_annotations: Option, ) -> Result> { let (config_files, config_root): (Vec, PathBuf) = if let Some(config_paths) = config_paths { @@ -94,6 +95,24 @@ pub fn load_workspace( .collect::>(); let mut analysis = EmmyLuaAnalysis::new(); + + // Add GMod annotations as library workspace if provided + if let Some(annotations_path) = gmod_annotations { + if annotations_path.exists() { + log::info!( + "Adding GMod annotations from: {}", + annotations_path.display() + ); + analysis.add_library_workspace(annotations_path.clone()); + workspace_folders.push(WorkspaceFolder::new(annotations_path, true)); + } else { + log::warn!( + "GMod annotations path does not exist: {}", + annotations_path.display() + ); + } + } + for lib in &emmyrc.workspace.library { let path = PathBuf::from(lib.get_path().clone()); workspace_folders.push(WorkspaceFolder::new(path.clone(), true)); diff --git a/crates/glua_doc_cli/src/lib.rs b/crates/glua_doc_cli/src/lib.rs index 6bfa3e901..9b1e1c88f 100644 --- a/crates/glua_doc_cli/src/lib.rs +++ b/crates/glua_doc_cli/src/lib.rs @@ -51,6 +51,7 @@ pub fn run_doc_cli(mut cmd_args: CmdArgs) -> Result<(), Box Date: Wed, 19 Aug 2026 16:01:31 +0100 Subject: [PATCH 2/2] refactor(glua_doc_cli): mirror glua_check's prioritize_gmod_annotations_library Address review: guard with is_dir() (rejecting a file path) and use the same prioritize_gmod_annotations_library helper glua_check uses, instead of registering the directory as a separate library workspace. That inserts the annotations at the front of workspace.library so the existing library loop picks them up, matching glua_check's mechanism exactly. Co-Authored-By: Claude Opus 4.8 (1M context) Claude-Session: https://claude.ai/code/session_018CzM9mxWHmgA5b5d926jBH --- crates/glua_doc_cli/src/init.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/crates/glua_doc_cli/src/init.rs b/crates/glua_doc_cli/src/init.rs index 77acea6b7..0f2efab05 100644 --- a/crates/glua_doc_cli/src/init.rs +++ b/crates/glua_doc_cli/src/init.rs @@ -89,30 +89,30 @@ pub fn load_workspace( config_root.display() ); emmyrc.pre_process_emmyrc(&config_root); - let mut workspace_folders = cmd_workspace_folders - .iter() - .map(|p| WorkspaceFolder::new(p.clone(), false)) - .collect::>(); - let mut analysis = EmmyLuaAnalysis::new(); - - // Add GMod annotations as library workspace if provided if let Some(annotations_path) = gmod_annotations { - if annotations_path.exists() { + if annotations_path.is_dir() { log::info!( "Adding GMod annotations from: {}", annotations_path.display() ); - analysis.add_library_workspace(annotations_path.clone()); - workspace_folders.push(WorkspaceFolder::new(annotations_path, true)); + emmyrc.prioritize_gmod_annotations_library( + annotations_path.to_string_lossy().into_owned(), + ); } else { log::warn!( - "GMod annotations path does not exist: {}", + "GMod annotations path is not an existing directory: {}", annotations_path.display() ); } } + let mut workspace_folders = cmd_workspace_folders + .iter() + .map(|p| WorkspaceFolder::new(p.clone(), false)) + .collect::>(); + + let mut analysis = EmmyLuaAnalysis::new(); for lib in &emmyrc.workspace.library { let path = PathBuf::from(lib.get_path().clone()); workspace_folders.push(WorkspaceFolder::new(path.clone(), true));