You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/language-server-support/README.md
+15-11Lines changed: 15 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -56,34 +56,38 @@ Because traditionally the code editor and the language server is expected to be
56
56
computer (or to be more exact with containers: the same namespace), there usually is a difference
57
57
in the expectations of default usage behaviour and how you want to use it with Bob. Specifically:
58
58
59
-
|issue| Traditional approach | Containerized way |
59
+
|| Traditional approach | Containerized way |
60
60
|-------------------------|---|---|
61
-
| Start a language server | An editor starts `gopls`a as child process | We want to start `gopls` inside a container |
62
-
| Multiple LS instances? | An editor expects one `gopls` instance can access any Go-based project | Each project (also the language server) is in own container, so it can only access the chosen project's files |
61
+
| Start a language server | An editor starts `gopls`as a child process | We want to start `gopls` inside a container |
62
+
| Multiple LS instances? | An editor expects one `gopls` instance to be able to access any Go-based project | Each project (also the LS) is in own container, so it can only access the chosen project's files |
63
63
| File access | Filesystem from editor's & LS's perspective are the same | Host and container filesystems are separated. We can map host paths (like a given project's files) into a container, but paths can be different from host and container perspectives. |
64
64
65
65
More about file access: e.g. `/home/joonas/work/turbobob` could get mounted in `/workspace` inside a
66
66
dev container (the one you get a shell in with `$ bob dev`). Therefore instead of reusing the same
67
67
dev container, a language server gets its own container (still based on the same builder image!) for
68
-
the purpose of trying to make the paths look the same. This is also a better approach because you
68
+
the purpose of trying to make the paths look the same. This is also a good approach because you
69
69
don't want your language server stopping if you exit the dev shell.
70
70
71
71
To help bridge these differences, Bob has a small shim (`$ bob tools langserver`) that handles
72
72
starting an LS in a container with the right parameters. The shim isn't strictly necessary, as you
73
73
could just rig the `$ docker run ... some/docker-image gopls` command directly into your editor's
74
74
LSP config, but it contains so many project-specific parameters (Docker image & its version to use,
75
-
project directory path) that it's easier to use the shim because editors expect one `gopls` langserver
76
-
instance to be able to deal with all of your projects. We're swimming a bit against the current here
77
-
by making a langserver project-specific. Some could say it's a good feature, because now we can't
78
-
get version conflicts if a new langserver doesn't work with an old project anymore. :)
75
+
project directory path) that it's easier to use the shim.
76
+
77
+
Editors expect each LS to be without much config (let alone project-specific config) because
78
+
traditionally each LS isn't project-specific - one LS instance deals with all of your Go-based projects.
79
+
80
+
We're swimming a bit against the current here. I'd still say it's a good tradeoff, because Bob enables
81
+
ones host system to contain minimal state, and now we can't get version conflicts if a new langserver
82
+
doesn't work with an old project anymore. Now a project specifies its langserver it's compatible with. :)
79
83
80
84
81
85
### Beta quality warning
82
86
83
87
The LSP support is in beta stage. It is working at least in my test setup and there isn't major hacks
84
88
preventing wider use - but I haven't tested it more languages and editors yet.
85
89
86
-
The following has been tested to work: Bob + Sublime Text + gopls.
90
+
The following has been tested to work with Go code: Bob + Sublime Text + gopls.
87
91
88
92
89
93
### Known issues
@@ -92,7 +96,7 @@ Here be dragons - Bob's LSP shim isn't perfect yet:
92
96
93
97
- Depending on your editor you might be able to only access one project at a time for each given
94
98
language (unless you create different "langserver instance" configs for each project in your editor).
95
-
At least Sublime Text expects that if one `gopls` instance running, it can use that instance to
99
+
At least Sublime Text expects that if one `gopls` instance is running, it can use that instance to
96
100
access projects A and B, but the `gopls` is in A's container (assuming that project was opened
97
101
first and as a result the langserver was launched) and thus can't access B's files.
98
102
@@ -109,7 +113,7 @@ Here be dragons - Bob's LSP shim isn't perfect yet:
109
113
110
114
We're assuming you're using Sublime Text and Go language, but the overall process is the same for every editor:
111
115
112
-
- Make sure the editor supports LSP, if not, it might have a plugin
116
+
- Make sure the editor supports LSP. If not directly, it might have a plugin
113
117
114
118
- There usually is per-language configuration to enable LSP by specifying a command the editor runs
0 commit comments