Giter Club home page Giter Club logo

Comments (6)

noib3 avatar noib3 commented on May 27, 2024

The two main reasons are:

  • performance: when using mlua you're calling the Neovim Lua api, i.e. Lua bindings to the C api. This means that all the Rust values are first converted to Lua values, then you call the Lua api, then Neovim converts those values back to C.

Since all the Neovim C functions are exported we can avoid all of that by hooking straight into the C api via ffi, effectively turning

Rust -> Lua, Lua -> C

into

Rust -> C
  • integration: mlua is a fantastic crate, but it is a general purpose one. I believe there's a lot of value in having a more vertically integrated framework that's tailored specifically to Neovim, allowing you to take full advantage of Rust's type system. Examples are still scarce since nvim-oxi is still far from ready but you'll see what I mean.

from nvim-oxi.

maan2003 avatar maan2003 commented on May 27, 2024

I didn't explain the question properly. I understand using neovim C functions directly.

But I don't understand why we are using lua C function directly (in nvim-oxi/src/lua). It is hard to get correct and just creates additional work.

from nvim-oxi.

noib3 avatar noib3 commented on May 27, 2024

we are using lua C function directly (in nvim-oxi/src/lua)

We don't? I'm not sure what you mean by "lua C function". Could you link the module/line?

from nvim-oxi.

maan2003 avatar maan2003 commented on May 27, 2024

these

extern "C" {
// https://www.lua.org/manual/5.1/manual.html#lua_call
pub(crate) fn lua_call(L: *mut lua_State, nargs: c_int, nresults: c_int);
// https://www.lua.org/manual/5.1/manual.html#lua_createtable
pub(crate) fn lua_createtable(L: *mut lua_State, narr: c_int, nrec: c_int);
// https://www.lua.org/manual/5.1/manual.html#lua_error
pub(crate) fn lua_error(L: *mut lua_State) -> !;

from nvim-oxi.

noib3 avatar noib3 commented on May 27, 2024

Yes, those are needed.

from nvim-oxi.

maan2003 avatar maan2003 commented on May 27, 2024

Yes, those are needed.

Yes that is question, why deal with unsafe ffi ourselves, instead of using mlua in module mode.

from nvim-oxi.

Related Issues (20)

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.