I am using Neovim 0.5 and want to write a custom function to use with telescope.nvim
.
I need to get the path of the file loaded in the current buffer before I can execute the function. I have been unable to find how to do this after reading the Neovim Lua API documentation.
So far I've found that vim.api.nvim_get_current_buf()
returns the current buffer number, but how do I get the full file path of the current buffer?
You can access the full path to the file in the current buffer using vim.api.nvim_buf_get_name(0)
, where 0
for buffer id means "the current buffer".
https://neovim.io/doc/user/api.html#nvim_buf_get_name()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With