Skip to content

Commit 9197625

Browse files
committed
Merge remote-tracking branch 'upstream/main' into string-macro
2 parents db11076 + 39b84fe commit 9197625

35 files changed

+213
-209
lines changed

CHANGELOG.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,27 @@
22

33
## [Unreleased]
44

5+
### Added
6+
7+
- a `String::to_str()` method which returns a `&str` if the string contains
8+
valid UTF-8 data;
9+
10+
- a `WindowConfig::mouse` field and a `WindowOptsBuilder::mouse()` method
11+
on nightly ([#189](https://github.com/noib3/nvim-oxi/pull/189));
12+
13+
### Changed
14+
15+
- `nvim_oxi::api::echo` is now generic over the highlight group type instead of
16+
expecting a string slice;
17+
18+
- renamed the `lua_<Foo>` types to `<Foo>`;
19+
520
## [0.5.1] - June 23 2024
621

722
### Added
823

924
- a `handle` method on `Buffer`, `Window`, and `TabPage` which returns the
10-
underlying handle ([#176](https://github.com/noib3/nvim-oxi/pull/176));
25+
underlying handle ([#176](https://github.com/noib3/nvim-oxi/pull/176));
1126

1227
### Removed
1328

@@ -66,7 +81,7 @@
6681
## [0.4.0] - Dec 11 2023
6782

6883
[Unreleased]: https://github.com/noib3/nvim-oxi/compare/v0.5.1...HEAD
69-
[0.5.0]: https://github.com/noib3/nvim-oxi/tree/v0.5.1
84+
[0.5.1]: https://github.com/noib3/nvim-oxi/tree/v0.5.1
7085
[0.5.0]: https://github.com/noib3/nvim-oxi/tree/v0.5.0
7186
[0.4.2]: https://github.com/noib3/nvim-oxi/tree/v0.4.2
7287
[0.4.1]: https://github.com/noib3/nvim-oxi/tree/v0.4.1

crates/api/src/buffer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl FromObject for Buffer {
7171

7272
impl Poppable for Buffer {
7373
unsafe fn pop(
74-
lstate: *mut lua::ffi::lua_State,
74+
lstate: *mut lua::ffi::State,
7575
) -> std::result::Result<Self, lua::Error> {
7676
BufHandle::pop(lstate).map(Into::into)
7777
}
@@ -80,7 +80,7 @@ impl Poppable for Buffer {
8080
impl Pushable for Buffer {
8181
unsafe fn push(
8282
self,
83-
lstate: *mut lua::ffi::lua_State,
83+
lstate: *mut lua::ffi::State,
8484
) -> std::result::Result<std::ffi::c_int, lua::Error> {
8585
self.0.push(lstate)
8686
}

crates/api/src/ffi/buffer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ extern "C" {
8383
strict_indexing: bool,
8484
#[cfg(feature = "neovim-0-10")] // On 0.10 and nightly.
8585
arena: *mut Arena,
86-
lstate: *mut luajit::ffi::lua_State,
86+
lstate: *mut luajit::ffi::State,
8787
err: *mut Error,
8888
) -> Array;
8989

@@ -124,7 +124,7 @@ extern "C" {
124124
opts: *const GetTextOpts,
125125
#[cfg(feature = "neovim-0-10")] // On 0.10 and nightly.
126126
arena: *mut Arena,
127-
lstate: *mut luajit::ffi::lua_State,
127+
lstate: *mut luajit::ffi::State,
128128
err: *mut Error,
129129
) -> Array;
130130

crates/api/src/opts/set_highlight.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use types::Object;
22
#[cfg(feature = "neovim-0-10")] // On 0.10 and nightly.
3-
use types::{Boolean, Integer};
3+
use types::{Boolean, Integer, String as NvimString};
44

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

9999
#[builder(argtype = "bool")]
100100
force: Boolean,
101+
102+
#[builder(skip)]
103+
url: NvimString,
101104
}
102105

103106
/// Options passed to [`set_hl()`](crate::set_hl).

crates/api/src/tabpage.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl From<TabPage> for Object {
4646

4747
impl Poppable for TabPage {
4848
unsafe fn pop(
49-
lstate: *mut lua::ffi::lua_State,
49+
lstate: *mut lua::ffi::State,
5050
) -> std::result::Result<Self, lua::Error> {
5151
TabHandle::pop(lstate).map(Into::into)
5252
}
@@ -55,7 +55,7 @@ impl Poppable for TabPage {
5555
impl Pushable for TabPage {
5656
unsafe fn push(
5757
self,
58-
lstate: *mut lua::ffi::lua_State,
58+
lstate: *mut lua::ffi::State,
5959
) -> std::result::Result<std::ffi::c_int, lua::Error> {
6060
self.0.push(lstate)
6161
}

crates/api/src/trait_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ impl HlGroup for &str {
163163
let hl_id = unsafe {
164164
crate::ffi::helpers::object_to_hl_id(
165165
obj,
166-
b"hl_group\0".as_ptr() as *const _,
166+
c"hl_group".as_ptr() as *const _,
167167
&mut err,
168168
)
169169
};

crates/api/src/types/autocmd_callback_args.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl FromObject for AutocmdCallbackArgs {
4747

4848
impl luajit::Poppable for AutocmdCallbackArgs {
4949
unsafe fn pop(
50-
lstate: *mut luajit::ffi::lua_State,
50+
lstate: *mut luajit::ffi::State,
5151
) -> Result<Self, luajit::Error> {
5252
let obj = Object::pop(lstate)?;
5353

crates/api/src/types/command_args.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl FromObject for CommandArgs {
5858

5959
impl luajit::Poppable for CommandArgs {
6060
unsafe fn pop(
61-
lstate: *mut luajit::ffi::lua_State,
61+
lstate: *mut luajit::ffi::State,
6262
) -> Result<Self, luajit::Error> {
6363
let obj = Object::pop(lstate)?;
6464

crates/api/src/types/command_range.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ impl<'de> de::Deserialize<'de> for CommandRange {
3535
{
3636
struct CommandRangeVisitor;
3737

38-
impl<'de> de::Visitor<'de> for CommandRangeVisitor {
38+
impl de::Visitor<'_> for CommandRangeVisitor {
3939
type Value = CommandRange;
4040

4141
fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result {

crates/api/src/types/window_config.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ pub struct WindowConfig {
7575
)]
7676
pub hide: Option<bool>,
7777

78+
#[cfg_attr(docsrs, doc(cfg(feature = "neovim-nightly")))]
79+
#[cfg(feature = "neovim-nightly")] // On 0.10 and nightly.
80+
#[serde(default)]
81+
pub mouse: bool,
82+
7883
/// If `true` then no buffer-related autocommand events such as `BufEnter`
7984
/// or `BufLeave` are fired when calling [`open_win`](crate::open_win).
8085
pub noautocmd: Option<bool>,
@@ -436,6 +441,9 @@ pub struct WindowOpts {
436441
bufpos: Array,
437442
external: Boolean,
438443
focusable: Boolean,
444+
#[cfg_attr(docsrs, doc(cfg(feature = "neovim-nightly")))]
445+
#[cfg(feature = "neovim-nightly")]
446+
mouse: Boolean,
439447
vertical: Boolean,
440448
zindex: Integer,
441449
border: Object,
@@ -501,6 +509,9 @@ impl From<&WindowConfig> for WindowOpts {
501509
builder.focusable(focusable);
502510
}
503511

512+
#[cfg(feature = "neovim-nightly")]
513+
builder.mouse(config.mouse);
514+
504515
if let Some(vertical) = config.vertical {
505516
builder.vertical(vertical);
506517
}
@@ -567,6 +578,8 @@ impl TryFrom<WindowOpts> for WindowConfig {
567578
footer_pos,
568579
height,
569580
hide,
581+
#[cfg(feature = "neovim-nightly")]
582+
mouse,
570583
noautocmd,
571584
relative,
572585
row,
@@ -639,6 +652,8 @@ impl TryFrom<WindowOpts> for WindowConfig {
639652
))?,
640653
height: deserialize(height)?,
641654
hide: deserialize(hide)?,
655+
#[cfg(feature = "neovim-nightly")]
656+
mouse,
642657
noautocmd: deserialize(noautocmd)?,
643658
relative,
644659
row: deserialize(row)?,

crates/api/src/vim.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,21 +116,22 @@ pub fn del_var(name: &str) -> Result<()> {
116116
/// Echoes a message to the Neovim message area.
117117
///
118118
/// [1]: https://neovim.io/doc/user/api.html#nvim_echo()
119-
pub fn echo<'hl, Text, Chunks>(
119+
pub fn echo<HlGroup, Text, Chunks>(
120120
chunks: Chunks,
121121
history: bool,
122122
opts: &EchoOpts,
123123
) -> Result<()>
124124
where
125-
Chunks: IntoIterator<Item = (Text, Option<&'hl str>)>,
125+
Chunks: IntoIterator<Item = (Text, Option<HlGroup>)>,
126126
Text: Into<nvim::String>,
127+
HlGroup: Into<nvim::String>,
127128
{
128129
let chunks = chunks
129130
.into_iter()
130131
.map(|(text, hlgroup)| {
131132
Array::from_iter([
132133
Object::from(text.into()),
133-
Object::from(hlgroup.map(|hl| hl.to_owned())),
134+
Object::from(hlgroup.map(Into::into)),
134135
])
135136
})
136137
.collect::<Array>();

crates/api/src/window.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl FromObject for Window {
6565

6666
impl Poppable for Window {
6767
unsafe fn pop(
68-
lstate: *mut lua::ffi::lua_State,
68+
lstate: *mut lua::ffi::State,
6969
) -> std::result::Result<Self, lua::Error> {
7070
WinHandle::pop(lstate).map(Into::into)
7171
}
@@ -74,7 +74,7 @@ impl Poppable for Window {
7474
impl Pushable for Window {
7575
unsafe fn push(
7676
self,
77-
lstate: *mut lua::ffi::lua_State,
77+
lstate: *mut lua::ffi::State,
7878
) -> std::result::Result<std::ffi::c_int, lua::Error> {
7979
self.0.push(lstate)
8080
}

crates/libuv/src/ffi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl crate::ProperLayout for uv_timer_t {}
4242
extern "C" {
4343
// https://github.com/luvit/luv/blob/master/src/luv.c#L751
4444
pub(crate) fn luv_loop(
45-
lua_state: *mut luajit::ffi::lua_State,
45+
lua_state: *mut luajit::ffi::State,
4646
) -> *mut uv_loop_t;
4747

4848
pub(crate) fn uv_async_init(

crates/libuv/src/loop.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use core::cell::OnceCell;
22

3-
use luajit::ffi::lua_State;
3+
use luajit::ffi::State;
44

55
use crate::ffi;
66

@@ -13,7 +13,7 @@ thread_local! {
1313
/// NOTE: this function **must** be called before calling any other function
1414
/// exposed by this crate or there will be segfaults.
1515
#[doc(hidden)]
16-
pub unsafe fn init(lua_state: *mut lua_State) {
16+
pub unsafe fn init(lua_state: *mut State) {
1717
LOOP.with(|uv_loop| uv_loop.set(ffi::luv_loop(lua_state)))
1818
.unwrap_unchecked();
1919
}

crates/luajit/src/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::ffi::c_int;
1+
use core::ffi::c_int;
22

33
use thiserror::Error as ThisError;
44

@@ -54,7 +54,7 @@ impl Error {
5454
}
5555

5656
pub unsafe fn pop_wrong_type_at_idx<T>(
57-
lstate: *mut crate::ffi::lua_State,
57+
lstate: *mut crate::ffi::State,
5858
idx: std::ffi::c_int,
5959
) -> Self {
6060
let expected = std::any::type_name::<T>();

0 commit comments

Comments
 (0)