Code Monkey home page Code Monkey logo

blog's People

Contributors

dependabot[bot] avatar kdheepak avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

zhao-ding

blog's Issues

38-rust-lua-nvim.md instructions don't work as specified on MacOs

Hello! First off, I want to say that I love the blog post! It's such an exciting way to write plugins and I had no idea about the lua C abi bindings in such detail before. I have run into a bit of a snag though it's probably just due to my own ignorance.

I'm running MacOs 10.15.7, and after following the instructions I wasn't able to get the plugin to compile.
My steps were

  1. cargo new --lib rust_plugin_test
  2. add
[lib]
crate-type = ["cdylib"]

[dependencies]
mlua = {version = "*", features = ["luajit", "vendored", "module", "macros"]}

to my cargo.toml
3. Replace my src/lib.rs with

use mlua::chunk;
use mlua::prelude::*;

fn hello(lua: &Lua, name: String) -> LuaResult<LuaTable> {
    let t = lua.create_table()?;
    t.set("name", name.clone())?;
    let _globals = lua.globals();
    lua.load(chunk! {
        print("hello, " .. $name)
    })
    .exec()?;
    Ok(t)
}

#[mlua::lua_module]
fn moonshine(lua: &Lua) -> LuaResult<LuaTable> {
    let exports = lua.create_table()?;
    exports.set("hello", lua.create_function(hello)?)?;
    Ok(exports)
}

  1. Since there is no ~/.cargo/config file by default I touch .cargo/config
  2. copy
[target.x86_64-apple-darwin]
rustflags = [
  "-C", "link-arg=-undefined",
  "-C", "link-arg=dynamic_lookup",
]

[target.aarch64-apple-darwin]
rustflags = [
  "-C", "link-arg=-undefined",
  "-C", "link-arg=dynamic_lookup",
]

into ~/.cargo/config
6. Finally I run cargo build --release && mv target/release/libmoonshine.dylib lua/moonshine.so
The output of which is

mv: rename target/release/libmoonshine.dylib to lua/moonshine.so: No such file or directory

I'm sure I'm missing something obvious, and if I am I'm very sorry.

Thanks again for your time!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.