Sha256: 6f0d0e829f1b11fa462cdd72d80c1f65df433768e55eecc3b9f849f2de675ca0

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

require "language_server-protocol"

module Ruby
  module Lsp
    module Cli
      def self.start(_argv)
        writer = LanguageServer::Protocol::Transport::Stdio::Writer.new
        reader = LanguageServer::Protocol::Transport::Stdio::Reader.new

        subscribers = {
          initialize: -> {
            LanguageServer::Protocol::Interface::InitializeResult.new(
              capabilities: LanguageServer::Protocol::Interface::ServerCapabilities.new(
                text_document_sync: LanguageServer::Protocol::Interface::TextDocumentSyncOptions.new(
                  change: LanguageServer::Protocol::Constant::TextDocumentSyncKind::FULL
                ),
                completion_provider: LanguageServer::Protocol::Interface::CompletionOptions.new(
                  resolve_provider: true,
                  trigger_characters: %w(.)
                ),
                definition_provider: true
              )
            )
          }
        }

        reader.read do |request|
          result = subscribers[request[:method].to_sym].call
          writer.write(id: request[:id], result: result)
          exit
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby-lsp-0.0.1 lib/ruby/lsp/cli.rb