If I open a file via the command-line, then I can call vim.api.nvim_buf_get_name(0) within a formatter to get the current buffer name, it works.
If I use :tabedit to or :edit to open a file later, then it returns the empty string "" if neovim was opened with no file, or the path to the initially opened file.
To reproduce:
- Open
nvim without any files.
- Use
:edit <file> to open a new file where util.get_current_buffer_file_path() is used in the formatting configuration.
- Try to write it.
- Notice that the formatting will fail since the empty string will be passed as an argument and vanish.
This is because the config setup is only run once.
If I open a file via the command-line, then I can call
vim.api.nvim_buf_get_name(0)within a formatter to get the current buffer name, it works.If I use
:tabeditto or:editto open a file later, then it returns the empty string""if neovim was opened with no file, or the path to the initially opened file.To reproduce:
nvimwithout any files.:edit <file>to open a new file whereutil.get_current_buffer_file_path()is used in the formatting configuration.This is because the config setup is only run once.