Can't find buffer number from `Buffer`
patata3000 opened this issue · 6 comments
Hey! Me again, It's hard to get the buffer number from a Buffer
. I did this:
let buf_nbr: Object = buffer.clone().into();
let buf_nbr = unsafe { buf_nbr.as_integer_unchecked() as i32 };
But I guess that we could have a the id directly from the Buffer
struct. Am I missing something?
There's currently no public method to get the inner BufHandle
. What's your use case?
I need it to call another vim function that uses the buffer id
let buffer = create_buf(true, false)?;
let buf_nbr: Object = buffer.clone().into();
let buf_nbr = unsafe { buf_nbr.as_integer_unchecked() as i32 };
let vim: LuaTable = lua.globals().get("vim")?;
let api: LuaTable = vim.get("api")?;
let set_buf_keymap: LuaFunction = api.get("nvim_buf_set_keymap")?;
let result = set_buf_keymap.call::<_, ()>((buf_nbr, mode, key, rhs, options));
That's not necessary, we have bindings to all the vim.api
functions in the api
module. Try Buffer::set_keymap()
instead.
Oh! Thank you! And thank you for nvim oxi, you rock! ❤️
Hello, I just got upon something I cannot handle really easily because I don't have access to the buffer id. I'm making a plugin that needs to store the opened buffer it created. There may be a workaround but I cannot find it.