Skip to content

Commit c2d00fc

Browse files
committed
+ LSP support
1 parent 04800ff commit c2d00fc

6 files changed

Lines changed: 123 additions & 2 deletions

File tree

template/_lsp.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Configure Ruby LSP
2+
3+
begin
4+
if gemspecs.key?("ruby-lsp")
5+
file "#{DOCKER_DEV_ROOT}/ruby-lsp", <%= code("ruby-lsp") %>
6+
7+
chmod "#{DOCKER_DEV_ROOT}/ruby-lsp", 0755
8+
end
9+
10+
if gemspecs.key?("solargraph")
11+
file "#{DOCKER_DEV_ROOT}/solargraph", <%= code("solargraph") %>
12+
13+
chmod "#{DOCKER_DEV_ROOT}/solargraph", 0755
14+
end
15+
end

template/dip.yml.tt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,18 @@ interaction:
6464

6565
ruby-lsp:
6666
description: Run Ruby LSP
67-
service: ruby-lsp
67+
service: rails
6868
command: bundle exec ruby-lsp
6969
compose_run_options: [ service-ports, no-deps ]
7070
<% end %>
71+
<% if gemspecs.key?("solargraph") %>
72+
73+
solargraph:
74+
description: Run Solargraph
75+
service: rails
76+
command: bundle exec solargraph
77+
compose_run_options: [ service-ports, no-deps ]
78+
<% end %>
7179
<% if yarn_version %>
7280

7381
yarn:

template/ruby-lsp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
3+
# This binary can be used to run Ruby LSP within a Docker container.
4+
#
5+
# You must configure your editor to do that.
6+
#
7+
# Zed example (`.zed/settings.json`):
8+
#
9+
# {
10+
# "languages": {
11+
# "Ruby": {
12+
# "language_servers": ["ruby-lsp", "!solargraph", "!rubocop", "..."]
13+
# }
14+
# },
15+
# "lsp": {
16+
# "ruby-lsp": {
17+
# "binary": {
18+
# "path": ".dockerdev/ruby-lsp",
19+
# "arguments": ["stdio"]
20+
# }
21+
# }
22+
# }
23+
# }
24+
#
25+
26+
cd $(dirname $0)/..
27+
28+
dip ruby-lsp $@

template/solargraph

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
3+
# This binary can be used to run Solargraph within a Docker container.
4+
#
5+
# You must configure your editor to do that.
6+
#
7+
# Zed example (`.zed/settings.json`):
8+
#
9+
# {
10+
# "lsp": {
11+
# "solargraph": {
12+
# "binary": {
13+
# "path": ".dockerdev/solargraph",
14+
# "arguments": ["stdio"]
15+
# }
16+
# }
17+
# }
18+
# }
19+
#
20+
21+
cd $(dirname $0)/..
22+
23+
dip solargraph $@

test/template/dip_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def test_default_dip_configuration
6262
<<-CODE
6363
ruby-lsp:
6464
description: Run Ruby LSP
65-
service: ruby-lsp
65+
service: rails
6666
command: bundle exec ruby-lsp
6767
compose_run_options: [ service-ports, no-deps ]
6868
CODE

test/template/lsp_test.rb

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# frozen_string_literal: true
2+
3+
require "test_helper"
4+
5+
class LSPRubyLSPTest < GeneratorTestCase
6+
template %q(
7+
DOCKER_DEV_ROOT = ".dockerdev_test"
8+
9+
gemspecs = {
10+
"ruby-lsp" => Gem::Version.new("1.0.0")
11+
}
12+
13+
<%= include "lsp" %>
14+
)
15+
16+
def test_when_has_ruby_lsp
17+
run_generator do |output|
18+
assert_file_contains ".dockerdev_test/ruby-lsp", <<~CODE
19+
cd $(dirname $0)/..
20+
21+
dip ruby-lsp $@
22+
CODE
23+
end
24+
end
25+
end
26+
27+
class LSPSolargraphTest < GeneratorTestCase
28+
template %q(
29+
DOCKER_DEV_ROOT = ".dockerdev_test"
30+
31+
gemspecs = {
32+
"solargraph" => Gem::Version.new("1.0.0")
33+
}
34+
35+
<%= include "lsp" %>
36+
)
37+
38+
def test_when_has_solargraph
39+
run_generator do |output|
40+
assert_file_contains ".dockerdev_test/solargraph", <<~CODE
41+
cd $(dirname $0)/..
42+
43+
dip solargraph $@
44+
CODE
45+
end
46+
end
47+
end

0 commit comments

Comments
 (0)