Merge branch 'main' into main

This commit is contained in:
jinzhongjia
2024-05-04 15:28:13 +08:00
committed by GitHub
10 changed files with 94 additions and 57 deletions

View File

@@ -94,6 +94,9 @@ M.defaults = {
lsp = {
blacklist_clients = {},
},
markdown = {
filetypes = { 'markdown' },
},
},
symbols = {
---@type outline.FilterConfig?
@@ -325,6 +328,8 @@ function M.resolve_config()
map[client] = true
end
M.o.providers.lsp.blacklist_clients = map
----- LSP PROVIDER CONFIG NAME -----
M.o.providers['nvim-lsp'] = M.o.providers.lsp
end
---Ensure l is either table, false, or nil. If not, print warning using given

View File

@@ -297,6 +297,10 @@ function M.show_status()
return require('outline.help').show_status(ctx)
end
function M.has_provider()
return providers.has_provider()
end
local function setup_commands()
local cmd = function(n, c, o)
vim.api.nvim_create_user_command('Outline' .. n, c, o)

View File

@@ -3,6 +3,8 @@ local import_prefix = 'outline/providers/'
---@return outline.Provider?, table?
function M.find_provider()
local configs = require('outline.config').o.providers
if not M.providers then
M.providers = vim.tbl_map(function(p)
return import_prefix .. p
@@ -11,7 +13,7 @@ function M.find_provider()
for _, path in ipairs(M.providers) do
local provider = require(path)
local ok, info = provider.supports_buffer(0)
local ok, info = provider.supports_buffer(0, configs[provider.name])
if ok then
return provider, info
end

View File

@@ -15,9 +15,19 @@ local M = {
name = 'markdown',
}
---@param bufnr integer
---@param config table?
---@return boolean ft_is_markdown
function M.supports_buffer(bufnr)
return vim.api.nvim_buf_get_option(bufnr, 'ft') == 'markdown'
function M.supports_buffer(bufnr, config)
local ft = vim.api.nvim_buf_get_option(bufnr, 'ft')
if config and config.filetypes then
for _, ft_check in ipairs(config.filetypes) do
if ft_check == ft then
return true
end
end
end
return ft == "markdown"
end
-- Parses markdown files and returns a table of SymbolInformation[] which is

View File

@@ -18,7 +18,9 @@ local M = {
]],
}
function M.supports_buffer(bufnr)
---@param bufnr integer
---@param config table?
function M.supports_buffer(bufnr, config)
if vim.api.nvim_buf_get_option(bufnr, 'ft') ~= 'norg' then
return false
end

View File

@@ -63,8 +63,9 @@
---@class outline.Provider
---@field name string
---@field config table?
---@field get_status? fun(info:table?):string[]
---@field supports_buffer fun(bufnr:integer):boolean,table?
---@field supports_buffer fun(bufnr:integer, config:table?):boolean,table?
---@field request_symbols fun(on_symbols:fun(symbols?:outline.ProviderSymbol[], opts:table?, provider_info:table?), opts:table?)
---@field show_hover? fun(sidebar:outline.Sidebar):boolean
---@field rename_symbol? fun(sidebar:outline.Sidebar):boolean

View File

@@ -26,13 +26,16 @@ function View:setup_view(split_command)
-- create a split
vim.cmd(split_command)
-- get current (outline) window and attach our buffer to it
self.win = vim.api.nvim_get_current_win()
vim.api.nvim_win_set_buf(self.win, self.buf)
-- resize to a % of the current window size
vim.cmd('vertical resize ' .. cfg.o.outline_window.width)
-- resize if split_command not specify width like "25vsplit"
if split_command:match("%d+") == nil then
-- resize to a % of the current window size
vim.cmd('vertical resize ' .. cfg.o.outline_window.width)
end
-- window stuff
vim.api.nvim_win_set_option(self.win, 'spell', false)