Allow each language adapter to provide their own code action kinds array

This commit is contained in:
Julia 2023-03-30 15:41:54 -04:00
parent 007aa92581
commit cdde523ea4
4 changed files with 41 additions and 10 deletions

View file

@ -20,6 +20,7 @@ use futures::{
use gpui::{executor::Background, MutableAppContext, Task};
use highlight_map::HighlightMap;
use lazy_static::lazy_static;
use lsp::CodeActionKind;
use parking_lot::{Mutex, RwLock};
use postage::watch;
use regex::Regex;
@ -140,6 +141,10 @@ impl CachedLspAdapter {
self.adapter.cached_server_binary(container_dir).await
}
pub fn code_action_kinds(&self) -> Option<Vec<CodeActionKind>> {
self.adapter.code_action_kinds()
}
pub fn workspace_configuration(
&self,
cx: &mut MutableAppContext,
@ -225,6 +230,16 @@ pub trait LspAdapter: 'static + Send + Sync {
None
}
fn code_action_kinds(&self) -> Option<Vec<CodeActionKind>> {
Some(vec![
CodeActionKind::EMPTY,
CodeActionKind::QUICKFIX,
CodeActionKind::REFACTOR,
CodeActionKind::REFACTOR_EXTRACT,
CodeActionKind::SOURCE,
])
}
async fn disk_based_diagnostic_sources(&self) -> Vec<String> {
Default::default()
}
@ -825,6 +840,7 @@ impl LanguageRegistry {
&binary.path,
&binary.arguments,
&root_path,
adapter.code_action_kinds(),
cx,
)?;