Skip to content

Commit

Permalink
Merge pull request #110 from willothy/inline-virt-text
Browse files Browse the repository at this point in the history
feat(nightly): support inline virtual text
  • Loading branch information
noib3 authored Dec 15, 2023
2 parents c1a89ca + 3532e1b commit 9e4689a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

- a new `ExtmarkVirtTextChunk` struct;

- an `Inline` variant to the `ExtmarkVirtTextPosition` enum when building for
`neovim-nightly`;

### Changed

- the type of `ExtmarkInfos`'s `virt_text` field from
Expand Down
8 changes: 8 additions & 0 deletions crates/oxi-api/src/types/extmark_virt_text_position.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ pub enum ExtmarkVirtTextPosition {

/// Display right aligned in the window.
RightAlign,

/// Display at the specified column, and shift the buffer text to the right
/// as needed.
#[cfg(feature = "neovim-nightly")]
#[cfg_attr(docsrs, doc(cfg(feature = "neovim-nightly")))]
Inline,
}

impl From<ExtmarkVirtTextPosition> for nvim::String {
Expand All @@ -25,6 +31,8 @@ impl From<ExtmarkVirtTextPosition> for nvim::String {
Eol => "eol",
Overlay => "overlay",
RightAlign => "right_align",
#[cfg(feature = "neovim-nightly")]
Inline => "inline",
})
}
}
25 changes: 25 additions & 0 deletions tests/src/api/extmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,28 @@ fn set_get_del_extmark() {
let res = buf.del_extmark(ns_id, extmark_id);
assert_eq!(Ok(()), res);
}

#[cfg(feature = "neovim-nightly")]
#[oxi::test]
fn virt_text_pos_inline() {
let mut buf = Buffer::current();

let ns_id = api::create_namespace("test");

let opts = SetExtmarkOpts::builder()
.virt_text([("", "")])
.virt_text_pos(ExtmarkVirtTextPosition::Inline)
.build();

let extmark_id = buf.set_extmark(ns_id, 0, 0, &opts).unwrap();

let opts = GetExtmarkByIdOpts::builder().details(true).build();

let Ok((_, _, Some(infos))) =
buf.get_extmark_by_id(ns_id, extmark_id, &opts)
else {
unreachable!()
};

assert_eq!(infos.virt_text_pos, Some(ExtmarkVirtTextPosition::Inline));
}

0 comments on commit 9e4689a

Please sign in to comment.