Class: Rigor::CLI::LspCommand
- Inherits:
-
Object
- Object
- Rigor::CLI::LspCommand
- Defined in:
- lib/rigor/cli/lsp_command.rb
Overview
Executes the ‘rigor lsp` command.
See ‘docs/design/20260517-language-server.md` for the design. Slice 1 (this commit) ships the CLI subcommand entry point. The actual stdio JSON-RPC reader / writer is queued for slice 2; invoking `rigor lsp` at slice 1 returns immediately after validating the transport flag.
Constant Summary collapse
- USAGE =
"Usage: rigor lsp [options]"
Instance Method Summary collapse
-
#initialize(argv:, out:, err:) ⇒ LspCommand
constructor
A new instance of LspCommand.
-
#run ⇒ Integer
CLI exit status.
Constructor Details
#initialize(argv:, out:, err:) ⇒ LspCommand
Returns a new instance of LspCommand.
17 18 19 20 21 |
# File 'lib/rigor/cli/lsp_command.rb', line 17 def initialize(argv:, out:, err:) @argv = argv @out = out @err = err end |
Instance Method Details
#run ⇒ Integer
Returns CLI exit status.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/rigor/cli/lsp_command.rb', line 24 def run = return CLI::EXIT_USAGE if == :usage_error transport = .fetch(:transport) unless transport == "stdio" @err.puts("rigor lsp: unsupported transport: #{transport.inspect} (only `stdio` is supported in v1)") return CLI::EXIT_USAGE end require_relative "../language_server" require_relative "../configuration" require "language_server-protocol" # STDIN is read frame-by-frame via the gem's `Io::Reader`; # STDOUT is wrapped in `SynchronizedWriter` so concurrent # writes from the main dispatch thread + the Debouncer's # async threads don't interleave frames. The Loop runs # until either STDIN hits EOF or `server.exited?`; the # process then exits with the server's recorded code # (0 after a clean shutdown+exit, 1 otherwise). writer = LanguageServer::SynchronizedWriter.new( ::LanguageServer::Protocol::Transport::Io::Writer.new($stdout) ) server, loop_runner = build_server(writer: writer, config_path: .fetch(:config)) loop_runner.run server.exit_code || 0 end |