vim-hug-neovim-rpc
vim-hug-neovim-rpc copied to clipboard
nvim_buf_get_lines not working
Hey!
I've been messing with this, and hit a weird bug where if I called nvim.api.buf_set_lines, I got back the error pynvim.api.nvim.NvimError: b"object of type 'int' has no len()".
This was when calling it with 0, 0, -1, True.
Looking at the code for nvim_buf_get_lines and set lines, it looks like the first argument buffer is treated as the buffer, rather than the buffer index, as implied by the nvim docs :
Parameters:
{buffer} Buffer handle, or 0 for current buffer
Or over in
EXT Type C type Data
------------------------------------------------------------------------
Buffer enum value kObjectTypeBuffer |bufnr()|
I could be entirely wrong, and my code is just working oddly, but if I add in a buffer_contents = vim.buffers[buffer] (or I guess vim.current.buffer for buffer == 0) and then use buffer_contents rather than buffer, the set and get work as expected.
Is that expected, or am I just using the function wrong?