mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-26 03:59:55 +00:00
Implement ElixirLspAdapter::label_for_symbol
This commit is contained in:
parent
13c2021aef
commit
559dad893f
1 changed files with 32 additions and 2 deletions
|
@ -4,7 +4,7 @@ use async_trait::async_trait;
|
||||||
use client::http::HttpClient;
|
use client::http::HttpClient;
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
pub use language::*;
|
pub use language::*;
|
||||||
use lsp::CompletionItemKind;
|
use lsp::{CompletionItemKind, SymbolKind};
|
||||||
use smol::fs::{self, File};
|
use smol::fs::{self, File};
|
||||||
use std::{any::Any, path::PathBuf, sync::Arc};
|
use std::{any::Any, path::PathBuf, sync::Arc};
|
||||||
use util::ResultExt;
|
use util::ResultExt;
|
||||||
|
@ -139,7 +139,8 @@ impl LspAdapter for ElixirLspAdapter {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Some((
|
Some((
|
||||||
CompletionItemKind::MODULE
|
CompletionItemKind::CLASS
|
||||||
|
| CompletionItemKind::MODULE
|
||||||
| CompletionItemKind::INTERFACE
|
| CompletionItemKind::INTERFACE
|
||||||
| CompletionItemKind::STRUCT,
|
| CompletionItemKind::STRUCT,
|
||||||
_,
|
_,
|
||||||
|
@ -162,4 +163,33 @@ impl LspAdapter for ElixirLspAdapter {
|
||||||
|
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn label_for_symbol(
|
||||||
|
&self,
|
||||||
|
name: &str,
|
||||||
|
kind: SymbolKind,
|
||||||
|
language: &Language,
|
||||||
|
) -> Option<CodeLabel> {
|
||||||
|
let (text, filter_range, display_range) = match kind {
|
||||||
|
SymbolKind::METHOD | SymbolKind::FUNCTION => {
|
||||||
|
let text = format!("def {}", name);
|
||||||
|
let filter_range = 4..4 + name.len();
|
||||||
|
let display_range = 0..filter_range.end;
|
||||||
|
(text, filter_range, display_range)
|
||||||
|
}
|
||||||
|
SymbolKind::CLASS | SymbolKind::MODULE | SymbolKind::INTERFACE | SymbolKind::STRUCT => {
|
||||||
|
let text = format!("defmodule {}", name);
|
||||||
|
let filter_range = 10..10 + name.len();
|
||||||
|
let display_range = 0..filter_range.end;
|
||||||
|
(text, filter_range, display_range)
|
||||||
|
}
|
||||||
|
_ => return None,
|
||||||
|
};
|
||||||
|
|
||||||
|
Some(CodeLabel {
|
||||||
|
runs: language.highlight_text(&text.as_str().into(), display_range.clone()),
|
||||||
|
text: text[display_range].to_string(),
|
||||||
|
filter_range,
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue