Shougo / defx.nvim

:file_folder: The dark powered file explorer implementation for neovim/Vim8
MIT License
1.17k stars 86 forks source link

Question: Is Defx buffer open ? #301

Closed thecontinium closed 3 years ago

thecontinium commented 3 years ago

Hi

When I open defx I am using the -buffer-name={buffer-name} option and then use that buffer-name to identify whether the buffer is open using bufwinnr

I see that in view.py you embellish the buffer name with:

self._bufname = f'[defx] {self._context.buffer_name}-{self._index}

I suspect I am missing the full picture here because I'm not sure what the _index is appended at the end ? It seems you can have more than one defx buffer for the same name ?

So I can try and "construct" this name in the same way but I am not sure what the index is appended at the end.

Is there a way to get the above embellished name to that given in the -buffer-name option ? or a defx function that can tell me whether the defx buffer is showing for a given buffer-name ?

Thanks in advance.

Shougo commented 3 years ago

I suspect I am missing the full picture here because I'm not sure what the _index is appended at the end ?n. It seems you can have more than one defx buffer for the same name ?

Yes. Because you can create multiple buffer name defxs by -new option.

Shougo commented 3 years ago

Is there a way to get the above embellished name to that given in the -buffer-name option ? or a defx function that can tell me whether the defx buffer is showing for a given buffer-name ?

No. Because it is internal feature. It is not documented and may be changed in the later version. You should get the name by bufname() instead.

thecontinium commented 3 years ago

ok - cheers

Shougo commented 3 years ago

If you need to check the buffer, you should check defx#get_context() in defx window or b:defx variable.

thecontinium commented 3 years ago

ah! - that will help; thanks