fix: Ignore special buffers, fix auto-preview and not focus_on_open

This commit is contained in:
hedy
2023-11-30 10:17:00 +08:00
parent 4bbecbb92e
commit a5411b0a0c
3 changed files with 21 additions and 17 deletions

View File

@@ -105,6 +105,9 @@ function Sidebar:initial_handler(response, opts)
self.items = items
self:_update_lines(true)
if not cfg.o.outline_window.focus_on_open or not opts.focus_outline then
vim.fn.win_gotoid(self.code.win)
end
end
-- stylua: ignore start
@@ -325,10 +328,17 @@ end
---Re-request symbols from provider
function Sidebar:__refresh()
local focused_outline = self.view.buf == vim.api.nvim_get_current_buf()
local buf = vim.api.nvim_get_current_buf()
local focused_outline = self.view.buf == buf
if focused_outline or not self.view:is_open() then
return
end
local ft = vim.api.nvim_buf_get_option(buf, 'ft')
local nolisted = vim.api.nvim_buf_get_option(buf, 'buflisted')
local hidden = vim.api.nvim_buf_get_option(buf, 'bufhidden')
if ft == 'OutlineHelp' or nolisted or hidden then
return
end
self.provider = providers.find_provider()
if self.provider then
self.provider.request_symbols(function(res)
@@ -551,6 +561,7 @@ function Sidebar:open(opts)
self.provider.request_symbols(function(...)
self:initial_handler(...)
end, opts)
return
else
-- No provider
self:initial_setup(opts)