ruby-lsp 0.0.1 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +7 -16
- data/.github/pull_request_template.md +15 -0
- data/.github/workflows/ci.yml +31 -0
- data/.github/workflows/publish_docs.yml +32 -0
- data/.gitignore +9 -12
- data/.rubocop.yml +20 -2
- data/.vscode/settings.json +5 -0
- data/CHANGELOG.md +29 -0
- data/Gemfile +8 -4
- data/Gemfile.lock +76 -14
- data/README.md +69 -2
- data/Rakefile +5 -0
- data/VERSION +1 -1
- data/bin/tapioca +29 -0
- data/bin/test +7 -1
- data/dev.yml +7 -7
- data/exe/ruby-lsp +19 -2
- data/lib/internal.rb +7 -0
- data/lib/ruby-lsp.rb +4 -1
- data/lib/ruby_lsp/cli.rb +88 -0
- data/lib/ruby_lsp/document.rb +113 -0
- data/lib/ruby_lsp/handler.rb +236 -0
- data/lib/ruby_lsp/requests/base_request.rb +33 -0
- data/lib/ruby_lsp/requests/code_actions.rb +37 -0
- data/lib/ruby_lsp/requests/diagnostics.rb +37 -0
- data/lib/ruby_lsp/requests/document_highlight.rb +96 -0
- data/lib/ruby_lsp/requests/document_symbol.rb +216 -0
- data/lib/ruby_lsp/requests/folding_ranges.rb +213 -0
- data/lib/ruby_lsp/requests/formatting.rb +52 -0
- data/lib/ruby_lsp/requests/rubocop_request.rb +50 -0
- data/lib/ruby_lsp/requests/selection_ranges.rb +103 -0
- data/lib/ruby_lsp/requests/semantic_highlighting.rb +112 -0
- data/lib/ruby_lsp/requests/support/rubocop_diagnostic.rb +88 -0
- data/lib/ruby_lsp/requests/support/selection_range.rb +17 -0
- data/lib/ruby_lsp/requests/support/semantic_token_encoder.rb +60 -0
- data/lib/ruby_lsp/requests/support/syntax_error_diagnostic.rb +27 -0
- data/lib/ruby_lsp/requests.rb +24 -0
- data/lib/ruby_lsp/store.rb +59 -0
- data/rakelib/check_docs.rake +56 -0
- data/ruby-lsp.gemspec +5 -1
- data/{shipit.yml → shipit.production.yml} +0 -0
- data/sorbet/config +4 -0
- data/sorbet/rbi/.rubocop.yml +8 -0
- data/sorbet/rbi/gems/ansi@1.5.0.rbi +338 -0
- data/sorbet/rbi/gems/ast@2.4.2.rbi +522 -0
- data/sorbet/rbi/gems/builder@3.2.4.rbi +418 -0
- data/sorbet/rbi/gems/coderay@1.1.3.rbi +8 -0
- data/sorbet/rbi/gems/debug@1.5.0.rbi +1273 -0
- data/sorbet/rbi/gems/diff-lcs@1.5.0.rbi +867 -0
- data/sorbet/rbi/gems/io-console@0.5.11.rbi +8 -0
- data/sorbet/rbi/gems/irb@1.4.1.rbi +376 -0
- data/sorbet/rbi/gems/language_server-protocol@3.16.0.3.rbi +7325 -0
- data/sorbet/rbi/gems/method_source@1.0.0.rbi +8 -0
- data/sorbet/rbi/gems/minitest-reporters@1.5.0.rbi +612 -0
- data/sorbet/rbi/gems/minitest@5.15.0.rbi +994 -0
- data/sorbet/rbi/gems/parallel@1.22.1.rbi +163 -0
- data/sorbet/rbi/gems/parser@3.1.2.0.rbi +3968 -0
- data/sorbet/rbi/gems/prettier_print@0.1.0.rbi +734 -0
- data/sorbet/rbi/gems/pry@0.14.1.rbi +8 -0
- data/sorbet/rbi/gems/rainbow@3.1.1.rbi +227 -0
- data/sorbet/rbi/gems/rake@13.0.6.rbi +1853 -0
- data/sorbet/rbi/gems/rbi@0.0.14.rbi +2337 -0
- data/sorbet/rbi/gems/regexp_parser@2.5.0.rbi +1854 -0
- data/sorbet/rbi/gems/reline@0.3.1.rbi +1274 -0
- data/sorbet/rbi/gems/rexml@3.2.5.rbi +3852 -0
- data/sorbet/rbi/gems/rubocop-ast@1.18.0.rbi +4180 -0
- data/sorbet/rbi/gems/rubocop-minitest@0.20.0.rbi +1369 -0
- data/sorbet/rbi/gems/rubocop-rake@0.6.0.rbi +246 -0
- data/sorbet/rbi/gems/rubocop-shopify@2.6.0.rbi +8 -0
- data/sorbet/rbi/gems/rubocop-sorbet@0.6.8.rbi +652 -0
- data/sorbet/rbi/gems/rubocop@1.30.0.rbi +36729 -0
- data/sorbet/rbi/gems/ruby-progressbar@1.11.0.rbi +732 -0
- data/sorbet/rbi/gems/spoom@1.1.11.rbi +1600 -0
- data/sorbet/rbi/gems/syntax_tree@2.7.1.rbi +6777 -0
- data/sorbet/rbi/gems/tapioca@0.8.1.rbi +1972 -0
- data/sorbet/rbi/gems/thor@1.2.1.rbi +2921 -0
- data/sorbet/rbi/gems/unicode-display_width@2.1.0.rbi +27 -0
- data/sorbet/rbi/gems/unparser@0.6.5.rbi +2789 -0
- data/sorbet/rbi/gems/webrick@1.7.0.rbi +1779 -0
- data/sorbet/rbi/gems/yard-sorbet@0.6.1.rbi +289 -0
- data/sorbet/rbi/gems/yard@0.9.27.rbi +13048 -0
- data/sorbet/rbi/shims/fiddle.rbi +4 -0
- data/sorbet/rbi/shims/hash.rbi +6 -0
- data/sorbet/rbi/shims/rdoc.rbi +4 -0
- data/sorbet/tapioca/config.yml +13 -0
- data/sorbet/tapioca/require.rb +7 -0
- metadata +119 -9
- data/.vscode/launch.json +0 -19
- data/bin/package_extension +0 -5
- data/bin/style +0 -10
- data/lib/ruby/lsp/cli.rb +0 -37
- data/lib/ruby/lsp.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab0e94532c080cf6e443c95d9ca7ccb16f548ec45768dc58e95fd691c907a965
|
4
|
+
data.tar.gz: 856df7b413ef111e100ee42da541856843d966184f9dbe1dfe2ee5a50da1e802
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fde4cd9c5e556ff926b22d316d1bfcc5d31c089850d4558ac7d954fe33df4c8d2b8f8c14e55d1dcc2898087d0d29e8b12fc2f768e2b14935fa727f9620ff5c9e
|
7
|
+
data.tar.gz: 24fb12213f36edcee13fe65d53a94977737b251566d2503dc857dc276192d6f570f93147f57fc5e3b23c8d90b2c1f96f4cc7e308d5b969a02705d39444676f95
|
data/.github/dependabot.yml
CHANGED
@@ -1,20 +1,11 @@
|
|
1
1
|
version: 2
|
2
|
-
registries:
|
3
|
-
rubygems-server-pkgs-shopify-io:
|
4
|
-
type: rubygems-server
|
5
|
-
url: https://pkgs.shopify.io
|
6
|
-
username: ${{secrets.RUBYGEMS_SERVER_PKGS_SHOPIFY_IO_USERNAME}}
|
7
|
-
password: ${{secrets.RUBYGEMS_SERVER_PKGS_SHOPIFY_IO_PASSWORD}}
|
8
|
-
github-com:
|
9
|
-
type: git
|
10
|
-
url: https://github.com
|
11
|
-
username: ${{secrets.DEPENDENCIES_GITHUB_USER}}
|
12
|
-
password: ${{secrets.DEPENDENCIES_GITHUB_TOKEN}}
|
13
2
|
updates:
|
14
|
-
- package-ecosystem: bundler
|
3
|
+
- package-ecosystem: "bundler"
|
15
4
|
directory: "/"
|
16
5
|
schedule:
|
17
|
-
interval:
|
18
|
-
|
19
|
-
|
20
|
-
|
6
|
+
interval: "weekly"
|
7
|
+
reviewers:
|
8
|
+
- "Shopify/sorbet"
|
9
|
+
labels:
|
10
|
+
- "dependencies"
|
11
|
+
- "ruby"
|
@@ -0,0 +1,15 @@
|
|
1
|
+
### Motivation
|
2
|
+
|
3
|
+
<!-- Explain why you are making this change. Include links to issues or describe the problem being solved, not the solution. -->
|
4
|
+
|
5
|
+
### Implementation
|
6
|
+
|
7
|
+
<!-- How did you implement your changes? Explain your solution, design decisions, things reviewers should watch out for. -->
|
8
|
+
|
9
|
+
### Automated Tests
|
10
|
+
|
11
|
+
<!-- We hope you added unit tests as part of your changes, just state that you have. If you haven't, state why. -->
|
12
|
+
|
13
|
+
### Manual Tests
|
14
|
+
|
15
|
+
<!-- Explain how we can test these changes in our own instance of VS Code. Provide the step by step instructions. -->
|
@@ -0,0 +1,31 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
strategy:
|
9
|
+
fail-fast: false
|
10
|
+
matrix:
|
11
|
+
ruby: [ "2.7", "3.0", "3.1" ]
|
12
|
+
name: Ruby ${{ matrix.ruby }}
|
13
|
+
steps:
|
14
|
+
- uses: actions/checkout@v2
|
15
|
+
- name: Set up Ruby
|
16
|
+
uses: ruby/setup-ruby@v1
|
17
|
+
with:
|
18
|
+
ruby-version: ${{ matrix.ruby }}
|
19
|
+
bundler-cache: true
|
20
|
+
|
21
|
+
- name: Check if documentation is up to date
|
22
|
+
run: bundle exec rake check_docs
|
23
|
+
|
24
|
+
- name: Typecheck
|
25
|
+
run: bundle exec srb tc
|
26
|
+
|
27
|
+
- name: Lint Ruby files
|
28
|
+
run: bin/rubocop
|
29
|
+
|
30
|
+
- name: Run tests
|
31
|
+
run: bin/test
|
@@ -0,0 +1,32 @@
|
|
1
|
+
name: Publish docs
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [main]
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
build:
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
name: Publish documentation website
|
11
|
+
steps:
|
12
|
+
- uses: actions/checkout@v3
|
13
|
+
|
14
|
+
- name: Set up Ruby
|
15
|
+
uses: ruby/setup-ruby@v1
|
16
|
+
with:
|
17
|
+
ruby-version: 3.1.1
|
18
|
+
bundler-cache: true
|
19
|
+
|
20
|
+
- name: Configure git
|
21
|
+
run: |
|
22
|
+
git config user.name github-actions
|
23
|
+
git config user.email github-actions@github.com
|
24
|
+
|
25
|
+
- name: Generate documentation
|
26
|
+
run: bundle exec rake yard
|
27
|
+
|
28
|
+
- name: Commit to gh-pages
|
29
|
+
run: |
|
30
|
+
git add docs
|
31
|
+
git commit -m "Publish website $(git log --format=format:%h -1)"
|
32
|
+
git push --force origin main:gh-pages
|
data/.gitignore
CHANGED
@@ -1,12 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
/**/node_modules/
|
11
|
-
/**/out/
|
12
|
-
/**/*.vsix
|
1
|
+
/**/.bundle/
|
2
|
+
/**/.yardoc
|
3
|
+
/**/_yardoc/
|
4
|
+
/**/coverage/
|
5
|
+
/**/doc/
|
6
|
+
/**/pkg/
|
7
|
+
/**/spec/reports/
|
8
|
+
/**/tmp/
|
9
|
+
/**/.dev/
|
data/.rubocop.yml
CHANGED
@@ -1,12 +1,30 @@
|
|
1
1
|
inherit_gem:
|
2
2
|
rubocop-shopify: rubocop.yml
|
3
3
|
|
4
|
+
require:
|
5
|
+
- rubocop-sorbet
|
6
|
+
- rubocop-minitest
|
7
|
+
- rubocop-rake
|
8
|
+
|
4
9
|
AllCops:
|
5
|
-
|
10
|
+
NewCops: disable
|
11
|
+
SuggestExtensions: false
|
12
|
+
TargetRubyVersion: 2.7
|
6
13
|
Exclude:
|
7
14
|
- "vendor/**/*"
|
8
15
|
- "features/**/*"
|
16
|
+
- "test/fixtures/**/*"
|
9
17
|
|
10
18
|
Naming/FileName:
|
11
19
|
Exclude:
|
12
|
-
- "lib/ruby-lsp.rb"
|
20
|
+
- "lib/ruby-lsp.rb"
|
21
|
+
|
22
|
+
Sorbet/FalseSigil:
|
23
|
+
Enabled: false
|
24
|
+
|
25
|
+
Sorbet/TrueSigil:
|
26
|
+
Enabled: true
|
27
|
+
Include:
|
28
|
+
- "**/*.rb"
|
29
|
+
Exclude:
|
30
|
+
- "**/*.rake"
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Change Log
|
2
|
+
|
3
|
+
All notable changes to the "ruby-lsp" extension will be documented in this file.
|
4
|
+
|
5
|
+
Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
|
6
|
+
|
7
|
+
## [Unreleased]
|
8
|
+
|
9
|
+
## [0.0.4]
|
10
|
+
|
11
|
+
- Add basic document highlight (https://github.com/Shopify/ruby-lsp/pull/91)
|
12
|
+
- Add error telemetry (https://github.com/Shopify/ruby-lsp/pull/100)
|
13
|
+
- Always push telemetry events from the server (https://github.com/Shopify/ruby-lsp/pull/109)
|
14
|
+
- Fix multibyte character handling (https://github.com/Shopify/ruby-lsp/pull/122)
|
15
|
+
- Add Sorbet to the Ruby LSP (https://github.com/Shopify/ruby-lsp/pull/119, https://github.com/Shopify/ruby-lsp/pull/123)
|
16
|
+
|
17
|
+
## [0.0.3]
|
18
|
+
|
19
|
+
- Fixed code actions return hanging
|
20
|
+
- Moved to incremental text synchronization
|
21
|
+
- Added syntax error resiliency
|
22
|
+
|
23
|
+
## [0.0.2]
|
24
|
+
|
25
|
+
- Alpha release including
|
26
|
+
- RuboCop formatting, diagnostics and quick fixes
|
27
|
+
- Folding ranges
|
28
|
+
- Initial semantic highlighting
|
29
|
+
- Document symbols
|
data/Gemfile
CHANGED
@@ -4,10 +4,14 @@ source "https://rubygems.org"
|
|
4
4
|
|
5
5
|
gemspec
|
6
6
|
|
7
|
+
gem "debug", "~> 1.5", require: false
|
7
8
|
gem "minitest", "~> 5.15"
|
8
9
|
gem "minitest-reporters", "~> 1.5"
|
9
10
|
gem "rake", "~> 13.0"
|
10
|
-
gem "rubocop", "~>
|
11
|
-
gem "rubocop-
|
12
|
-
gem "rubocop-
|
13
|
-
gem "rubocop-
|
11
|
+
gem "rubocop-shopify", "~> 2.7", require: false
|
12
|
+
gem "rubocop-minitest", "~> 0.20.0", require: false
|
13
|
+
gem "rubocop-rake", "~> 0.6.0", require: false
|
14
|
+
gem "rubocop-sorbet", "~> 0.6", require: false
|
15
|
+
gem "sorbet-static-and-runtime"
|
16
|
+
gem "tapioca", "~> 0.8", require: false
|
17
|
+
gem "yard", "~> 0.9", require: false
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ruby-lsp (0.0.
|
4
|
+
ruby-lsp (0.0.4)
|
5
5
|
language_server-protocol
|
6
|
+
rubocop (>= 1.0)
|
7
|
+
sorbet-runtime
|
8
|
+
syntax_tree (>= 2.3)
|
6
9
|
|
7
10
|
GEM
|
8
11
|
remote: https://rubygems.org/
|
@@ -10,53 +13,112 @@ GEM
|
|
10
13
|
ansi (1.5.0)
|
11
14
|
ast (2.4.2)
|
12
15
|
builder (3.2.4)
|
16
|
+
coderay (1.1.3)
|
17
|
+
debug (1.5.0)
|
18
|
+
irb (>= 1.3.6)
|
19
|
+
reline (>= 0.2.7)
|
20
|
+
diff-lcs (1.5.0)
|
21
|
+
io-console (0.5.11)
|
22
|
+
irb (1.4.1)
|
23
|
+
reline (>= 0.3.0)
|
13
24
|
language_server-protocol (3.16.0.3)
|
25
|
+
method_source (1.0.0)
|
14
26
|
minitest (5.15.0)
|
15
27
|
minitest-reporters (1.5.0)
|
16
28
|
ansi
|
17
29
|
builder
|
18
30
|
minitest (>= 5.0)
|
19
31
|
ruby-progressbar
|
20
|
-
parallel (1.
|
21
|
-
parser (3.1.
|
32
|
+
parallel (1.22.1)
|
33
|
+
parser (3.1.2.0)
|
22
34
|
ast (~> 2.4.1)
|
35
|
+
prettier_print (0.1.0)
|
36
|
+
pry (0.14.1)
|
37
|
+
coderay (~> 1.1)
|
38
|
+
method_source (~> 1.0)
|
23
39
|
rainbow (3.1.1)
|
24
40
|
rake (13.0.6)
|
25
|
-
|
41
|
+
rbi (0.0.14)
|
42
|
+
ast
|
43
|
+
parser (>= 2.6.4.0)
|
44
|
+
sorbet-runtime (>= 0.5.9204)
|
45
|
+
unparser
|
46
|
+
regexp_parser (2.5.0)
|
47
|
+
reline (0.3.1)
|
48
|
+
io-console (~> 0.5)
|
26
49
|
rexml (3.2.5)
|
27
|
-
rubocop (1.
|
50
|
+
rubocop (1.30.0)
|
28
51
|
parallel (~> 1.10)
|
29
52
|
parser (>= 3.1.0.0)
|
30
53
|
rainbow (>= 2.2.2, < 4.0)
|
31
54
|
regexp_parser (>= 1.8, < 3.0)
|
32
|
-
rexml
|
33
|
-
rubocop-ast (>= 1.
|
55
|
+
rexml (>= 3.2.5, < 4.0)
|
56
|
+
rubocop-ast (>= 1.18.0, < 2.0)
|
34
57
|
ruby-progressbar (~> 1.7)
|
35
58
|
unicode-display_width (>= 1.4.0, < 3.0)
|
36
|
-
rubocop-ast (1.
|
59
|
+
rubocop-ast (1.18.0)
|
37
60
|
parser (>= 3.1.1.0)
|
38
|
-
rubocop-minitest (0.
|
61
|
+
rubocop-minitest (0.20.0)
|
39
62
|
rubocop (>= 0.90, < 2.0)
|
40
63
|
rubocop-rake (0.6.0)
|
41
64
|
rubocop (~> 1.0)
|
42
|
-
rubocop-shopify (2.
|
43
|
-
rubocop (~> 1.
|
65
|
+
rubocop-shopify (2.7.0)
|
66
|
+
rubocop (~> 1.30)
|
67
|
+
rubocop-sorbet (0.6.8)
|
68
|
+
rubocop (>= 0.90.0)
|
44
69
|
ruby-progressbar (1.11.0)
|
70
|
+
sorbet (0.5.10073)
|
71
|
+
sorbet-static (= 0.5.10073)
|
72
|
+
sorbet-runtime (0.5.10073)
|
73
|
+
sorbet-static (0.5.10073-universal-darwin-21)
|
74
|
+
sorbet-static (0.5.10073-x86_64-linux)
|
75
|
+
sorbet-static-and-runtime (0.5.10073)
|
76
|
+
sorbet (= 0.5.10073)
|
77
|
+
sorbet-runtime (= 0.5.10073)
|
78
|
+
spoom (1.1.11)
|
79
|
+
sorbet (>= 0.5.9204)
|
80
|
+
sorbet-runtime (>= 0.5.9204)
|
81
|
+
thor (>= 0.19.2)
|
82
|
+
syntax_tree (2.7.1)
|
83
|
+
prettier_print
|
84
|
+
tapioca (0.8.1)
|
85
|
+
bundler (>= 1.17.3)
|
86
|
+
parallel (>= 1.21.0)
|
87
|
+
pry (>= 0.12.2)
|
88
|
+
rbi (~> 0.0.0, >= 0.0.14)
|
89
|
+
sorbet-static-and-runtime (>= 0.5.9204)
|
90
|
+
spoom (~> 1.1.0, >= 1.1.11)
|
91
|
+
thor (>= 1.2.0)
|
92
|
+
yard-sorbet
|
93
|
+
thor (1.2.1)
|
45
94
|
unicode-display_width (2.1.0)
|
95
|
+
unparser (0.6.5)
|
96
|
+
diff-lcs (~> 1.3)
|
97
|
+
parser (>= 3.1.0)
|
98
|
+
webrick (1.7.0)
|
99
|
+
yard (0.9.28)
|
100
|
+
webrick (~> 1.7.0)
|
101
|
+
yard-sorbet (0.6.1)
|
102
|
+
sorbet-runtime (>= 0.5)
|
103
|
+
yard (>= 0.9)
|
46
104
|
|
47
105
|
PLATFORMS
|
48
106
|
arm64-darwin-21
|
49
107
|
x86_64-linux
|
50
108
|
|
51
109
|
DEPENDENCIES
|
110
|
+
debug (~> 1.5)
|
52
111
|
minitest (~> 5.15)
|
53
112
|
minitest-reporters (~> 1.5)
|
54
113
|
rake (~> 13.0)
|
55
|
-
rubocop (~>
|
56
|
-
rubocop-minitest (~> 0.17.2)
|
114
|
+
rubocop-minitest (~> 0.20.0)
|
57
115
|
rubocop-rake (~> 0.6.0)
|
58
|
-
rubocop-shopify (~> 2.
|
116
|
+
rubocop-shopify (~> 2.7)
|
117
|
+
rubocop-sorbet (~> 0.6)
|
59
118
|
ruby-lsp!
|
119
|
+
sorbet-static-and-runtime
|
120
|
+
tapioca (~> 0.8)
|
121
|
+
yard (~> 0.9)
|
60
122
|
|
61
123
|
BUNDLED WITH
|
62
124
|
2.3.7
|
data/README.md
CHANGED
@@ -1,6 +1,23 @@
|
|
1
|
-
|
1
|
+
![Build Status](https://github.com/Shopify/ruby-lsp/workflows/CI/badge.svg)
|
2
2
|
|
3
|
-
|
3
|
+
# Ruby LSP
|
4
|
+
|
5
|
+
This gem is an implementation of the language server protocol specification for Ruby, used to improve editor features.
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
Install the gem. There's no need to require it, since the server is used as a standalone executable.
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
group :development do
|
13
|
+
gem "ruby-lsp", require: false
|
14
|
+
end
|
15
|
+
```
|
16
|
+
|
17
|
+
If using VS Code, install the [Ruby LSP plugin](https://github.com/Shopify/vscode-ruby-lsp) to get the extra features in
|
18
|
+
the editor.
|
19
|
+
|
20
|
+
See the [documentation](https://shopify.github.io/ruby-lsp) for supported features.
|
4
21
|
|
5
22
|
## Contributing
|
6
23
|
|
@@ -10,6 +27,56 @@ are expected to adhere to the
|
|
10
27
|
[Contributor Covenant](https://github.com/Shopify/ruby-lsp/blob/main/CODE_OF_CONDUCT.md)
|
11
28
|
code of conduct.
|
12
29
|
|
30
|
+
### Expectation testing
|
31
|
+
|
32
|
+
To simplify the way we run tests over different pieces of Ruby code, we use a custom expectations test framework against a set of Ruby fixtures.
|
33
|
+
|
34
|
+
To add a new fixture to the expectations test suite:
|
35
|
+
|
36
|
+
1. Add a new fixture `my_fixture.rb` file under `test/fixtures`
|
37
|
+
2. (optional) Add new expectations under `test/expectations/$HANDLER` for the request handlers you're concerned by
|
38
|
+
3. Profit by running `bin/test test/requests/$HANDLER_expectations_test my_fixture`
|
39
|
+
* Handlers for which you added expectations will be checked with `assert_expectations`
|
40
|
+
* Handlers without expectations will be ran against your new test to check that nothing breaks
|
41
|
+
|
42
|
+
To add a new expectations test runner for a new request handler:
|
43
|
+
|
44
|
+
1. Add a new file under `test/requests/$HANDLER_expectations_test.rb` that subclasses `ExpectationsTestRunner` and calls `expectations_tests $HANDLER, "$EXPECTATIONS_DIR"` where: `$HANDLER` is the fully qualified name or your handler class and `$EXPECTATIONS_DIR` is the directory name where you want to store the expectation files.
|
45
|
+
|
46
|
+
```rb
|
47
|
+
# frozen_string_literal: true
|
48
|
+
|
49
|
+
require "test_helper"
|
50
|
+
require "expectations/expectations_test_runner"
|
51
|
+
|
52
|
+
class $HANDLERExpectationsTest < ExpectationsTestRunner
|
53
|
+
expectations_tests RubyLsp::Requests::$HANDLER, "$EXPECTATIONS_DIR"
|
54
|
+
end
|
55
|
+
```
|
56
|
+
|
57
|
+
2. (optional) Override the `run_expectations` and `assert_expectations` methods if needed. See the different request handler expectations runners under `test/requests/*_expectations_test.rb` for examples.
|
58
|
+
|
59
|
+
4. (optional) Add new fixtures for your handler under `test/fixtures`
|
60
|
+
|
61
|
+
5. (optional) Add new expectations under `test/expectations/$HANDLER`
|
62
|
+
* No need to write the expectations by hand, just run the test with an empty expectation file and copy from the output.
|
63
|
+
|
64
|
+
7. Profit by running, `bin/test test/expectations_test $HANDLER`
|
65
|
+
* Tests with expectations will be checked with `assert_expectations`
|
66
|
+
* Tests without expectations will be ran against your new $HANDLER to check that nothing breaks
|
67
|
+
|
68
|
+
## Debugging
|
69
|
+
|
70
|
+
### Tracing LSP requests and responses
|
71
|
+
|
72
|
+
LSP server tracing can be controlled through the `ruby lsp.trace.server` config key in the `.vscode/settings.json` config file.
|
73
|
+
|
74
|
+
Possible values are:
|
75
|
+
|
76
|
+
* `off`: no tracing
|
77
|
+
* `messages`: display requests and responses notifications
|
78
|
+
* `verbose`: display each request and response as JSON
|
79
|
+
|
13
80
|
## License
|
14
81
|
|
15
82
|
The gem is available as open source under the terms of the
|
data/Rakefile
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require "bundler/gem_tasks"
|
4
4
|
require "rake/testtask"
|
5
|
+
require "yard"
|
5
6
|
|
6
7
|
Rake::TestTask.new(:test) do |t|
|
7
8
|
t.libs << "test"
|
@@ -9,6 +10,10 @@ Rake::TestTask.new(:test) do |t|
|
|
9
10
|
t.test_files = FileList["test/**/*_test.rb"]
|
10
11
|
end
|
11
12
|
|
13
|
+
YARD::Rake::YardocTask.new do |t|
|
14
|
+
t.options = ["--markup", "markdown", "--output-dir", "docs"]
|
15
|
+
end
|
16
|
+
|
12
17
|
require "rubocop/rake_task"
|
13
18
|
|
14
19
|
RuboCop::RakeTask.new
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.4
|
data/bin/tapioca
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'tapioca' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("tapioca", "tapioca")
|
data/bin/test
CHANGED
data/dev.yml
CHANGED
@@ -4,15 +4,15 @@ type: ruby
|
|
4
4
|
|
5
5
|
up:
|
6
6
|
- ruby: 3.1.1
|
7
|
-
- bundler
|
8
|
-
|
9
|
-
yarn: 1.22.17
|
10
|
-
version: v16.14.0
|
11
|
-
packages: ["./features/vscode_extension"]
|
7
|
+
- bundler:
|
8
|
+
gemfile: Gemfile
|
12
9
|
|
13
10
|
commands:
|
14
|
-
|
15
|
-
|
11
|
+
server: exe/ruby-lsp
|
12
|
+
style: bin/rubocop
|
13
|
+
typecheck:
|
14
|
+
aliases: ["tc"]
|
15
|
+
run: "bundle exec srb tc"
|
16
16
|
test:
|
17
17
|
syntax:
|
18
18
|
argument: file
|
data/exe/ruby-lsp
CHANGED
@@ -1,6 +1,23 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
|
4
|
+
require "sorbet-runtime"
|
5
5
|
|
6
|
-
|
6
|
+
begin
|
7
|
+
T::Configuration.default_checked_level = :never
|
8
|
+
# Suppresses call validation errors
|
9
|
+
T::Configuration.call_validation_error_handler = ->(*) {}
|
10
|
+
# Suppresses errors caused by T.cast, T.let, T.must, etc.
|
11
|
+
T::Configuration.inline_type_error_handler = ->(*) {}
|
12
|
+
# Suppresses errors caused by incorrect parameter ordering
|
13
|
+
T::Configuration.sig_validation_error_handler = ->(*) {}
|
14
|
+
rescue
|
15
|
+
# Need this rescue so that if another gem has
|
16
|
+
# already set the checked level by the time we
|
17
|
+
# get to it, we don't fail outright.
|
18
|
+
nil
|
19
|
+
end
|
20
|
+
|
21
|
+
require_relative "../lib/internal"
|
22
|
+
|
23
|
+
RubyLsp::Cli.start
|
data/lib/internal.rb
ADDED
data/lib/ruby-lsp.rb
CHANGED
data/lib/ruby_lsp/cli.rb
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "language_server-protocol"
|
5
|
+
|
6
|
+
require_relative "handler"
|
7
|
+
|
8
|
+
module RubyLsp
|
9
|
+
module Cli
|
10
|
+
extend T::Sig
|
11
|
+
|
12
|
+
sig { void }
|
13
|
+
def self.start
|
14
|
+
handler = RubyLsp::Handler.new
|
15
|
+
|
16
|
+
handler.config do
|
17
|
+
on("initialize") do |request|
|
18
|
+
store.clear
|
19
|
+
initialization_options = request.dig(:params, :initializationOptions)
|
20
|
+
|
21
|
+
respond_with_capabilities(initialization_options.fetch(:enabledFeatures, []))
|
22
|
+
end
|
23
|
+
|
24
|
+
on("textDocument/didChange") do |request|
|
25
|
+
uri = request.dig(:params, :textDocument, :uri)
|
26
|
+
store.push_edits(uri, request.dig(:params, :contentChanges))
|
27
|
+
|
28
|
+
send_diagnostics(uri)
|
29
|
+
RubyLsp::Handler::VOID
|
30
|
+
end
|
31
|
+
|
32
|
+
on("textDocument/didOpen") do |request|
|
33
|
+
uri = request.dig(:params, :textDocument, :uri)
|
34
|
+
text = request.dig(:params, :textDocument, :text)
|
35
|
+
store.set(uri, text)
|
36
|
+
|
37
|
+
send_diagnostics(uri)
|
38
|
+
RubyLsp::Handler::VOID
|
39
|
+
end
|
40
|
+
|
41
|
+
on("textDocument/didClose") do |request|
|
42
|
+
uri = request.dig(:params, :textDocument, :uri)
|
43
|
+
store.delete(uri)
|
44
|
+
|
45
|
+
RubyLsp::Handler::VOID
|
46
|
+
end
|
47
|
+
|
48
|
+
on("textDocument/documentSymbol") do |request|
|
49
|
+
respond_with_document_symbol(request.dig(:params, :textDocument, :uri))
|
50
|
+
end
|
51
|
+
|
52
|
+
on("textDocument/foldingRange") do |request|
|
53
|
+
respond_with_folding_ranges(request.dig(:params, :textDocument, :uri))
|
54
|
+
end
|
55
|
+
|
56
|
+
on("textDocument/selectionRange") do |request|
|
57
|
+
respond_with_selection_ranges(
|
58
|
+
request.dig(:params, :textDocument, :uri),
|
59
|
+
request.dig(:params, :positions),
|
60
|
+
)
|
61
|
+
end
|
62
|
+
|
63
|
+
on("textDocument/semanticTokens/full") do |request|
|
64
|
+
respond_with_semantic_highlighting(request.dig(:params, :textDocument, :uri))
|
65
|
+
end
|
66
|
+
|
67
|
+
on("textDocument/formatting") do |request|
|
68
|
+
respond_with_formatting(request.dig(:params, :textDocument, :uri))
|
69
|
+
end
|
70
|
+
|
71
|
+
on("textDocument/documentHighlight") do |request|
|
72
|
+
respond_with_document_highlight(request.dig(:params, :textDocument, :uri), request.dig(:params, :position))
|
73
|
+
end
|
74
|
+
|
75
|
+
on("textDocument/codeAction") do |request|
|
76
|
+
range = request.dig(:params, :range)
|
77
|
+
start_line = range.dig(:start, :line)
|
78
|
+
end_line = range.dig(:end, :line)
|
79
|
+
respond_with_code_actions(request.dig(:params, :textDocument, :uri), (start_line..end_line))
|
80
|
+
end
|
81
|
+
|
82
|
+
on("shutdown") { shutdown }
|
83
|
+
end
|
84
|
+
|
85
|
+
handler.start
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|