mirror of
https://github.com/noib3/nvim-oxi.git
synced 2025-07-07 13:25:18 +00:00
fix(api): allow Buffer::get_extmarks()
to get extmarks from all namespaces (#256)
This commit is contained in:
parent
3bbb551c0f
commit
5ee2096e70
4 changed files with 38 additions and 4 deletions
|
@ -12,6 +12,11 @@
|
|||
- `nvim_oxi::api::KeymapInfos::buffer` is now an `Option<Buffer>` instead of
|
||||
a `bool` ([#255](https://github.com/noib3/nvim-oxi/pull/255));
|
||||
|
||||
- `nvim_oxi::api::Buffer::get_extmarks()` now takes an
|
||||
`impl Into<GetExtmarksNamespaceId>` as its first argument instead of a `u32`.
|
||||
Because `GetExtmarksNamespaceId` implements `From<u32>`, this should be an
|
||||
API-compatible change ([#256](https://github.com/noib3/nvim-oxi/pull/256));
|
||||
|
||||
### Fixed
|
||||
|
||||
- fixed the definition of `DecorationProviderOpts`, which was causing
|
||||
|
|
|
@ -195,20 +195,20 @@ impl Buffer {
|
|||
/// was set to `true`.
|
||||
///
|
||||
/// [1]: https://neovim.io/doc/user/api.html#nvim_buf_get_extmarks()
|
||||
pub fn get_extmarks(
|
||||
pub fn get_extmarks<NsId: Into<GetExtmarksNamespaceId>>(
|
||||
&self,
|
||||
ns_id: u32,
|
||||
ns_id: NsId,
|
||||
start: ExtmarkPosition,
|
||||
end: ExtmarkPosition,
|
||||
opts: &GetExtmarksOpts,
|
||||
) -> Result<
|
||||
impl SuperIterator<(u32, usize, usize, Option<ExtmarkInfos>)> + use<>,
|
||||
impl SuperIterator<(u32, usize, usize, Option<ExtmarkInfos>)> + use<NsId>,
|
||||
> {
|
||||
let mut err = nvim::Error::new();
|
||||
let extmarks = unsafe {
|
||||
nvim_buf_get_extmarks(
|
||||
self.0,
|
||||
ns_id as Integer,
|
||||
ns_id.into().into(),
|
||||
start.into(),
|
||||
end.into(),
|
||||
opts,
|
||||
|
|
27
crates/api/src/types/get_extmarks_namespace_id.rs
Normal file
27
crates/api/src/types/get_extmarks_namespace_id.rs
Normal file
|
@ -0,0 +1,27 @@
|
|||
/// Namespace selector given to
|
||||
/// [`Buffer::get_extmarks`](crate::Buffer::get_extmarks).
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||
pub enum GetExtmarksNamespaceId {
|
||||
/// Get extmarks from all namespaces.
|
||||
All,
|
||||
|
||||
/// Only get extmarks registered on the namespace with this ID.
|
||||
Specific(u32),
|
||||
}
|
||||
|
||||
impl From<u32> for GetExtmarksNamespaceId {
|
||||
#[inline]
|
||||
fn from(namespace_id: u32) -> Self {
|
||||
Self::Specific(namespace_id)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<GetExtmarksNamespaceId> for types::Integer {
|
||||
#[inline]
|
||||
fn from(namespace_id: GetExtmarksNamespaceId) -> Self {
|
||||
match namespace_id {
|
||||
GetExtmarksNamespaceId::All => -1,
|
||||
GetExtmarksNamespaceId::Specific(id) => id as Self,
|
||||
}
|
||||
}
|
||||
}
|
|
@ -21,6 +21,7 @@ mod extmark_infos;
|
|||
mod extmark_position;
|
||||
mod extmark_virt_text_chunk;
|
||||
mod extmark_virt_text_position;
|
||||
mod get_extmarks_namespace_id;
|
||||
mod get_hl_infos;
|
||||
mod got_mode;
|
||||
mod highlight_infos;
|
||||
|
@ -73,6 +74,7 @@ pub use extmark_infos::*;
|
|||
pub use extmark_position::*;
|
||||
pub use extmark_virt_text_chunk::*;
|
||||
pub use extmark_virt_text_position::*;
|
||||
pub use get_extmarks_namespace_id::GetExtmarksNamespaceId;
|
||||
pub use get_hl_infos::GetHlInfos;
|
||||
pub use got_mode::*;
|
||||
pub use highlight_infos::*;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue