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

Commit 6a3916c

Browse files
authored
Merge pull request #205 from Green-Avocado/config-file
2 parents ac226e5 + 8869407 commit 6a3916c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

lib/index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const cp = require("child_process")
22
const os = require("os")
3+
const fs = require("fs")
34
const path = require("path")
45
const { CompositeDisposable, Disposable } = require("atom")
56
const { AutoLanguageClient } = require("atom-languageclient")
@@ -450,6 +451,18 @@ class RustLanguageClient extends AutoLanguageClient {
450451
params.initializationOptions = params.initializationOptions || {}
451452
// Don't build straight after initialize, wait for first `workspace/didChangeConfiguration`
452453
params.initializationOptions.omitInitBuild = true
454+
455+
let rlsConfigPath = path.join(projectPath, "rust-analyzer.json")
456+
457+
if (fs.existsSync(rlsConfigPath)) {
458+
try {
459+
let options = fs.readFileSync(rlsConfigPath)
460+
Object.assign(params.initializationOptions, JSON.parse(options))
461+
} catch(e) {
462+
atom.notifications.addError("Error reading rust-analyzer config file\n", e)
463+
}
464+
}
465+
453466
return params
454467
}
455468

0 commit comments

Comments
 (0)