Class: Rigor::CLI::LspCommand
- Defined in:
- lib/rigor/cli/lsp_command.rb
Overview
Executes the rigor lsp command.
Starts a long-running LSP server over stdio (JSON-RPC). See docs/design/20260517-language-server.md for the
design.
Constant Summary collapse
- USAGE =
"Usage: rigor lsp [options]"
Instance Method Summary collapse
-
#run ⇒ Integer
CLI exit status.
Methods inherited from Command
Constructor Details
This class inherits a constructor from Rigor::CLI::Command
Instance Method Details
#run ⇒ Integer
Returns CLI exit status.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/rigor/cli/lsp_command.rb', line 19 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 # A long-lived server always outlasts the JIT compile cost, so enable # YJIT at boot rather than on the analysis deadline (Runtime::Jit). Runtime::Jit.enable_now 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 |