feat(providers): Support independent configs for each provider to handle
Closes #58
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user