|
|
|
@ -5,7 +5,10 @@ use helix_lsp::{
|
|
|
|
|
util::{diagnostic_to_lsp_diagnostic, lsp_pos_to_pos, lsp_range_to_range, range_to_lsp_range},
|
|
|
|
|
OffsetEncoding,
|
|
|
|
|
};
|
|
|
|
|
use tui::text::{Span, Spans};
|
|
|
|
|
use tui::{
|
|
|
|
|
text::{Span, Spans},
|
|
|
|
|
widgets::Row,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
use super::{align_view, push_jump, Align, Context, Editor, Open};
|
|
|
|
|
|
|
|
|
@ -46,7 +49,7 @@ impl ui::menu::Item for lsp::Location {
|
|
|
|
|
/// Current working directory.
|
|
|
|
|
type Data = PathBuf;
|
|
|
|
|
|
|
|
|
|
fn label(&self, cwdir: &Self::Data) -> Spans {
|
|
|
|
|
fn format(&self, cwdir: &Self::Data) -> Row {
|
|
|
|
|
// The preallocation here will overallocate a few characters since it will account for the
|
|
|
|
|
// URL's scheme, which is not used most of the time since that scheme will be "file://".
|
|
|
|
|
// Those extra chars will be used to avoid allocating when writing the line number (in the
|
|
|
|
@ -80,7 +83,7 @@ impl ui::menu::Item for lsp::SymbolInformation {
|
|
|
|
|
/// Path to currently focussed document
|
|
|
|
|
type Data = Option<lsp::Url>;
|
|
|
|
|
|
|
|
|
|
fn label(&self, current_doc_path: &Self::Data) -> Spans {
|
|
|
|
|
fn format(&self, current_doc_path: &Self::Data) -> Row {
|
|
|
|
|
if current_doc_path.as_ref() == Some(&self.location.uri) {
|
|
|
|
|
self.name.as_str().into()
|
|
|
|
|
} else {
|
|
|
|
@ -110,7 +113,7 @@ struct PickerDiagnostic {
|
|
|
|
|
impl ui::menu::Item for PickerDiagnostic {
|
|
|
|
|
type Data = (DiagnosticStyles, DiagnosticsFormat);
|
|
|
|
|
|
|
|
|
|
fn label(&self, (styles, format): &Self::Data) -> Spans {
|
|
|
|
|
fn format(&self, (styles, format): &Self::Data) -> Row {
|
|
|
|
|
let mut style = self
|
|
|
|
|
.diag
|
|
|
|
|
.severity
|
|
|
|
@ -149,6 +152,7 @@ impl ui::menu::Item for PickerDiagnostic {
|
|
|
|
|
Span::styled(&self.diag.message, style),
|
|
|
|
|
Span::styled(code, style),
|
|
|
|
|
])
|
|
|
|
|
.into()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -467,7 +471,7 @@ pub fn workspace_diagnostics_picker(cx: &mut Context) {
|
|
|
|
|
|
|
|
|
|
impl ui::menu::Item for lsp::CodeActionOrCommand {
|
|
|
|
|
type Data = ();
|
|
|
|
|
fn label(&self, _data: &Self::Data) -> Spans {
|
|
|
|
|
fn format(&self, _data: &Self::Data) -> Row {
|
|
|
|
|
match self {
|
|
|
|
|
lsp::CodeActionOrCommand::CodeAction(action) => action.title.as_str().into(),
|
|
|
|
|
lsp::CodeActionOrCommand::Command(command) => command.title.as_str().into(),
|
|
|
|
@ -662,7 +666,7 @@ pub fn code_action(cx: &mut Context) {
|
|
|
|
|
|
|
|
|
|
impl ui::menu::Item for lsp::Command {
|
|
|
|
|
type Data = ();
|
|
|
|
|
fn label(&self, _data: &Self::Data) -> Spans {
|
|
|
|
|
fn format(&self, _data: &Self::Data) -> Row {
|
|
|
|
|
self.title.as_str().into()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|