Get The Buffer Number Of A Buffer In A Neovim Window With Lua
Getting The Buffer Number
Use this to get the buffer number of the buffer in a specific window:
Code
nvim_win_get_buf(WINDOW_NUMBER)
Where `WINDOW_NUMBER`` is the number of the window you want to get the buffer number for. It can be set to zero to get the buffer number of the current window.
To see the value on the command line, use:
Code
:echo nvim_win_get_buf(WINDOW_NUMBER)
The Current Window Number
You can find the window number of the current window with:
Code
nvim_get_current_win()
Which is used like this on the command line
Code
:echo nvim_get_current_win()