Closed airtonix closed 1 year ago
Thanks, can you adjust the code to use the same conventions we use in this repo? In particular:
snake_case
And I'm wondering if we should add examples for each tree plugin, or maybe keep them in an examples/
folder and link to them.
Before merging, I want to double check that nvim_create_autocmd
doesn't expose the information being worked around in get_filetree_window
. Iirc it does, but we'll see
examples folder
Not a bad idea. It would also let the LSP attach when adjusting the examples,which prevents syntax errors.
I think there should be one examples/general.lua
for the common case (e.g. NvimTree, neo-tree) since they seem to be compatible.
@airtonix I've taken a look, and it seems nvim_create_command
puts out the information you need to do resizing. Here's what you can put into the README:
vim.api.nvim_create_autocmd('FileType', {
callback = function(tbl)
local api = require'bufferline.api'
local autocmd = vim.api.nvim_create_autocmd('WinScrolled', {
buffer = tbl.buf,
callback = function()
local width = vim.api.nvim_win_get_width(vim.fn.bufwinid(tbl.buf))
api.set_offset(width, 'FileTree')
end,
})
vim.api.nvim_create_autocmd('BufWipeout', {
buffer = tbl.buf,
callback = function()
vim.api.nvim_del_autocmd(autocmd)
api.set_offset(0)
end,
once = true,
})
end,
pattern = 'NvimTree', -- or any other filetree's `&ft`
})
This implementation is actually more performant than the existing one, since it registers buf-local or pattern
ed autocmds (instead of a global autocmd for every buffer created). It also destroys autocmds when the tree is closed
Thank you!
NvimTree and neo-tree are both resizable, this just shows how a user can get that information and use it.
fixes #373
Screencast from 2023-03-02 17-21-53.webm