Skip to content

Commit ffcaa03

Browse files
committed
[Chore] upgrade nvim-oxi to v0.5.1
1 parent 87b2770 commit ffcaa03

File tree

7 files changed

+90
-170
lines changed

7 files changed

+90
-170
lines changed

Diff for: generator/Cargo.lock

+63-146
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: generator/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.1.0"
44
edition = "2021"
55

66
[dependencies]
7-
nvim-oxi = { features = ["neovim-0-9", "libuv", "oxi-libuv"], version = "0.3" }
7+
nvim-oxi = { features = ["neovim-0-9", "libuv"], version = "0.5.1" }
88
tiny-skia = "0.11.4"
99
syntect = "5.2.0"
1010
cosmic-text = "0.12.0"

Diff for: generator/src/components/interface/render_error.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use nvim_oxi::lua;
21
use thiserror::Error;
32

43
pub type Result<T> = std::result::Result<T, RenderError>;
@@ -21,8 +20,8 @@ pub enum RenderError {
2120
NoSuchFile(String),
2221
}
2322

24-
impl From<RenderError> for nvim_oxi::Error {
23+
impl From<RenderError> for nvim_oxi::api::Error {
2524
fn from(err: RenderError) -> Self {
26-
nvim_oxi::Error::Lua(lua::Error::RuntimeError(err.to_string()))
25+
nvim_oxi::api::Error::Other(err.to_string())
2726
}
2827
}

Diff for: generator/src/copy.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ use crate::{config::TakeSnapshotParams, snapshot::take_snapshot};
33
use arboard::SetExtLinux;
44
use arboard::{Clipboard, ImageData};
55

6-
use nvim_oxi::Result;
6+
use nvim_oxi::api;
77

88
// The function will be called as FFI on Lua side
99
#[allow(dead_code)]
10-
pub fn copy_into_clipboard(config: TakeSnapshotParams) -> Result<()> {
10+
pub fn copy_into_clipboard(config: TakeSnapshotParams) -> Result<(), api::Error> {
1111
let pixmap = take_snapshot(config.clone())?;
1212
let premultplied_colors = pixmap.pixels();
1313
let colors = premultplied_colors

Diff for: generator/src/copy_ascii.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::{
55
use arboard::Clipboard;
66
#[cfg(target_os = "linux")]
77
use arboard::SetExtLinux;
8-
use nvim_oxi::Result;
8+
use nvim_oxi::api;
99
use std::cmp::max;
1010

1111
const SPACE_BOTH_SIDE: usize = 2;
@@ -19,7 +19,7 @@ fn optional(component: String, is_view: bool) -> String {
1919
}
2020

2121
#[allow(dead_code)]
22-
pub fn copy_ascii(params: TakeSnapshotParams) -> Result<()> {
22+
pub fn copy_ascii(params: TakeSnapshotParams) -> Result<(), api::Error> {
2323
let code = prepare_code(&params.code);
2424
let (width, height) = calc_wh(&code, 1., 1.);
2525
let calc_line_number_width =
@@ -71,7 +71,10 @@ pub fn copy_ascii(params: TakeSnapshotParams) -> Result<()> {
7171
});
7272

7373
#[cfg(not(target_os = "linux"))]
74-
Clipboard::new().unwrap().set_text(ascii_snapshot).unwrap();
74+
Clipboard::new()
75+
.unwrap()
76+
.set_text(ascii_snapshot)
77+
.map_err(|err| api::Error::Other(err.to_string()))?;
7578

7679
Ok(())
7780
}

Diff for: generator/src/lib.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,19 @@ mod save;
1111
mod snapshot;
1212
mod text;
1313

14+
use config::TakeSnapshotParams;
1415
use copy::copy_into_clipboard;
1516
use copy_ascii::copy_ascii;
16-
use nvim_oxi::{Dictionary, Function, Result};
17+
use nvim_oxi::{api, Dictionary, Function};
1718
use save::save_snapshot;
1819

19-
#[nvim_oxi::module]
20-
fn generator() -> Result<Dictionary> {
20+
#[nvim_oxi::plugin]
21+
fn generator() -> nvim_oxi::Result<Dictionary> {
22+
let copy_into_clipboard: Function<TakeSnapshotParams, Result<(), api::Error>> =
23+
Function::from_fn(copy_into_clipboard);
24+
2125
Ok(Dictionary::from_iter([
22-
(
23-
"copy_into_clipboard",
24-
Function::from_fn(copy_into_clipboard),
25-
),
26+
("copy_into_clipboard", copy_into_clipboard),
2627
("save_snapshot", Function::from_fn(save_snapshot)),
2728
("copy_ascii", Function::from_fn(copy_ascii)),
2829
]))

0 commit comments

Comments
 (0)