ruby-lsp 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyLsp
4
+ module Requests
5
+ autoload :BaseRequest, "ruby_lsp/requests/base_request"
6
+ autoload :DocumentSymbol, "ruby_lsp/requests/document_symbol"
7
+ autoload :FoldingRanges, "ruby_lsp/requests/folding_ranges"
8
+ autoload :SemanticHighlighting, "ruby_lsp/requests/semantic_highlighting"
9
+ autoload :RuboCopRequest, "ruby_lsp/requests/rubocop_request"
10
+ autoload :Formatting, "ruby_lsp/requests/formatting"
11
+ autoload :Diagnostics, "ruby_lsp/requests/diagnostics"
12
+ autoload :CodeActions, "ruby_lsp/requests/code_actions"
13
+ end
14
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "cgi"
4
+ require "uri"
5
+ require "ruby_lsp/document"
6
+
7
+ module RubyLsp
8
+ class Store
9
+ def initialize
10
+ @state = {}
11
+ end
12
+
13
+ def get(uri)
14
+ document = @state[uri]
15
+ return document unless document.nil?
16
+
17
+ set(uri, File.binread(CGI.unescape(URI.parse(uri).path)))
18
+ @state[uri]
19
+ end
20
+
21
+ def set(uri, content)
22
+ @state[uri] = Document.new(content)
23
+ rescue SyntaxTree::Parser::ParseError
24
+ # Do not update the store if there are syntax errors
25
+ end
26
+
27
+ def clear
28
+ @state.clear
29
+ end
30
+
31
+ def delete(uri)
32
+ @state.delete(uri)
33
+ end
34
+
35
+ def cache_fetch(uri, request_name, &block)
36
+ get(uri).cache_fetch(request_name, &block)
37
+ end
38
+ end
39
+ end
data/ruby-lsp.gemspec CHANGED
@@ -10,6 +10,7 @@ Gem::Specification.new do |s|
10
10
  s.summary = "A simple language server for ruby"
11
11
  s.description = "A simple language server for ruby"
12
12
  s.homepage = "https://github.com/Shopify/ruby-lsp"
13
+ s.license = "MIT"
13
14
 
14
15
  s.files = Dir.chdir(File.expand_path(__dir__)) do
15
16
  %x(git ls-files -z).split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
@@ -18,5 +19,7 @@ Gem::Specification.new do |s|
18
19
  s.executables = s.files.grep(/\Aexe/) { |f| File.basename(f) }
19
20
  s.require_paths = ["lib"]
20
21
 
21
- s.add_dependency "language_server-protocol"
22
+ s.add_dependency("language_server-protocol")
23
+ s.add_dependency("rubocop", ">= 1.0")
24
+ s.add_dependency("syntax_tree", ">= 2.3")
22
25
  end
File without changes
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-lsp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-03-01 00:00:00.000000000 Z
11
+ date: 2022-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: language_server-protocol
@@ -24,6 +24,34 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rubocop
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: syntax_tree
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '2.3'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '2.3'
27
55
  description: A simple language server for ruby
28
56
  email:
29
57
  - ruby@shopify.com
@@ -34,11 +62,14 @@ extra_rdoc_files: []
34
62
  files:
35
63
  - ".github/dependabot.yml"
36
64
  - ".github/probots.yml"
65
+ - ".github/pull_request_template.md"
66
+ - ".github/workflows/ci.yml"
37
67
  - ".gitignore"
38
68
  - ".rubocop.yml"
39
69
  - ".vscode/extensions.json"
40
- - ".vscode/launch.json"
70
+ - ".vscode/settings.json"
41
71
  - ".vscode/tasks.json"
72
+ - CHANGELOG.md
42
73
  - CODE_OF_CONDUCT.md
43
74
  - Gemfile
44
75
  - Gemfile.lock
@@ -46,20 +77,30 @@ files:
46
77
  - README.md
47
78
  - Rakefile
48
79
  - VERSION
49
- - bin/package_extension
50
80
  - bin/rubocop
51
- - bin/style
52
81
  - bin/test
53
82
  - dev.yml
54
83
  - exe/ruby-lsp
55
84
  - lib/ruby-lsp.rb
56
- - lib/ruby/lsp.rb
57
- - lib/ruby/lsp/cli.rb
85
+ - lib/ruby_lsp/cli.rb
86
+ - lib/ruby_lsp/document.rb
87
+ - lib/ruby_lsp/handler.rb
88
+ - lib/ruby_lsp/requests.rb
89
+ - lib/ruby_lsp/requests/base_request.rb
90
+ - lib/ruby_lsp/requests/code_actions.rb
91
+ - lib/ruby_lsp/requests/diagnostics.rb
92
+ - lib/ruby_lsp/requests/document_symbol.rb
93
+ - lib/ruby_lsp/requests/folding_ranges.rb
94
+ - lib/ruby_lsp/requests/formatting.rb
95
+ - lib/ruby_lsp/requests/rubocop_request.rb
96
+ - lib/ruby_lsp/requests/semantic_highlighting.rb
97
+ - lib/ruby_lsp/store.rb
58
98
  - ruby-lsp.gemspec
59
99
  - service.yml
60
- - shipit.yml
100
+ - shipit.production.yml
61
101
  homepage: https://github.com/Shopify/ruby-lsp
62
- licenses: []
102
+ licenses:
103
+ - MIT
63
104
  metadata:
64
105
  allowed_push_host: https://rubygems.org
65
106
  post_install_message:
data/.vscode/launch.json DELETED
@@ -1,19 +0,0 @@
1
- {
2
- // Use IntelliSense to learn about possible attributes.
3
- // Hover to view descriptions of existing attributes.
4
- // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
- "version": "0.2.0",
6
- "configurations": [
7
- {
8
- "name": "Minitest - current line",
9
- "type": "Ruby",
10
- "cwd": "${workspaceRoot}",
11
- "request": "launch",
12
- "program": "${workspaceRoot}/bin/rails",
13
- "args": [
14
- "test",
15
- "${file}:${lineNumber}"
16
- ]
17
- }
18
- ]
19
- }
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- cd features/vscode_extension || exit
4
- yarn run vscode:prepublish
5
- yarn run package -o ../.. # drop the extension in the main directory
data/bin/style DELETED
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- echo "Linting gem..."
4
- bin/rubocop
5
-
6
- echo
7
- echo "Linting extension..."
8
- cd features/vscode_extension || exit
9
- yarn run lint
10
- cd ../..
data/lib/ruby/lsp/cli.rb DELETED
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "language_server-protocol"
4
-
5
- module Ruby
6
- module Lsp
7
- module Cli
8
- def self.start(_argv)
9
- writer = LanguageServer::Protocol::Transport::Stdio::Writer.new
10
- reader = LanguageServer::Protocol::Transport::Stdio::Reader.new
11
-
12
- subscribers = {
13
- initialize: -> {
14
- LanguageServer::Protocol::Interface::InitializeResult.new(
15
- capabilities: LanguageServer::Protocol::Interface::ServerCapabilities.new(
16
- text_document_sync: LanguageServer::Protocol::Interface::TextDocumentSyncOptions.new(
17
- change: LanguageServer::Protocol::Constant::TextDocumentSyncKind::FULL
18
- ),
19
- completion_provider: LanguageServer::Protocol::Interface::CompletionOptions.new(
20
- resolve_provider: true,
21
- trigger_characters: %w(.)
22
- ),
23
- definition_provider: true
24
- )
25
- )
26
- }
27
- }
28
-
29
- reader.read do |request|
30
- result = subscribers[request[:method].to_sym].call
31
- writer.write(id: request[:id], result: result)
32
- exit
33
- end
34
- end
35
- end
36
- end
37
- end
data/lib/ruby/lsp.rb DELETED
@@ -1,3 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "lsp/cli"