From 80f20cc95c9798980ec4efed4b699824e20b94e9 Mon Sep 17 00:00:00 2001 From: Takumi Shotoku Date: Sat, 1 Nov 2025 23:42:21 +0900 Subject: [PATCH] Fix error by auto-detecting `analysis_unit_dirs` The LSP server requires `conf[:analysis_unit_dirs]` at server.rb:107, causing errors when the config field is missing. Auto-detect "app" and "lib" directories to populate this field in generated configs. --- lib/typeprof/cli/cli.rb | 10 +++++++++- lib/typeprof/cli/typeprof.conf.jsonc | 6 ------ 2 files changed, 9 insertions(+), 7 deletions(-) delete mode 100644 lib/typeprof/cli/typeprof.conf.jsonc diff --git a/lib/typeprof/cli/cli.rb b/lib/typeprof/cli/cli.rb index 336865c2b..88902d474 100644 --- a/lib/typeprof/cli/cli.rb +++ b/lib/typeprof/cli/cli.rb @@ -184,7 +184,15 @@ def set_profiler end def generate_config_file - File.write('typeprof.conf.jsonc', File.read(File.join(__dir__, 'typeprof.conf.jsonc')), mode: "wx") + exist_dirs = ["app", "lib"].select { |dir| File.exist?(File.join(Dir.pwd, dir)) } + File.write('typeprof.conf.jsonc', <<~JSONC, mode: "wx") + { + "typeprof_version": "experimental", + "rbs_dir": "sig/", + "analysis_unit_dirs": #{exist_dirs.inspect} + // "diagnostic_severity": "warning" + } + JSONC end end end diff --git a/lib/typeprof/cli/typeprof.conf.jsonc b/lib/typeprof/cli/typeprof.conf.jsonc deleted file mode 100644 index 39eaf0a1e..000000000 --- a/lib/typeprof/cli/typeprof.conf.jsonc +++ /dev/null @@ -1,6 +0,0 @@ -{ - "typeprof_version": "experimental", - "rbs_dir": "sig/" - // "analysis_unit_dirs": [], - // "diagnostic_severity": "warning" -}