feat: Per-tabpage outlines

Closes #37

Almost completely refactored the UI parts outline.nvim to use a Sidebar
object that implements an outline window. In init.lua, we can then store
a table of the outline for each tabpage ID.

When tabs are closed the outline is closed and sidebar reset
responsibly.

This simplifies `init.lua` quite a lot, making it the highest level
control center for the outline elements.

All lua APIs and commands should work as before.
This commit is contained in:
hedy
2023-11-24 14:50:24 +08:00
parent 83dc477af5
commit e705330e40
9 changed files with 754 additions and 600 deletions

View File

@@ -1,8 +1,9 @@
local cfg = require('outline.config')
---@class outline.View
local View = {}
---@class View
---@class outline.View
---@field bufnr integer
---@field winnr integer
@@ -46,7 +47,8 @@ function View:setup_view(split_command)
-- mess with other theme/user settings. So just use empty spaces for now.
vim.api.nvim_win_set_option(self.winnr, 'showbreak', ' ') -- only has effect when wrap=true.
-- buffer stuff
vim.api.nvim_buf_set_name(self.bufnr, 'OUTLINE')
local tab = vim.api.nvim_get_current_tabpage()
vim.api.nvim_buf_set_name(self.bufnr, 'OUTLINE_'..tostring(tab))
vim.api.nvim_buf_set_option(self.bufnr, 'filetype', 'Outline')
vim.api.nvim_buf_set_option(self.bufnr, 'modifiable', false)