server: resolve config from workspace folders, rootUri, and rootPath#1034
server: resolve config from workspace folders, rootUri, and rootPath#1034reteps wants to merge 2 commits intosbdchd:masterfrom
Conversation
Move ConfigFile parsing from squawk into squawk_linter so the LSP server can reuse it. Add LintConfig in squawk_server to bridge ConfigFile settings into linter settings. The server now falls back to rootUri and rootPath when workspace_folders is absent, so clients that only set rootUri (common outside multi-root workspaces) will correctly load .squawk.toml. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
👷 Deploy request for squawkhq pending review.Visit the deploys page to approve it
|
Glob patterns in .squawk.toml (e.g. migrations/*.sql) are relative, but the LSP was comparing them against the absolute URI path, so they never matched. Now also strips the workspace root to produce a relative path for matching. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
| pub(crate) struct Snapshot { | ||
| pub(crate) db: Database, | ||
| pub(crate) files: Arc<FxHashMap<Url, File>>, | ||
| pub(crate) config: Arc<LintConfig>, |
There was a problem hiding this comment.
I'm not 100% sure, but I think it might be better if we put the config in the Salsa database instead
And then we can more easily access without having to pass it around
Another thing I was thinking about is setting up the language server to watch for the config file changes, but that might be a lot of work
There was a problem hiding this comment.
I like this feature, the server has been without config for far too long 😄
| .and_then(|folders| folders.first()) | ||
| .and_then(|folder| folder.uri.to_file_path().ok()) | ||
| .or_else(|| { | ||
| #[allow(deprecated)] |
There was a problem hiding this comment.
is there a way to avoid the deprecated?
| let db = Database::default(); | ||
| let file = File::new(&db, sql.to_owned().into()); | ||
| lint(&db, file) | ||
| let config = crate::config::LintConfig::from_config_file(None, None); |
There was a problem hiding this comment.
I wonder if we can avoid the (None, None), seems non-ideal
| .flatten() | ||
| }); | ||
|
|
||
| let config = LintConfig::from_config_file(config_file, workspace_root); |
There was a problem hiding this comment.
maybe there's a way for us to avoid having to use workspace_root on line 99 to get config_file and then again pass it to this method
Summary
ConfigFileparsing fromsquawkCLI intosquawk_linterso the LSP server can reuse itLintConfiginsquawk_serverto bridge config file settings into linter settingsrootUrithenrootPathwhenworkspace_foldersis absent, so clients that only setrootUri(common outside multi-root workspaces) correctly load.squawk.tomlCloses #679
Test plan
./s/lintpasses./s/testpassessquawk_linter🤖 Generated with Claude Code