Skip to content

Commit

Permalink
Merge pull request #188 from noib3/fix-highlight-opts
Browse files Browse the repository at this point in the history
Add `url` to `SetHighlightOpts`
  • Loading branch information
noib3 authored Oct 7, 2024
2 parents 101f2be + 20a7934 commit b986c49
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 11 deletions.
5 changes: 4 additions & 1 deletion crates/api/src/opts/set_highlight.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use types::Object;
#[cfg(feature = "neovim-0-10")] // On 0.10 and nightly.
use types::{Boolean, Integer};
use types::{Boolean, Integer, String as NvimString};

#[cfg(feature = "neovim-0-10")] // On 0.10 and nightly.
#[derive(Clone, Debug, Default, PartialEq, macros::OptsBuilder)]
Expand Down Expand Up @@ -98,6 +98,9 @@ pub struct SetHighlightOpts {

#[builder(argtype = "bool")]
force: Boolean,

#[builder(skip)]
url: NvimString,
}

/// Options passed to [`set_hl()`](crate::set_hl).
Expand Down
2 changes: 1 addition & 1 deletion crates/api/src/types/command_range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl<'de> de::Deserialize<'de> for CommandRange {
{
struct CommandRangeVisitor;

impl<'de> de::Visitor<'de> for CommandRangeVisitor {
impl de::Visitor<'_> for CommandRangeVisitor {
type Value = CommandRange;

fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result {
Expand Down
6 changes: 3 additions & 3 deletions crates/macros/src/derive_opts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl<'a> From<&'a DeriveInput> for OptsBuilder<'a> {
}
}

impl<'a> OptsBuilder<'a> {
impl OptsBuilder<'_> {
/// Returns the `impl Clone` block for the builder.
#[inline]
fn impl_clone(&self) -> TokenStream {
Expand Down Expand Up @@ -187,7 +187,7 @@ impl<'a> TryFrom<&'a DeriveInput> for OptsFields<'a> {
}
}

impl<'a> OptsFields<'a> {
impl OptsFields<'_> {
#[inline]
fn setters(&self) -> impl Iterator<Item = TokenStream> + '_ {
self.fields.iter().filter_map(|field| field.setter(self.mask_name))
Expand Down Expand Up @@ -249,7 +249,7 @@ impl<'a> TryFrom<&'a Field> for OptsField<'a> {
}
}

impl<'a> OptsField<'a> {
impl OptsField<'_> {
/// TODO: docs
#[inline]
fn setter(&self, mask_name: Option<&Ident>) -> Option<TokenStream> {
Expand Down
2 changes: 1 addition & 1 deletion crates/types/src/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ mod serde {

struct FunctionVisitor<A, R>(PhantomData<A>, PhantomData<R>);

impl<'de, A, R> Visitor<'de> for FunctionVisitor<A, R> {
impl<A, R> Visitor<'_> for FunctionVisitor<A, R> {
type Value = Function<A, R>;

fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result {
Expand Down
6 changes: 3 additions & 3 deletions crates/types/src/non_owning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ pub struct NonOwning<'a, T> {
lt: PhantomData<&'a ()>,
}

impl<'a, T> NonOwning<'a, T> {
impl<T> NonOwning<'_, T> {
pub const fn new(value: T) -> Self {
Self { inner: ManuallyDrop::new(value), lt: PhantomData }
}
}

impl<'a, T> core::fmt::Debug for NonOwning<'a, T>
impl<T> core::fmt::Debug for NonOwning<'_, T>
where
T: core::fmt::Debug,
{
Expand All @@ -27,7 +27,7 @@ where
}
}

impl<'a, T> Default for NonOwning<'a, T>
impl<T> Default for NonOwning<'_, T>
where
T: Default,
{
Expand Down
2 changes: 1 addition & 1 deletion crates/types/src/serde/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ impl Deserializer {
}
}

impl<'de> IntoDeserializer<'de, DeserializeError> for Object {
impl IntoDeserializer<'_, DeserializeError> for Object {
type Deserializer = Deserializer;

#[inline]
Expand Down
2 changes: 1 addition & 1 deletion crates/types/src/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ mod serde {
{
struct StringVisitor;

impl<'de> Visitor<'de> for StringVisitor {
impl Visitor<'_> for StringVisitor {
type Value = crate::String;

fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result {
Expand Down
13 changes: 13 additions & 0 deletions tests/src/api/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,19 @@ fn get_runtime_file() {
assert!(api::get_runtime_file("*", true).unwrap().next().is_some());
}

#[oxi::test]
fn hl_foreground() {
let opts = SetHighlightOpts::builder()
.foreground("#FF0000")
.strikethrough(true)
.bold(true)
.build();
api::set_hl(0, "Header", &opts).unwrap();

let infos = api::get_hl_by_name("Header", true).unwrap();
assert_eq!(infos.foreground, Some(16711680));
}

#[oxi::test]
fn hl_underline() {
let opts = SetHighlightOpts::builder().underline(true).build();
Expand Down

0 comments on commit b986c49

Please sign in to comment.