refactor: Add a generic provider module
In preperation for coc support
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
local vim = vim
|
||||
|
||||
local parser = require('symbols-outline.parser')
|
||||
local providers = require('symbols-outline.providers.init')
|
||||
local ui = require('symbols-outline.ui')
|
||||
local writer = require('symbols-outline.writer')
|
||||
local config = require('symbols-outline.config')
|
||||
local lsp_utils = require('symbols-outline.utils.lsp_utils')
|
||||
local utils = require('symbols-outline.utils.init')
|
||||
local markdown = require('symbols-outline.markdown')
|
||||
local view = require('symbols-outline.view')
|
||||
|
||||
local M = {}
|
||||
@@ -29,10 +29,6 @@ local function setup_buffer_autocmd()
|
||||
|
||||
end
|
||||
|
||||
local function getParams()
|
||||
return {textDocument = vim.lsp.util.make_text_document_params()}
|
||||
end
|
||||
|
||||
-------------------------
|
||||
-- STATE
|
||||
-------------------------
|
||||
@@ -48,7 +44,7 @@ local function wipe_state()
|
||||
M.state = {outline_items = {}, flattened_outline_items = {}}
|
||||
end
|
||||
|
||||
local function __refresh ()
|
||||
local function __refresh()
|
||||
if M.state.outline_buf ~= nil then
|
||||
local function refresh_handler(response)
|
||||
if response == nil or type(response) ~= 'table' then
|
||||
@@ -70,11 +66,7 @@ local function __refresh ()
|
||||
M.state.flattened_outline_items)
|
||||
end
|
||||
|
||||
if vim.api.nvim_buf_get_option(0, 'ft') == 'markdown' then
|
||||
refresh_handler(markdown.handle_markdown())
|
||||
end
|
||||
vim.lsp.buf_request_all(0, "textDocument/documentSymbol", getParams(),
|
||||
refresh_handler)
|
||||
providers.request_symbols(refresh_handler)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -195,16 +187,12 @@ end
|
||||
|
||||
function M.open_outline()
|
||||
if M.state.outline_buf == nil then
|
||||
if vim.api.nvim_buf_get_option(0, 'ft') == 'markdown' then
|
||||
handler(markdown.handle_markdown())
|
||||
end
|
||||
vim.lsp.buf_request_all(0, "textDocument/documentSymbol", getParams(),
|
||||
handler)
|
||||
providers.request_symbols(handler)
|
||||
end
|
||||
end
|
||||
|
||||
function M.close_outline()
|
||||
if M.state.outline_buf ~= nil then
|
||||
if M.state.outline_buf then
|
||||
vim.api.nvim_win_close(M.state.outline_win, true)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user