standard 1.24.0 → 1.24.1

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: 69342b56c2cb5d98f491d5c02cb7d787c667954fe4422654ddc434d0f34384b4
4
+ data.tar.gz: 7945846b4e2a92e4543752ccd7034a8ce5e441d126f5604d72333cd3b2ec1966
5
5
  SHA512:
6
- metadata.gz: 465bf72a4d1585c54e93d290358a13e2a5b4e4890c428f41f08918bec2d6365367f41f8b7b3614765d4eb6a7557c9ef13823a845e86ce3f54f39e043027a93cf
7
- data.tar.gz: b9c98f70f328bdad82f563f8fa572f5ea18389bdebeb81b830b54c23197cedfb9918ee29d7a1dfe79b83b0e2ee7aa41798fd25bdeb68eb85ca28460cd2376fc3
6
+ metadata.gz: 49e59dc51822c205910db0f1dc318e26012875ae727c00d1f358779b7292799e1d6ce4df36d321fd4a1633471afc86a218697bfd9dc7b00b73e62efc2bdbe7c8
7
+ data.tar.gz: 29dfd9bb60acb15d038be99e338e6376894237e8fe1fac78915b9c8f76040a17e6b3fcd7f14a072b9c6e712f256e8ef51445099993604a57c3b14d9675bb4285
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.24.1
4
+
5
+ * _Further_ improve `--lsp` server to better support commands used by VS Code
6
+
3
7
  ## 1.24.0
4
8
 
5
9
  * 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.1)
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,51 @@ 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}"
84
123
  end
85
124
 
86
125
  private
@@ -23,15 +23,13 @@ module Standard
23
23
 
24
24
  def start
25
25
  @reader.read do |request|
26
+ next unless request.key?(:method) # ignore responses without methods
27
+
26
28
  method = request[:method]
27
29
  if (route = @routes.for(method))
28
30
  route.call(request)
29
31
  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}"
32
+ @routes.handle_unsupported_method(request)
35
33
  end
36
34
  rescue => e
37
35
  @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.1")
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.1
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