diff --git a/.vscode/settings.json b/.vscode/settings.json index a714a9a7d0..dfd935ea64 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -18,6 +18,21 @@ "editor.formatOnType": true, "editor.semanticHighlighting.enabled": true, }, + "sorbet.enabled": true, + "sorbet.lspConfigs": [ + { + "id": "default", + "name": "Brew Typecheck", + "description": "Default configuration", + "cwd": "${workspaceFolder}", + "command": [ + "./bin/brew", + "typecheck", + "--lsp", + ] + } + ], + "sorbet.selectedLspConfigId": "default", "shellcheck.customArgs": [ "--shell=bash", "--enable=all", diff --git a/Library/Homebrew/dev-cmd/typecheck.rb b/Library/Homebrew/dev-cmd/typecheck.rb index 4e6af62914..3d570a9c63 100644 --- a/Library/Homebrew/dev-cmd/typecheck.rb +++ b/Library/Homebrew/dev-cmd/typecheck.rb @@ -24,6 +24,8 @@ module Homebrew switch "--suggest-typed", depends_on: "--update", description: "Try upgrading `typed` sigils." + switch "--lsp", + description: "Start the Sorbet LSP server." flag "--dir=", description: "Typecheck all files in a specific directory." flag "--file=", @@ -33,6 +35,9 @@ module Homebrew "in their paths (relative to the input path passed to Sorbet)." conflicts "--dir", "--file" + conflicts "--lsp", "--update" + conflicts "--lsp", "--update-all" + conflicts "--lsp", "--fix" named_args :none end @@ -80,6 +85,15 @@ module Homebrew srb_exec << "--autocorrect" end + if args.lsp? + srb_exec << "--lsp" + if (watchman = which("watchman", ORIGINAL_PATHS)) + srb_exec << "--watchman-path" << watchman + else + srb_exec << "--disable-watchman" unless which("watchman", ORIGINAL_PATHS) + end + end + srb_exec += ["--ignore", args.ignore] if args.ignore.present? if args.file.present? || args.dir.present? cd("sorbet") do