|
|
@ -278,11 +278,13 @@ pub mod completers {
|
|
|
|
.unwrap_or_else(|| Cow::from(SCRATCH_BUFFER_NAME))
|
|
|
|
.unwrap_or_else(|| Cow::from(SCRATCH_BUFFER_NAME))
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
fuzzy_match(input, names, true)
|
|
|
|
CompletionResult::new(
|
|
|
|
.into_iter()
|
|
|
|
fuzzy_match(input, names, true)
|
|
|
|
.map(|(name, _)| ((0..), name))
|
|
|
|
.into_iter()
|
|
|
|
.collect::<Vec<Completion>>()
|
|
|
|
.map(|(name, _)| ((0..), name))
|
|
|
|
.into()
|
|
|
|
.collect::<Vec<Completion>>(),
|
|
|
|
|
|
|
|
false,
|
|
|
|
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn theme(_editor: &Editor, input: &str) -> CompletionResult {
|
|
|
|
pub fn theme(_editor: &Editor, input: &str) -> CompletionResult {
|
|
|
@ -295,11 +297,13 @@ pub mod completers {
|
|
|
|
names.sort();
|
|
|
|
names.sort();
|
|
|
|
names.dedup();
|
|
|
|
names.dedup();
|
|
|
|
|
|
|
|
|
|
|
|
fuzzy_match(input, names, false)
|
|
|
|
CompletionResult::new(
|
|
|
|
.into_iter()
|
|
|
|
fuzzy_match(input, names, false)
|
|
|
|
.map(|(name, _)| ((0..), name.into()))
|
|
|
|
.into_iter()
|
|
|
|
.collect::<Vec<Completion>>()
|
|
|
|
.map(|(name, _)| ((0..), name.into()))
|
|
|
|
.into()
|
|
|
|
.collect::<Vec<Completion>>(),
|
|
|
|
|
|
|
|
false,
|
|
|
|
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Recursive function to get all keys from this value and add them to vec
|
|
|
|
/// Recursive function to get all keys from this value and add them to vec
|
|
|
@ -326,11 +330,13 @@ pub mod completers {
|
|
|
|
keys
|
|
|
|
keys
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
fuzzy_match(input, &*KEYS, false)
|
|
|
|
CompletionResult::new(
|
|
|
|
.into_iter()
|
|
|
|
fuzzy_match(input, &*KEYS, false)
|
|
|
|
.map(|(name, _)| ((0..), name.into()))
|
|
|
|
.into_iter()
|
|
|
|
.collect::<Vec<Completion>>()
|
|
|
|
.map(|(name, _)| ((0..), name.into()))
|
|
|
|
.into()
|
|
|
|
.collect::<Vec<Completion>>(),
|
|
|
|
|
|
|
|
false,
|
|
|
|
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn filename(editor: &Editor, input: &str) -> CompletionResult {
|
|
|
|
pub fn filename(editor: &Editor, input: &str) -> CompletionResult {
|
|
|
@ -363,11 +369,13 @@ pub mod completers {
|
|
|
|
.map(|config| &config.language_id)
|
|
|
|
.map(|config| &config.language_id)
|
|
|
|
.chain(std::iter::once(&text));
|
|
|
|
.chain(std::iter::once(&text));
|
|
|
|
|
|
|
|
|
|
|
|
fuzzy_match(input, language_ids, false)
|
|
|
|
CompletionResult::new(
|
|
|
|
.into_iter()
|
|
|
|
fuzzy_match(input, language_ids, false)
|
|
|
|
.map(|(name, _)| ((0..), name.to_owned().into()))
|
|
|
|
.into_iter()
|
|
|
|
.collect::<Vec<Completion>>()
|
|
|
|
.map(|(name, _)| ((0..), name.to_owned().into()))
|
|
|
|
.into()
|
|
|
|
.collect::<Vec<Completion>>(),
|
|
|
|
|
|
|
|
false,
|
|
|
|
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn lsp_workspace_command(editor: &Editor, input: &str) -> CompletionResult {
|
|
|
|
pub fn lsp_workspace_command(editor: &Editor, input: &str) -> CompletionResult {
|
|
|
@ -378,11 +386,13 @@ pub mod completers {
|
|
|
|
return CompletionResult::default();
|
|
|
|
return CompletionResult::default();
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
fuzzy_match(input, &options.commands, false)
|
|
|
|
CompletionResult::new(
|
|
|
|
.into_iter()
|
|
|
|
fuzzy_match(input, &options.commands, false)
|
|
|
|
.map(|(name, _)| ((0..), name.to_owned().into()))
|
|
|
|
.into_iter()
|
|
|
|
.collect::<Vec<Completion>>()
|
|
|
|
.map(|(name, _)| ((0..), name.to_owned().into()))
|
|
|
|
.into()
|
|
|
|
.collect::<Vec<Completion>>(),
|
|
|
|
|
|
|
|
false,
|
|
|
|
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn directory(editor: &Editor, input: &str) -> CompletionResult {
|
|
|
|
pub fn directory(editor: &Editor, input: &str) -> CompletionResult {
|
|
|
@ -504,17 +514,19 @@ pub mod completers {
|
|
|
|
// if empty, return a list of dirs and files in current dir
|
|
|
|
// if empty, return a list of dirs and files in current dir
|
|
|
|
if let Some(file_name) = file_name {
|
|
|
|
if let Some(file_name) = file_name {
|
|
|
|
let range = (input.len().saturating_sub(file_name.len()))..;
|
|
|
|
let range = (input.len().saturating_sub(file_name.len()))..;
|
|
|
|
fuzzy_match(&file_name, files, true)
|
|
|
|
CompletionResult::new(
|
|
|
|
.into_iter()
|
|
|
|
fuzzy_match(&file_name, files, true)
|
|
|
|
.map(|(name, _)| (range.clone(), name))
|
|
|
|
.into_iter()
|
|
|
|
.collect::<Vec<Completion>>()
|
|
|
|
.map(|(name, _)| (range.clone(), name))
|
|
|
|
.into()
|
|
|
|
.collect::<Vec<Completion>>(),
|
|
|
|
|
|
|
|
false,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: complete to longest common match
|
|
|
|
// TODO: complete to longest common match
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
let mut files: Vec<_> = files.map(|file| (end.clone(), file)).collect();
|
|
|
|
let mut files: Vec<_> = files.map(|file| (end.clone(), file)).collect();
|
|
|
|
files.sort_unstable_by(|(_, path1), (_, path2)| path1.cmp(path2));
|
|
|
|
files.sort_unstable_by(|(_, path1), (_, path2)| path1.cmp(path2));
|
|
|
|
files.into()
|
|
|
|
CompletionResult::new(files, false)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -526,10 +538,10 @@ pub mod completers {
|
|
|
|
.filter(|(ch, _)| !matches!(ch, '%' | '#' | '.'))
|
|
|
|
.filter(|(ch, _)| !matches!(ch, '%' | '#' | '.'))
|
|
|
|
.map(|(ch, _)| ch.to_string());
|
|
|
|
.map(|(ch, _)| ch.to_string());
|
|
|
|
|
|
|
|
|
|
|
|
fuzzy_match(input, iter, false)
|
|
|
|
let results = fuzzy_match(input, iter, false)
|
|
|
|
.into_iter()
|
|
|
|
.into_iter()
|
|
|
|
.map(|(name, _)| ((0..), name.into()))
|
|
|
|
.map(|(name, _)| ((0..), name.into()))
|
|
|
|
.collect::<Vec<Completion>>()
|
|
|
|
.collect::<Vec<Completion>>();
|
|
|
|
.into()
|
|
|
|
CompletionResult::new(results, false)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|