Merge pull request #131 from onion108/0.11-patch

fix: migrating to 0.11
This commit is contained in:
~hedy
2025-04-19 21:00:41 +08:00
committed by GitHub
15 changed files with 211 additions and 87 deletions

View File

@@ -1,3 +1,4 @@
syntax = 'Lua52'
column_width = 100
line_endings = 'Unix'
indent_type = 'Spaces'

View File

@@ -918,7 +918,8 @@ symbols = {
```lua
symbols = {
icon_fetcher = function(kind, bufnr, symbol)
local ft = vim.api.nvim_buf_get_option(bufnr, 'ft')
-- Use nvim_buf_get_option(bufnr, 'ft') for nvim 0.7 users
local ft = vim.api.nvim_get_option_value('ft', { buf = bufnr })
-- ...
end,
}
@@ -1112,7 +1113,8 @@ and `icons` as fallback.
```lua
symbols = {
icon_fetcher = function(kind, bufnr)
local ft = vim.api.nvim_buf_get_option(bufnr, 'ft')
-- Use nvim_buf_get_option(bufnr, 'ft') for nvim 0.7 users
local ft = vim.api.nvim_get_option_value('ft', { buf = bufnr })
-- ...
end,
}
@@ -1152,7 +1154,8 @@ other filetypes.
```lua
symbols = {
icon_fetcher = function(k, buf)
local ft = vim.api.nvim_buf_get_option(buf, "ft")
-- Use nvim_buf_get_option(bufnr, 'ft') for nvim 0.7 users
local ft = vim.api.nvim_get_option_value("ft", { buf = buf })
if ft == 'markdown' then
return ""
end

View File

@@ -500,7 +500,7 @@ and uses regex; the built-in norg <./lua/outline/providers/norg.lua> provider
is an example which uses treesitter.
All providers should support at least nvim 0.7. You can make use of
`_G._outline_nvim_has` with fields `[8]`, `[9]`, and `[10]`. For instance,
`_G._outline_nvim_has` with fields `[8]`, `[9]`, `[10]`, and `[11]`. For instance,
`_G._outline_nvim_has[8]` is equivalent to: `vim.fn.has('nvim-0.8') == 1`.
If a higher nvim version is required, it is recommended to check for this
@@ -806,7 +806,8 @@ based on the filetype.
>lua
symbols = {
icon_fetcher = function(kind, bufnr, symbol)
local ft = vim.api.nvim_buf_get_option(bufnr, 'ft')
-- Use nvim_buf_get_option_value(buf, 'ft') for nvim 0.7 users
local ft = vim.api.nvim_get_option_value('ft', { buf = bufnr })
-- ...
end,
}
@@ -1007,7 +1008,8 @@ DIFFERENT ICONS BASED ON FILETYPE ~
>lua
symbols = {
icon_fetcher = function(kind, bufnr)
local ft = vim.api.nvim_buf_get_option(bufnr, 'ft')
-- Use nvim_buf_get_option_value(buf, 'ft') for nvim 0.7 users
local ft = vim.api.nvim_get_option_value('ft', { buf = bufnr })
-- ...
end,
}
@@ -1048,7 +1050,8 @@ other filetypes.
>lua
symbols = {
icon_fetcher = function(k, buf)
local ft = vim.api.nvim_buf_get_option(buf, "ft")
-- Use nvim_buf_get_option_value(buf, 'ft') for nvim 0.7 users
local ft = vim.api.nvim_get_option_value("ft", { buf = buf })
if ft == 'markdown' then
return ""
end

View File

@@ -208,7 +208,7 @@ end
---@param bufnr integer
---@return boolean include
function M.should_include_symbol(kind, bufnr)
local ft = vim.api.nvim_buf_get_option(bufnr, 'ft')
local ft = utils.buf_get_option(bufnr, 'ft')
-- There can only be one kind in markdown and norg as of now
if ft == 'markdown' or ft == 'norg' or kind == nil then
return true
@@ -232,7 +232,7 @@ function M.should_include_symbol(kind, bufnr)
return filter_table[kind] ~= false
end
---@param client lsp.client|number
---@param client vim.lsp.Client|number
function M.is_client_blacklisted(client)
if not client then
return false

View File

@@ -1,6 +1,8 @@
---@class outline.Float
local Float = {}
local utils = require('outline.utils')
---@class outline.Float
---@field bufnr integer
---@field winnr integer
@@ -19,7 +21,7 @@ function Float:open(lines, hl, title, indent)
indent = indent or 0
self.bufnr = vim.api.nvim_create_buf(false, true)
vim.api.nvim_buf_set_option(self.bufnr, 'bufhidden', 'delete')
utils.buf_set_option(self.bufnr, 'bufhidden', 'delete')
local maxwidth = 0
for _, l in ipairs(lines) do
@@ -60,14 +62,24 @@ function Float:open(lines, hl, title, indent)
end
end
vim.api.nvim_win_set_option(self.winnr, 'winfixwidth', true)
utils.win_set_option(self.winnr, 'winfixwidth', true)
vim.api.nvim_buf_set_lines(self.bufnr, 0, -1, false, lines)
vim.api.nvim_buf_set_option(self.bufnr, 'modifiable', false)
vim.api.nvim_buf_set_option(self.bufnr, 'ft', 'OutlineHelp')
utils.buf_set_option(self.bufnr, 'modifiable', false)
utils.buf_set_option(self.bufnr, 'ft', 'OutlineHelp')
if hl then
self.ns = vim.api.nvim_create_namespace('OutlineHelp')
for _, h in ipairs(hl) do
if _G._outline_nvim_has[11] then
vim.hl.range(
self.bufnr,
self.ns,
h.name,
{ h.line, h.from + indent },
{ h.line, (h.to ~= -1 and h.to + indent) or -1 }
)
else
---@diagnostic disable-next-line:deprecated
vim.api.nvim_buf_add_highlight(
self.bufnr,
self.ns,
@@ -79,6 +91,7 @@ function Float:open(lines, hl, title, indent)
end
end
end
end
function Float:close()
if self.winnr then

View File

@@ -10,7 +10,9 @@ local M = {
---@param bufnr integer
function M.clear_all_ns(bufnr)
if vim.api.nvim_buf_is_valid(bufnr) then
pcall(function() vim.api.nvim_buf_clear_namespace(bufnr, -1, 0, -1) end)
pcall(function()
vim.api.nvim_buf_clear_namespace(bufnr, -1, 0, -1)
end)
end
end
@@ -29,9 +31,14 @@ function M.hovers(bufnr, nodes)
for line, node in ipairs(nodes) do
if node.hovered then
-- stylua: ignore start
if _G._outline_nvim_has[11] then
vim.hl.range(bufnr, M.ns.hover, 'OutlineCurrent', { line - 1, node.prefix_length }, { line - 1, -1 })
else
---@diagnostic disable-next-line:deprecated
vim.api.nvim_buf_add_highlight(
bufnr, M.ns.hover, 'OutlineCurrent', line - 1, node.prefix_length, -1
)
end
-- stylua: ignore end
end
end
@@ -43,9 +50,14 @@ end
function M.items(bufnr, hl_list)
for _, h in ipairs(hl_list) do
-- stylua: ignore start
if _G._outline_nvim_has[11] then
vim.hl.range(bufnr, M.ns.items, h.name, { h.line - 1, h.from }, { h.line - 1, h.to })
else
---@diagnostic disable-next-line:deprecated
vim.api.nvim_buf_add_highlight(
bufnr, M.ns.items, h.name, h.line - 1, h.from, h.to
)
end
-- stylua: ignore end
end
end

View File

@@ -3,7 +3,7 @@ local cfg = require('outline.config')
local highlight = require('outline.highlight')
local providers = require('outline.providers.init')
local symbols = require('outline.symbols')
local utils = require('outline.utils.init')
local utils = require('outline.utils')
local M = {
---@type outline.Sidebar[]
@@ -278,7 +278,7 @@ function M.show_status()
}
if buf and vim.api.nvim_buf_is_valid(buf) then
ctx.ft = vim.api.nvim_buf_get_option(buf, 'ft')
ctx.ft = utils.buf_get_option(buf, 'ft')
ctx.filter = cfg.o.symbols.user_config_filter[ctx.ft]
-- 'else' is handled in help.lua
end
@@ -351,6 +351,7 @@ function M.setup(opts)
[8] = minor >= 8,
[9] = minor >= 9,
[10] = minor >= 10,
[11] = minor >= 11,
}
cfg.setup(opts)

View File

@@ -1,4 +1,5 @@
local cfg = require('outline.config')
local utils = require('outline.utils')
-- A floating window to preview the location of a symbol from the outline.
-- Classical preview reads entire lines into a new buffer for preview. Live
@@ -151,12 +152,12 @@ end
---Set buf & win options, and setup highlight
function Preview:setup()
vim.api.nvim_win_set_option(self.win, 'winhl', self.conf.winhl)
vim.api.nvim_win_set_option(self.win, 'winblend', self.conf.winblend)
utils.win_set_option(self.win, 'winhl', self.conf.winhl)
utils.win_set_option(self.win, 'winblend', self.conf.winblend)
local code_buf = self.s.code.buf
local ft = vim.api.nvim_buf_get_option(code_buf, 'filetype')
vim.api.nvim_buf_set_option(self.buf, 'syntax', ft)
local ft = utils.buf_get_option(code_buf, 'filetype')
utils.buf_set_option(self.buf, 'syntax', ft)
local ts_highlight_fn = vim.treesitter.start
if not _G._outline_nvim_has[8] then
@@ -167,9 +168,9 @@ function Preview:setup()
end
pcall(ts_highlight_fn, self.buf, ft)
vim.api.nvim_buf_set_option(self.buf, 'bufhidden', 'delete')
vim.api.nvim_buf_set_option(self.buf, 'modifiable', false)
vim.api.nvim_win_set_option(self.win, 'cursorline', true)
utils.buf_set_option(self.buf, 'bufhidden', 'delete')
utils.buf_set_option(self.buf, 'modifiable', false)
utils.win_set_option(self.win, 'cursorline', true)
end
function Preview:update()
@@ -180,9 +181,9 @@ function Preview:update()
local lines = vim.api.nvim_buf_get_lines(self.s.code.buf, 0, -1, false)
if self.buf ~= nil then
vim.api.nvim_buf_set_option(self.buf, 'modifiable', true)
utils.buf_set_option(self.buf, 'modifiable', true)
vim.api.nvim_buf_set_lines(self.buf, 0, -1, false, lines)
vim.api.nvim_buf_set_option(self.buf, 'modifiable', false)
utils.buf_set_option(self.buf, 'modifiable', false)
vim.api.nvim_win_set_cursor(self.win, { node.line + 1, node.character })
end
end
@@ -221,7 +222,7 @@ end
---Creates new preview window and sets the content. Calls setup and set_lines.
function LivePreview:create()
self.codewin = self.s.code.win
self.initial_cursorline = vim.api.nvim_win_get_option(self.s.code.win, 'cursorline')
self.initial_cursorline = utils.win_get_option(self.s.code.win, 'cursorline')
self.outline_height = vim.api.nvim_win_get_height(self.s.view.win)
self.width = cfg.get_preview_width(self.conf)
self.height = cfg.get_preview_height(self.conf, self.outline_height)
@@ -256,9 +257,9 @@ end
---Set buf & win options, and autocmds
function LivePreview:setup()
vim.api.nvim_win_set_option(self.win, 'winhl', self.conf.winhl)
vim.api.nvim_win_set_option(self.win, 'winblend', self.conf.winblend)
vim.api.nvim_win_set_option(self.win, 'cursorline', true)
utils.win_set_option(self.win, 'winhl', self.conf.winhl)
utils.win_set_option(self.win, 'winblend', self.conf.winblend)
utils.win_set_option(self.win, 'cursorline', true)
vim.api.nvim_create_autocmd('WinClosed', {
pattern = tostring(self.win),
@@ -273,7 +274,7 @@ function LivePreview:setup()
once = true,
callback = function()
-- This doesn't work at all?
vim.api.nvim_win_set_option(self.win, 'cursorline', self.initial_cursorline)
utils.win_set_option(self.win, 'cursorline', self.initial_cursorline)
end,
})
end
@@ -286,7 +287,7 @@ end
function LivePreview:focus()
vim.api.nvim_set_current_win(self.win)
-- Remove this when the autocmd for WinEnter works above
vim.api.nvim_win_set_option(self.win, 'cursorline', self.initial_cursorline)
utils.win_set_option(self.win, 'cursorline', self.initial_cursorline)
end
---Create, focus, or update preview

View File

@@ -15,11 +15,13 @@ local M = {
name = 'markdown',
}
local utils = require('outline.utils')
---@param bufnr integer
---@param config table?
---@return boolean ft_is_markdown
function M.supports_buffer(bufnr, config)
local ft = vim.api.nvim_buf_get_option(bufnr, 'ft')
local ft = utils.buf_get_option(bufnr, 'ft')
if config and config.filetypes then
for _, ft_check in ipairs(config.filetypes) do
if ft_check == ft then
@@ -27,7 +29,7 @@ function M.supports_buffer(bufnr, config)
end
end
end
return ft == "markdown"
return ft == 'markdown'
end
-- Parses markdown files and returns a table of SymbolInformation[] which is
@@ -48,7 +50,7 @@ function M.handle_markdown()
end
local next_value = lines[line + 1]
local is_emtpy_line = #value:gsub("^%s*(.-)%s*$", "%1") == 0
local is_emtpy_line = #value:gsub('^%s*(.-)%s*$', '%1') == 0
local header, title = string.match(value, '^(#+)%s+(.+)$')
if not header and next_value and not is_emtpy_line then

View File

@@ -17,11 +17,12 @@ local M = {
]
]],
}
local utils = require('outline.utils')
---@param bufnr integer
---@param config table?
function M.supports_buffer(bufnr, config)
if vim.api.nvim_buf_get_option(bufnr, 'ft') ~= 'norg' then
if utils.buf_get_option(bufnr, 'ft') ~= 'norg' then
return false
end

View File

@@ -1,6 +1,7 @@
local cfg = require('outline.config')
local jsx = require('outline.providers.jsx')
local lsp_utils = require('outline.utils.lsp')
local utils = require('outline.utils')
local l = vim.lsp
@@ -18,7 +19,7 @@ function M.get_status(info)
return { 'client: ' .. info.client.name }
end
---@param client lsp.client
---@param client vim.lsp.Client
---@param capability string
---@return boolean
local function _check_client(client, capability)
@@ -30,7 +31,7 @@ end
---@param bufnr integer
---@param capability string
---@return lsp.client?
---@return vim.lsp.Client?
local function get_appropriate_client(bufnr, capability)
local clients, use_client
@@ -38,6 +39,7 @@ local function get_appropriate_client(bufnr, capability)
if _G._outline_nvim_has[10] then
clients = l.get_clients({ bufnr = bufnr })
else
---@diagnostic disable-next-line: deprecated
clients = l.get_active_clients({ bufnr = bufnr })
end
for _, client in ipairs(clients) do
@@ -97,14 +99,22 @@ function M.request_symbols(on_symbols, opts, info)
textDocument = l.util.make_text_document_params(),
}
-- XXX: Is bufnr=0 ok here?
local status = info.client.request('textDocument/documentSymbol', params, function(err, response)
local method = 'textDocument/documentSymbol'
local callback = function(err, response)
if err or not response then
on_symbols(response, opts)
else
response = postprocess_symbols(response)
on_symbols(response, opts)
end
end, 0)
end
local bufnr = 0
local status
if _G._outline_nvim_has[11] then
status = info.client:request(method, params, callback, bufnr)
else
status = info.client.request(method, params, callback, bufnr)
end
if not status then
on_symbols(nil, opts)
end
@@ -134,7 +144,7 @@ end
---@see rename_symbol
---@param sidebar outline.Sidebar
---@param client lsp.client
---@param client vim.lsp.Client
---@param node outline.FlatSymbol
---@return boolean success
local function legacy_rename(sidebar, client, node)
@@ -150,8 +160,15 @@ local function legacy_rename(sidebar, client, node)
bufnr = sidebar.code.buf,
newName = new_name,
}
local status, err =
local status, err
if _G._outline_nvim_has[11] then
status, err =
client:request_sync('textDocument/rename', params, request_timeout, sidebar.code.buf)
else
---@diagnostic disable-next-line
status, err =
client.request_sync('textDocument/rename', params, request_timeout, sidebar.code.buf)
end
if status == nil or status.err or err or status.result == nil then
return false
end
@@ -210,13 +227,23 @@ function M.show_hover(sidebar)
bufnr = sidebar.code.buf,
}
local status, err = client.request_sync('textDocument/hover', params, request_timeout)
local status, err
if _G._outline_nvim_has[11] then
status, err = client:request_sync('textDocument/hover', params, request_timeout)
else
status, err = client.request_sync('textDocument/hover', params, request_timeout)
end
if status == nil or status.err or err or not status.result or not status.result.contents then
return false
end
local md_lines = l.util.convert_input_to_markdown_lines(status.result.contents)
if _G._outline_nvim_has[10] then
md_lines = vim.split(status.result.contents, '\n', { trimempty = true })
else
---@diagnostic disable-next-line:deprecated
md_lines = l.util.trim_empty_lines(md_lines)
end
if vim.tbl_isempty(md_lines) then
-- Request was successful, but there is no hover content
return true
@@ -226,7 +253,7 @@ function M.show_hover(sidebar)
border = cfg.o.preview_window.border,
width = code_width,
})
vim.api.nvim_win_set_option(winnr, 'winhighlight', cfg.o.preview_window.winhl)
utils.win_set_option(winnr, 'winhighlight', cfg.o.preview_window.winhl)
return true
end

View File

@@ -5,7 +5,7 @@ local folding = require('outline.folding')
local parser = require('outline.parser')
local providers = require('outline.providers.init')
local symbols = require('outline.symbols')
local utils = require('outline.utils.init')
local utils = require('outline.utils')
local strlen = vim.fn.strlen
@@ -249,7 +249,7 @@ function Sidebar:update_cursor_style()
local hide_cursor = type(cl) ~= 'string'
if cl == 'focus_in_outline' or cl == 'focus_in_code' then
vim.api.nvim_win_set_option(0, 'cursorline', cl == 'focus_in_outline')
utils.win_set_option(0, 'cursorline', cl == 'focus_in_outline')
hide_cursor = cl == 'focus_in_outline'
end
@@ -265,7 +265,7 @@ function Sidebar:reset_cursor_style()
local cl = cfg.o.outline_window.show_cursorline
if cl == 'focus_in_outline' or cl == 'focus_in_code' then
vim.api.nvim_win_set_option(0, 'cursorline', cl ~= 'focus_in_outline')
utils.win_set_option(0, 'cursorline', cl ~= 'focus_in_outline')
end
-- vim.opt doesn't seem to provide a way to remove last item, like a pop()
-- vim.o.guicursor = vim.o.guicursor:gsub(",n.-:.-$", "")
@@ -344,8 +344,8 @@ function Sidebar:__refresh()
if focused_outline or not self.view:is_open() then
return
end
local ft = vim.api.nvim_buf_get_option(buf, 'ft')
local listed = vim.api.nvim_buf_get_option(buf, 'buflisted')
local ft = utils.buf_get_option(buf, 'ft')
local listed = utils.buf_get_option(buf, 'ft')
if ft == 'OutlineHelp' or not (listed or ft == 'help') then
return
end

View File

@@ -38,7 +38,14 @@ function M.flash_highlight(winnr, lnum, durationMs, hl_group)
durationMs = 400
end
local bufnr = vim.api.nvim_win_get_buf(winnr)
local ns = vim.api.nvim_buf_add_highlight(bufnr, 0, hl_group, lnum - 1, 0, -1)
local ns
if _G._outline_nvim_has[11] then
ns = vim.api.nvim_create_namespace('_outline_nvim_flash')
vim.hl.range(bufnr, ns, hl_group, { lnum - 1, 0 }, { lnum - 1, -1 })
else
---@diagnostic disable-next-line:deprecated
ns = vim.api.nvim_buf_add_highlight(bufnr, 0, hl_group, lnum - 1, 0, -1)
end
local remove_highlight = function()
pcall(vim.api.nvim_buf_clear_namespace, bufnr, ns, 0, -1)
end
@@ -116,4 +123,54 @@ function M.deepcopy_excluding(t, keys)
return res
end
--- Get option value of given buffer.
--- @param bufnr integer
--- @param name string
--- @return any
function M.buf_get_option(bufnr, name)
if _G._outline_nvim_has[10] then
return vim.api.nvim_get_option_value(name, { buf = bufnr })
else
---@diagnostic disable-next-line:deprecated
return vim.api.nvim_buf_get_option(bufnr, name)
end
end
--- Set option value of given buffer.
--- @param bufnr integer
--- @param name string
function M.buf_set_option(bufnr, name, value)
if _G._outline_nvim_has[10] then
return vim.api.nvim_set_option_value(name, value, { buf = bufnr })
else
---@diagnostic disable-next-line:deprecated
return vim.api.nvim_buf_set_option(bufnr, name, value)
end
end
--- Get option value of given window.
--- @param winnr integer
--- @param name string
--- @return any
function M.win_get_option(winnr, name)
if _G._outline_nvim_has[10] then
return vim.api.nvim_get_option_value(name, { win = winnr })
else
---@diagnostic disable-next-line:deprecated
return vim.api.nvim_buf_get_option(winnr, name)
end
end
--- Set option value of given window.
--- @param winnr integer
--- @param name string
function M.win_set_option(winnr, name, value)
if _G._outline_nvim_has[10] then
return vim.api.nvim_set_option_value(name, value, { win = winnr })
else
---@diagnostic disable-next-line:deprecated
return vim.api.nvim_win_set_option(winnr, name, value)
end
end
return M

View File

@@ -1,4 +1,5 @@
local config = require('outline.config')
local utils = require('outline.utils')
local M = {}
@@ -7,13 +8,14 @@ function M.is_buf_attached_to_lsp(bufnr)
if _G._outline_nvim_has[10] then
clients = vim.lsp.get_clients({ bufnr = bufnr or 0 })
else
---@diagnostic disable-next-line: deprecated
clients = vim.lsp.get_active_clients({ bufnr = bufnr or 0 })
end
return clients ~= nil and #clients > 0
end
function M.is_buf_markdown(bufnr)
return vim.api.nvim_buf_get_option(bufnr, 'ft') == 'markdown'
return utils.buf_get_option(bufnr, 'ft') == 'markdown'
end
--- Merge all client token lists in an LSP response

View File

@@ -1,5 +1,6 @@
local cfg = require('outline.config')
local highlight = require('outline.highlight')
local utils = require('outline.utils')
---@class outline.View
local View = {}
@@ -19,10 +20,10 @@ function View:setup_view(split_command)
self.buf = vim.api.nvim_create_buf(false, true)
-- set filetype
vim.api.nvim_buf_set_option(self.buf, 'filetype', 'Outline')
utils.buf_set_option(self.buf, 'filetype', 'Outline')
-- delete buffer when window is closed / buffer is hidden
vim.api.nvim_buf_set_option(self.buf, 'bufhidden', 'delete')
utils.buf_set_option(self.buf, 'bufhidden', 'delete')
-- create a split
vim.cmd(split_command)
@@ -38,38 +39,38 @@ function View:setup_view(split_command)
end
-- window stuff
vim.api.nvim_win_set_option(self.win, 'spell', false)
vim.api.nvim_win_set_option(self.win, 'signcolumn', 'no')
vim.api.nvim_win_set_option(self.win, 'foldcolumn', '0')
vim.api.nvim_win_set_option(self.win, 'number', false)
vim.api.nvim_win_set_option(self.win, 'relativenumber', false)
vim.api.nvim_win_set_option(self.win, 'winfixwidth', true)
vim.api.nvim_win_set_option(self.win, 'list', false)
vim.api.nvim_win_set_option(self.win, 'wrap', cfg.o.outline_window.wrap)
vim.api.nvim_win_set_option(self.win, 'winhl', cfg.o.outline_window.winhl)
vim.api.nvim_win_set_option(self.win, 'linebreak', true) -- only has effect when wrap=true
vim.api.nvim_win_set_option(self.win, 'breakindent', true) -- only has effect when wrap=true
utils.win_set_option(self.win, 'spell', false)
utils.win_set_option(self.win, 'signcolumn', 'no')
utils.win_set_option(self.win, 'foldcolumn', '0')
utils.win_set_option(self.win, 'number', false)
utils.win_set_option(self.win, 'relativenumber', false)
utils.win_set_option(self.win, 'winfixwidth', true)
utils.win_set_option(self.win, 'list', false)
utils.win_set_option(self.win, 'wrap', cfg.o.outline_window.wrap)
utils.win_set_option(self.win, 'winhl', cfg.o.outline_window.winhl)
utils.win_set_option(self.win, 'linebreak', true) -- only has effect when wrap=true
utils.win_set_option(self.win, 'breakindent', true) -- only has effect when wrap=true
-- Would be nice to use guides.markers.vertical as part of showbreak to keep
-- continuity of the tree UI, but there's currently no way to style the
-- color, apart from globally overriding hl-NonText, which will potentially
-- mess with other theme/user settings. So just use empty spaces for now.
vim.api.nvim_win_set_option(self.win, 'showbreak', ' ') -- only has effect when wrap=true.
utils.win_set_option(self.win, 'showbreak', ' ') -- only has effect when wrap=true.
-- buffer stuff
local tab = vim.api.nvim_get_current_tabpage()
vim.api.nvim_buf_set_name(self.buf, 'OUTLINE_' .. tostring(tab))
vim.api.nvim_buf_set_option(self.buf, 'modifiable', false)
utils.buf_set_option(self.buf, 'modifiable', false)
if cfg.o.outline_window.show_numbers or cfg.o.outline_window.show_relative_numbers then
vim.api.nvim_win_set_option(self.win, 'nu', true)
utils.win_set_option(self.win, 'nu', true)
end
if cfg.o.outline_window.show_relative_numbers then
vim.api.nvim_win_set_option(self.win, 'rnu', true)
utils.win_set_option(self.win, 'rnu', true)
end
local cl = cfg.o.outline_window.show_cursorline
if cl == true or cl == 'focus_in_outline' then
vim.api.nvim_win_set_option(self.win, 'cursorline', true)
utils.win_set_option(self.win, 'cursorline', true)
end
end
@@ -100,9 +101,9 @@ end
---@param lines string[]
function View:rewrite_lines(lines)
if self.buf and vim.api.nvim_buf_is_valid(self.buf) then
vim.api.nvim_buf_set_option(self.buf, 'modifiable', true)
utils.buf_set_option(self.buf, 'modifiable', true)
vim.api.nvim_buf_set_lines(self.buf, 0, -1, false, lines)
vim.api.nvim_buf_set_option(self.buf, 'modifiable', false)
utils.buf_set_option(self.buf, 'modifiable', false)
end
end