New lua API function: follow_cursor (supports opts.focus_outline). This sets location in outline to match location in code. New keymap: restore_location (C-g) by default. This provides the same functionality as follow_cursor. I've also refactored other lua API functions for consistency of using `opts.focus_outline`. If opts is not provided, focus_outline is defaulted to true. To change this behaviour, set it to false.
37 lines
815 B
Lua
37 lines
815 B
Lua
local M = {}
|
|
|
|
local providers = {
|
|
'symbols-outline/providers/nvim-lsp',
|
|
'symbols-outline/providers/coc',
|
|
'symbols-outline/providers/markdown',
|
|
}
|
|
|
|
_G._symbols_outline_current_provider = nil
|
|
|
|
function M.has_provider()
|
|
local ret = false
|
|
for _, value in ipairs(providers) do
|
|
local provider = require(value)
|
|
if provider.should_use_provider(0) then
|
|
ret = true
|
|
break
|
|
end
|
|
end
|
|
return ret
|
|
end
|
|
|
|
---@param on_symbols function
|
|
function M.request_symbols(on_symbols, opts)
|
|
for _, value in ipairs(providers) do
|
|
local provider = require(value)
|
|
if provider.should_use_provider(0) then
|
|
_G._symbols_outline_current_provider = provider
|
|
_G._symbols_outline_current_provider.name = value
|
|
provider.request_symbols(on_symbols, opts)
|
|
break
|
|
end
|
|
end
|
|
end
|
|
|
|
return M
|