Skip to content
This repository was archived by the owner on Mar 19, 2024. It is now read-only.

Commit 6dcb1ee

Browse files
authored
Merge pull request #32 from alexheretic/master
Enhance debugging
2 parents abf6763 + fbfc92f commit 6dcb1ee

File tree

4 files changed

+40
-14
lines changed

4 files changed

+40
-14
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ When set you'll be able to see, and remove, this from the package settings. Afte
3838

3939
![](https://image.ibb.co/jsR65w/rls_Command_Override_Info.png)
4040

41+
## Debugging
42+
If stuff isn't working you can try **enabling logging** to debug:
43+
* Open the atom console _(ctrl-shift-i)_
44+
* Enter `atom.config.set('core.debugLSP', true)`
45+
* Reload atom _(ctrl-shift-F5)_
46+
47+
This will spit out language server message logging into the atom console. Check if requests/responses are being sent or are incorrect. It will also include any Rls stderr messages (as warnings) which may point to Rls bugs.
48+
4149
## License
4250

4351
MIT License. See the [license](LICENSE) for more details.

lib/index.js

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,24 @@ function serverEnv(toolchain) {
168168
return env
169169
}
170170

171+
/**
172+
* Logs stderr if `core.debugLSP` is enabled
173+
* TODO should be handled upstream, see https://github.com/atom/atom-languageclient/issues/157
174+
* @param {process} process
175+
* @return {process}
176+
*/
177+
function logStdErr(process) {
178+
if (atom.config.get('core.debugLSP')) {
179+
process.stderr.on('data', chunk => {
180+
chunk.toString()
181+
.split('\n')
182+
.filter(l => l)
183+
.forEach(line => console.warn('Rls-stderr', line))
184+
})
185+
}
186+
return process
187+
}
188+
171189
/**
172190
* Check for and install Rls
173191
* @param [busySignalService]
@@ -320,16 +338,18 @@ class RustLanguageClient extends AutoLanguageClient {
320338
atom.notifications.addInfo(`Using rls command \`${cmdOverride}\``)
321339
this._warnedAboutRlsCommandOverride = true
322340
}
323-
return cp.spawn(cmdOverride, {
341+
return logStdErr(cp.spawn(cmdOverride, {
324342
env: serverEnv(),
325343
shell: true
326-
})
344+
}))
327345
}
328346

329347
return checkToolchain(this.busySignalService)
330348
.then(toolchain => checkRls(this.busySignalService).then(() => toolchain))
331349
.then(toolchain => {
332-
return cp.spawn("rustup", ["run", configToolchain(), "rls"], { env: serverEnv(toolchain) })
350+
return logStdErr(cp.spawn("rustup", ["run", configToolchain(), "rls"], {
351+
env: serverEnv(toolchain)
352+
}))
333353
})
334354
}
335355
}

package-lock.json

Lines changed: 8 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"atom": ">=1.21.0"
1919
},
2020
"dependencies": {
21-
"atom-languageclient": "^0.7.0",
21+
"atom-languageclient": "^0.7.2",
2222
"atom-package-deps": "^4.6.0",
2323
"toml": "^2.3.3",
2424
"underscore-plus": "^1.6.6"

0 commit comments

Comments
 (0)