mirror of
https://github.com/noib3/nvim-oxi.git
synced 2025-08-04 19:08:31 +00:00
parent
8999e511d3
commit
40ecec656a
6 changed files with 109 additions and 31 deletions
|
@ -319,6 +319,8 @@ pub struct SetExtmarkOpts {
|
|||
end_col: types::Integer,
|
||||
|
||||
/// Name of the highlight group used to highlight this mark.
|
||||
#[cfg(not(feature = "neovim-nightly"))] // On 0.9 and 0.10.
|
||||
#[cfg_attr(docsrs, doc(cfg(not(feature = "neovim-nightly"))))]
|
||||
#[builder(
|
||||
generics = "Hl: crate::HlGroup",
|
||||
argtype = "Hl",
|
||||
|
@ -326,6 +328,16 @@ pub struct SetExtmarkOpts {
|
|||
)]
|
||||
hl_group: types::HlGroupId,
|
||||
|
||||
/// Name of the highlight group used to highlight this mark.
|
||||
#[cfg(feature = "neovim-nightly")] // Only on Nightly.
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "neovim-nightly")))]
|
||||
#[builder(
|
||||
generics = "Hl: crate::SetExtmarkHlGroup",
|
||||
argtype = "Hl",
|
||||
inline = r#"{0}.into_object()"#
|
||||
)]
|
||||
hl_group: types::Object,
|
||||
|
||||
/// Virtual text to link to this mark. Every `(text, highlights)` tuple
|
||||
/// represents a text chunk with a specified highlight. The highlights
|
||||
/// specified in `highlights` will be combined together, with the highest
|
||||
|
|
|
@ -175,6 +175,38 @@ impl HlGroup for &str {
|
|||
}
|
||||
}
|
||||
|
||||
/// A trait implemented by types that can be passed to
|
||||
/// [`SetExtmarkOptsBuilder::hl_group`](crate::opts::SetExtmarkOptsBuilder::hl_group).
|
||||
#[cfg(feature = "neovim-nightly")] // Only on Nightly.
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "neovim-nightly")))]
|
||||
pub trait SetExtmarkHlGroup {
|
||||
fn into_object(self) -> Object;
|
||||
}
|
||||
|
||||
#[cfg(feature = "neovim-nightly")] // Only on Nightly.
|
||||
impl SetExtmarkHlGroup for Integer {
|
||||
#[inline]
|
||||
fn into_object(self) -> Object {
|
||||
self.into()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "neovim-nightly")] // Only on Nightly.
|
||||
impl SetExtmarkHlGroup for &str {
|
||||
#[inline]
|
||||
fn into_object(self) -> Object {
|
||||
self.into()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "neovim-nightly")] // Only on Nightly.
|
||||
impl<T: StringOrInt> SetExtmarkHlGroup for Vec<T> {
|
||||
#[inline]
|
||||
fn into_object(self) -> Object {
|
||||
self.into_iter().map(StringOrInt::to_object).collect::<Array>().into()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "neovim-0-10")] // On 0.10 and nightly.
|
||||
mod sealed {
|
||||
pub trait Sealed {}
|
||||
|
|
|
@ -23,9 +23,16 @@ pub struct ExtmarkInfos {
|
|||
#[serde(default)]
|
||||
pub hl_eol: Option<bool>,
|
||||
|
||||
#[cfg(not(feature = "neovim-nightly"))] // On 0.9 and 0.10.
|
||||
#[cfg_attr(docsrs, doc(cfg(not(feature = "neovim-nightly"))))]
|
||||
#[serde(default)]
|
||||
pub hl_group: Option<String>,
|
||||
|
||||
#[cfg(feature = "neovim-nightly")] // Only on Nightly.
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "neovim-nightly")))]
|
||||
#[serde(default)]
|
||||
pub hl_group: Option<super::OneOrMore<String>>,
|
||||
|
||||
#[serde(default)]
|
||||
pub hl_mode: Option<ExtmarkHlMode>,
|
||||
|
||||
|
|
|
@ -24,3 +24,12 @@ impl From<&str> for OneOrMore<String> {
|
|||
OneOrMore::One(s.to_owned())
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: PartialEq> PartialEq<T> for OneOrMore<T> {
|
||||
fn eq(&self, other: &T) -> bool {
|
||||
match self {
|
||||
OneOrMore::One(one) => one == other,
|
||||
OneOrMore::List(_) => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue