standard 1.24.0 → 1.24.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c0671d43dc2bb8c9d1337a61ea48651fa7bf9d47f3e9c427e27603d5eed9d462
4
- data.tar.gz: b98d3235ec3a617dfe3c6dbb57d827c6f4aff4670c53c5e4dccf92a003b79206
3
+ metadata.gz: 13d481f6982b619853ac364ffa223ddb6c010ea68cd57248c759786119f991a7
4
+ data.tar.gz: 3ee49b870ff3d1ffe12bca06c1d0c80ec41e815fe056f476b91f2bb766293196
5
5
  SHA512:
6
- metadata.gz: 465bf72a4d1585c54e93d290358a13e2a5b4e4890c428f41f08918bec2d6365367f41f8b7b3614765d4eb6a7557c9ef13823a845e86ce3f54f39e043027a93cf
7
- data.tar.gz: b9c98f70f328bdad82f563f8fa572f5ea18389bdebeb81b830b54c23197cedfb9918ee29d7a1dfe79b83b0e2ee7aa41798fd25bdeb68eb85ca28460cd2376fc3
6
+ metadata.gz: e1e0ad0ae158c7659b253f1062693f82cd1691babf12e65237521d005f9c4ce148b53e2905dfa1d1029082133e4852ef0f8c9a46e6917d6860342cf602c0fc64
7
+ data.tar.gz: 0d4ad3d30a9652e3536129f0f4733e5b7efb8ccefb699333e83f18a47e4259c2917b7f4507806aa79f4de15b0e7a73f5cf4961fafe86be88cb6c3c97a00a2d6f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.24.2
4
+
5
+ * _Further_ _further_ improve `--lsp` server to always respond to requests
6
+
7
+ ## 1.24.1
8
+
9
+ * _Further_ improve `--lsp` server to better support commands used by VS Code
10
+
3
11
  ## 1.24.0
4
12
 
5
13
  * Improve `--lsp` server to better support the commands used by VS Code
data/Gemfile CHANGED
@@ -9,7 +9,6 @@ gem "rake", "~> 13.0"
9
9
  gem "gimme"
10
10
  gem "m"
11
11
 
12
-
13
12
  if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.5")
14
13
  gem "simplecov"
15
14
  end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- standard (1.24.0)
4
+ standard (1.24.2)
5
5
  language_server-protocol (~> 3.17.0.2)
6
6
  rubocop (= 1.44.1)
7
7
  rubocop-performance (= 1.15.2)
@@ -21,7 +21,7 @@ GEM
21
21
  method_source (1.0.0)
22
22
  minitest (5.17.0)
23
23
  parallel (1.22.1)
24
- parser (3.2.0.0)
24
+ parser (3.2.1.0)
25
25
  ast (~> 2.4.1)
26
26
  pry (0.14.2)
27
27
  coderay (~> 1.1)
@@ -0,0 +1,10 @@
1
+ module Standard
2
+ module Lsp
3
+ class KillsServer
4
+ def call(&blk)
5
+ at_exit(&blk) unless blk.nil?
6
+ exit 0
7
+ end
8
+ end
9
+ end
10
+ end
@@ -1,3 +1,5 @@
1
+ require_relative "kills_server"
2
+
1
3
  module Standard
2
4
  module Lsp
3
5
  class Routes
@@ -7,6 +9,7 @@ module Standard
7
9
  @standardizer = standardizer
8
10
 
9
11
  @text_cache = {}
12
+ @kills_server = KillsServer.new
10
13
  end
11
14
 
12
15
  def self.handle(name, &block)
@@ -25,6 +28,7 @@ module Standard
25
28
  capabilities: Proto::Interface::ServerCapabilities.new(
26
29
  document_formatting_provider: true,
27
30
  diagnostic_provider: true,
31
+ execute_command_provider: true,
28
32
  text_document_sync: Proto::Interface::TextDocumentSyncOptions.new(
29
33
  change: Proto::Constant::TextDocumentSyncKind::FULL
30
34
  )
@@ -37,11 +41,11 @@ module Standard
37
41
  end
38
42
 
39
43
  handle "shutdown" do |request|
40
- @logger.puts "Client asked to shutdown Standard LSP server. Exiting..."
41
- at_exit {
44
+ @logger.puts "Client asked to shutdown Standard LSP server."
45
+ @kills_server.call do
42
46
  @writer.write(id: request[:id], result: nil)
43
- }
44
- exit 0
47
+ @logger.puts "Exiting..."
48
+ end
45
49
  end
46
50
 
47
51
  handle "textDocument/diagnostic" do |request|
@@ -71,16 +75,57 @@ module Standard
71
75
  @writer.write({id: request[:id], result: format_file(uri)})
72
76
  end
73
77
 
78
+ handle "workspace/didChangeWatchedFiles" do |request|
79
+ if request[:params][:changes].any? { |change| change[:uri].end_with?(".standard.yml") }
80
+ @logger.puts "Configuration file changed; restart required"
81
+ @kills_server.call
82
+ end
83
+ end
84
+
85
+ handle "workspace/executeCommand" do |request|
86
+ if request[:params][:command] == "standardRuby.formatAutoFixes"
87
+ uri = request[:params][:arguments][0][:uri]
88
+ @writer.write({
89
+ id: request[:id],
90
+ method: "workspace/applyEdit",
91
+ params: {
92
+ label: "Format with Standard Ruby auto-fixes",
93
+ edit: {
94
+ changes: {
95
+ uri => format_file(uri)
96
+ }
97
+ }
98
+ }
99
+ })
100
+ else
101
+ handle_unsupported_method(request, request[:params][:command])
102
+ end
103
+ end
104
+
74
105
  handle "textDocument/didSave" do |_request|
75
- # No-op
106
+ # Nothing to do
76
107
  end
77
108
 
78
109
  handle "$/cancelRequest" do |_request|
79
- # No-op
110
+ # Can't cancel anything because single-threaded
80
111
  end
81
112
 
82
113
  handle "$/setTrace" do |_request|
83
- # No-op
114
+ # No-op, we log everything
115
+ end
116
+
117
+ def handle_unsupported_method(request, method = request[:method])
118
+ @writer.write({id: request[:id], error: Proto::Interface::ResponseError.new(
119
+ code: Proto::Constant::ErrorCodes::METHOD_NOT_FOUND,
120
+ message: "Unsupported Method: #{method}"
121
+ )})
122
+ @logger.puts "Unsupported Method: #{method}"
123
+ end
124
+
125
+ def handle_method_missing(request)
126
+ if request.key?(:id)
127
+ @writer.write({id: request[:id], result: nil})
128
+ end
84
129
  end
85
130
 
86
131
  private
@@ -23,15 +23,12 @@ module Standard
23
23
 
24
24
  def start
25
25
  @reader.read do |request|
26
- method = request[:method]
27
- if (route = @routes.for(method))
26
+ if !request.key?(:method)
27
+ @routes.handle_method_missing(request)
28
+ elsif (route = @routes.for(request[:method]))
28
29
  route.call(request)
29
30
  else
30
- @writer.write({id: request[:id], error: Proto::Interface::ResponseError.new(
31
- code: Proto::Constant::ErrorCodes::METHOD_NOT_FOUND,
32
- message: "Unsupported Method: #{method}"
33
- )})
34
- @logger.puts "Unsupported Method: #{method}"
31
+ @routes.handle_unsupported_method(request)
35
32
  end
36
33
  rescue => e
37
34
  @logger.puts "Error #{e.class} #{e.message[0..100]}"
@@ -1,3 +1,3 @@
1
1
  module Standard
2
- VERSION = Gem::Version.new("1.24.0")
2
+ VERSION = Gem::Version.new("1.24.2")
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: standard
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.24.0
4
+ version: 1.24.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Searls
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-02-09 00:00:00.000000000 Z
11
+ date: 2023-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -102,6 +102,7 @@ files:
102
102
  - lib/standard/formatter.rb
103
103
  - lib/standard/loads_runner.rb
104
104
  - lib/standard/loads_yaml_config.rb
105
+ - lib/standard/lsp/kills_server.rb
105
106
  - lib/standard/lsp/logger.rb
106
107
  - lib/standard/lsp/routes.rb
107
108
  - lib/standard/lsp/server.rb