barbar.nvim overriding the buffer name
Summary:
I can't get nvim to update the buffer name while I'm using the barbar.nvim extension, so I had to modify barbar.nvim.
Plugin is at ~/.local/share/nvim/plugged/barbar.nvim
I've modified barbar.nvim/lua/barbar/buffer.lua
:
function buffer.get_name(buffer_number, depth)
-- ...
full_name = fs.normalize(full_name)
--name = fs.slice_parts_from_end(full_name, depth)
local handle = io.popen("php /home/reed/data/config/nvim/set_title.php " .. full_name );
local result = handle:read("*a");
handle:close()
name = result
Now, I could try to figure out how to work with strings and paths in lua, but it is easier to call PHP, since that's what I know.
It's a jank and terrible solution. I don't care for it, but it WORKS and that's what matters.
Complaining
The typical means of setting a buffer name in neovim are NOT working with the barbar.nvim plugin. This would be, I think :let title="something"
or something to that effect. Maybe "titlename"? and maybe :set
instead of :let
. Either way, I tried them all and it doesn't work on my machine.
I think my solution is to just modify the barbar plugin. I could make my own fork or just document my change so its easy to repeat in the future. For now, I'm just documenting it because I'm sick of playing with it. I just want shit to work. But it doesn't, and I have other things to do. Wasted an hour on this shit.
Anyway.
Plugin is at ~/.local/share/nvim/plugged/barbar.nvim
The offending piece of code is in barbar.nvim/lua/barbar/buffer.lua
, and it is the function function buffer.get_name(buffer_number, depth)
To update the buffer name in the tab, I can do something like this:
// existing code
// ....
full_name = fs.normalize(full_name)
name = fs.slice_parts_from_end(full_name, depth)
// new code
local handle = io.popen("php /home/reed/data/config/nvim/set_title.php " .. name);
local result = handle:read("*a");
handle:close()
name = result
But this isn't quite working because my PHP script is not getting the full path to the file. I don't know why!