Sha256: cf1f1be271ed6214652dfeba03de8802a122093d51ebac1113b589096dddae22

Contents?: true

Size: 1.02 KB

Versions: 104

Compression:

Stored size: 1.02 KB

Contents

require "language_server-protocol"
require_relative "standardizer"
require_relative "routes"
require_relative "logger"

module Standard
  module Lsp
    Proto = LanguageServer::Protocol
    SEV = Proto::Constant::DiagnosticSeverity

    class Server
      def initialize(config)
        @writer = Proto::Transport::Io::Writer.new($stdout)
        @reader = Proto::Transport::Io::Reader.new($stdin)
        @logger = Logger.new
        @standardizer = Standard::Lsp::Standardizer.new(config, @logger)
        @routes = Routes.new(@writer, @logger, @standardizer)
      end

      def start
        @reader.read do |request|
          if !request.key?(:method)
            @routes.handle_method_missing(request)
          elsif (route = @routes.for(request[:method]))
            route.call(request)
          else
            @routes.handle_unsupported_method(request)
          end
        rescue => e
          @logger.puts "Error #{e.class} #{e.message[0..100]}"
          @logger.puts e.backtrace.inspect
        end
      end
    end
  end
end

Version data entries

104 entries across 104 versions & 3 rubygems

Version Path
standard-1.38.0 lib/standard/lsp/server.rb
standard-1.37.0 lib/standard/lsp/server.rb
harbr-2.8.1 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/lsp/server.rb
standard-1.35.0.1 lib/standard/lsp/server.rb
standard-1.34.0.1 lib/standard/lsp/server.rb
standard-1.35.1 lib/standard/lsp/server.rb
standard-1.35.0 lib/standard/lsp/server.rb
standard-1.34.0 lib/standard/lsp/server.rb
harbr-0.2.10 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/lsp/server.rb
harbr-0.2.9 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/lsp/server.rb
harbr-0.2.8 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/lsp/server.rb
harbr-0.2.7 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/lsp/server.rb
harbr-0.2.6 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/lsp/server.rb
harbr-0.2.5 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/lsp/server.rb
harbr-0.2.4 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/lsp/server.rb
harbr-0.2.3 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/lsp/server.rb
harbr-0.2.2 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/lsp/server.rb
harbr-0.2.1 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/lsp/server.rb
harbr-0.2.0 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/lsp/server.rb
harbr-0.1.99 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/lsp/server.rb