Sha256: 40f789f2411f55c8524b9efd3e25cf4333422b59ef4676e45d7f4e0a4a030218

Contents?: true

Size: 1.04 KB

Versions: 9

Compression:

Stored size: 1.04 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)
        @routes = Routes.new(@writer, @logger, @standardizer)
      end

      def start
        RuboCop::LSP.enable
        @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

9 entries across 9 versions & 1 rubygems

Version Path
standard-1.42.1 lib/standard/lsp/server.rb
standard-1.42.0 lib/standard/lsp/server.rb
standard-1.41.1 lib/standard/lsp/server.rb
standard-1.41.0 lib/standard/lsp/server.rb
standard-1.40.1 lib/standard/lsp/server.rb
standard-1.40.0 lib/standard/lsp/server.rb
standard-1.39.2 lib/standard/lsp/server.rb
standard-1.39.1 lib/standard/lsp/server.rb
standard-1.39.0 lib/standard/lsp/server.rb