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

Commit 535a584

Browse files
authored
Support some standard code actions, filter out rust-analyzer custom ones (#173)
Update atom-languageclient
1 parent 3d41d7d commit 535a584

File tree

2 files changed

+36
-25
lines changed

2 files changed

+36
-25
lines changed

lib/index.js

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ async function serverEnv(toolchain, cwd) {
182182
env.RUST_BACKTRACE = env.RUST_BACKTRACE || "1"
183183

184184
// if (!env.RUST_LOG && atom.config.get('core.debugLSP')) {
185-
// env.RUST_LOG = 'rls=warn,rls::build=info'
185+
// env.RUST_LOG = 'info'
186186
// }
187187

188188
try {
@@ -505,9 +505,9 @@ class RustLanguageClient extends AutoLanguageClient {
505505
!filePath.includes('/target/release/')
506506
}
507507

508-
// Killing servers is faster and less likely to get stuck.
508+
// Killing servers is faster and less likely to get stuck, but let's see if rust-analyzer deserves grace...
509509
shutdownServersGracefully() {
510-
return false
510+
return true
511511
}
512512

513513
// Can click through to out-of-project files.
@@ -576,6 +576,24 @@ class RustLanguageClient extends AutoLanguageClient {
576576
return provide
577577
}
578578

579+
/**
580+
* Hide unsupported rust-analyzer custom actions
581+
* @param {(ls.Command | ls.CodeAction)[]} actions
582+
* @returns {(ls.Command | ls.CodeAction)[]} filtered actions
583+
*/
584+
filterCodeActions(actions) {
585+
return actions.filter(a => !a.command || a.command.command !== "rust-analyzer.applySourceChange")
586+
}
587+
588+
// /**
589+
// * TODO: Handle rust-analyzer custom actions
590+
// * @param {(ls.Command | ls.CodeAction)} action
591+
// * @returns {Promise<boolean>} continue with default handling
592+
// */
593+
// async onApplyCodeActions(action) {
594+
// return true
595+
// }
596+
579597
/**
580598
* Extend base-class to workaround the limited markdown support.
581599
* @param {TextEditor} editor

package-lock.json

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

0 commit comments

Comments
 (0)