Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't find buffer number from Buffer #138

Closed
patata3000 opened this issue Feb 21, 2024 · 6 comments
Closed

Can't find buffer number from Buffer #138

patata3000 opened this issue Feb 21, 2024 · 6 comments

Comments

@patata3000
Copy link

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?

@noib3
Copy link
Owner

noib3 commented Feb 22, 2024

There's currently no public method to get the inner BufHandle. What's your use case?

@patata3000
Copy link
Author

patata3000 commented Feb 23, 2024

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));

@noib3
Copy link
Owner

noib3 commented Feb 23, 2024

That's not necessary, we have bindings to all the vim.api functions in the api module. Try Buffer::set_keymap() instead.

@patata3000
Copy link
Author

Oh! Thank you! And thank you for nvim oxi, you rock! ❤️

@patata3000 patata3000 reopened this Apr 2, 2024
@patata3000
Copy link
Author

patata3000 commented Apr 2, 2024

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.

@noib3
Copy link
Owner

noib3 commented Jun 14, 2024

Closed by #176.

@noib3 noib3 closed this as completed Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants