diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-03-11 11:46:12 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-03-11 11:46:12 +0100 |
| commit | 8e5f446544fd147277ed2e4208c7ea793cc846a7 (patch) | |
| tree | f8b0143fb3845da6673ca1312f03ab53f0f28a50 /src/eval | |
| parent | a9fdff244aef859449a76e5f762ee7c343a8ddcc (diff) | |
Autocompletion for raw language tags
Diffstat (limited to 'src/eval')
| -rw-r--r-- | src/eval/args.rs | 4 | ||||
| -rw-r--r-- | src/eval/array.rs | 4 | ||||
| -rw-r--r-- | src/eval/cast.rs | 3 | ||||
| -rw-r--r-- | src/eval/dict.rs | 6 | ||||
| -rw-r--r-- | src/eval/library.rs | 2 |
5 files changed, 11 insertions, 8 deletions
diff --git a/src/eval/args.rs b/src/eval/args.rs index 17bd9cb4..129da463 100644 --- a/src/eval/args.rs +++ b/src/eval/args.rs @@ -5,7 +5,7 @@ use ecow::{eco_format, EcoVec}; use super::{Array, Cast, Dict, Str, Value}; use crate::diag::{bail, At, SourceResult}; use crate::syntax::{Span, Spanned}; -use crate::util::pretty_array; +use crate::util::pretty_array_like; /// Evaluated arguments to a function. #[derive(Clone, PartialEq, Hash)] @@ -174,7 +174,7 @@ impl Debug for Args { fn fmt(&self, f: &mut Formatter) -> fmt::Result { let pieces: Vec<_> = self.items.iter().map(|arg| eco_format!("{arg:?}")).collect(); - f.write_str(&pretty_array(&pieces, false)) + f.write_str(&pretty_array_like(&pieces, false)) } } diff --git a/src/eval/array.rs b/src/eval/array.rs index 8da9b3d2..979f15d4 100644 --- a/src/eval/array.rs +++ b/src/eval/array.rs @@ -6,7 +6,7 @@ use ecow::{eco_format, EcoString, EcoVec}; use super::{ops, Args, Func, Value, Vm}; use crate::diag::{bail, At, SourceResult, StrResult}; -use crate::util::pretty_array; +use crate::util::pretty_array_like; /// Create a new [`Array`] from values. #[macro_export] @@ -343,7 +343,7 @@ impl Array { impl Debug for Array { fn fmt(&self, f: &mut Formatter) -> fmt::Result { let pieces: Vec<_> = self.iter().map(|value| eco_format!("{value:?}")).collect(); - f.write_str(&pretty_array(&pieces, self.len() == 1)) + f.write_str(&pretty_array_like(&pieces, self.len() == 1)) } } diff --git a/src/eval/cast.rs b/src/eval/cast.rs index 806f7e92..ac23bd3a 100644 --- a/src/eval/cast.rs +++ b/src/eval/cast.rs @@ -8,6 +8,7 @@ use ecow::EcoString; use super::{Array, Str, Value}; use crate::diag::StrResult; use crate::syntax::Spanned; +use crate::util::separated_list; /// Cast from a value to a specific type. pub trait Cast<V = Value>: Sized { @@ -284,7 +285,7 @@ impl CastInfo { msg.push_str(" nothing"); } - crate::diag::comma_list(&mut msg, &parts, "or"); + msg.push_str(&separated_list(&parts, "or")); if !matching_type { msg.push_str(", found "); diff --git a/src/eval/dict.rs b/src/eval/dict.rs index ececce07..4333a55e 100644 --- a/src/eval/dict.rs +++ b/src/eval/dict.rs @@ -8,7 +8,7 @@ use ecow::{eco_format, EcoString}; use super::{array, Array, Str, Value}; use crate::diag::StrResult; use crate::syntax::is_ident; -use crate::util::{pretty_array, ArcExt}; +use crate::util::{pretty_array_like, separated_list, ArcExt}; /// Create a new [`Dict`] from key-value pairs. #[macro_export] @@ -125,7 +125,7 @@ impl Dict { if let Some((key, _)) = self.iter().next() { let parts: Vec<_> = expected.iter().map(|s| eco_format!("\"{s}\"")).collect(); let mut msg = format!("unexpected key {key:?}, valid keys are "); - crate::diag::comma_list(&mut msg, &parts, "and"); + msg.push_str(&separated_list(&parts, "and")); return Err(msg.into()); } Ok(()) @@ -149,7 +149,7 @@ impl Debug for Dict { }) .collect(); - f.write_str(&pretty_array(&pieces, false)) + f.write_str(&pretty_array_like(&pieces, false)) } } diff --git a/src/eval/library.rs b/src/eval/library.rs index 75787348..c37c16fd 100644 --- a/src/eval/library.rs +++ b/src/eval/library.rs @@ -55,6 +55,8 @@ pub struct LangItems { pub emph: fn(body: Content) -> Content, /// Raw text with optional syntax highlighting: `` `...` ``. pub raw: fn(text: EcoString, tag: Option<EcoString>, block: bool) -> Content, + /// The language names and tags supported by raw text. + pub raw_languages: fn() -> Vec<(&'static str, Vec<&'static str>)>, /// A hyperlink: `https://typst.org`. pub link: fn(url: EcoString) -> Content, /// A reference: `@target`. |
