Format with stylua
This commit is contained in:
@@ -1,31 +1,31 @@
|
||||
local M = {}
|
||||
|
||||
function M.should_use_provider(_)
|
||||
local not_coc_installed = vim.fn.exists("*CocActionAsync") == 0
|
||||
local not_coc_service_initialized = vim.g.coc_service_initialized == 0
|
||||
local not_coc_installed = vim.fn.exists '*CocActionAsync' == 0
|
||||
local not_coc_service_initialized = vim.g.coc_service_initialized == 0
|
||||
|
||||
if not_coc_installed or not_coc_service_initialized then
|
||||
return
|
||||
end
|
||||
if not_coc_installed or not_coc_service_initialized then
|
||||
return
|
||||
end
|
||||
|
||||
local coc_attached = vim.fn.call("CocAction", { "ensureDocument" })
|
||||
local has_symbols = vim.fn.call("CocHasProvider", { "documentSymbol" })
|
||||
local coc_attached = vim.fn.call('CocAction', { 'ensureDocument' })
|
||||
local has_symbols = vim.fn.call('CocHasProvider', { 'documentSymbol' })
|
||||
|
||||
return coc_attached and has_symbols
|
||||
return coc_attached and has_symbols
|
||||
end
|
||||
|
||||
function M.hover_info(_, _, on_info)
|
||||
on_info(nil, { contents = { kind = "markdown", contents = { "No extra information availaible!" } } })
|
||||
on_info(nil, { contents = { kind = 'markdown', contents = { 'No extra information availaible!' } } })
|
||||
end
|
||||
|
||||
---@param on_symbols function
|
||||
function M.request_symbols(on_symbols)
|
||||
vim.fn.call("CocActionAsync", {
|
||||
"documentSymbols",
|
||||
function(_, symbols)
|
||||
on_symbols({ [1000000] = { result = symbols } })
|
||||
end,
|
||||
})
|
||||
vim.fn.call('CocActionAsync', {
|
||||
'documentSymbols',
|
||||
function(_, symbols)
|
||||
on_symbols { [1000000] = { result = symbols } }
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
@@ -1,35 +1,35 @@
|
||||
local M = {}
|
||||
|
||||
local providers = {
|
||||
"symbols-outline/providers/nvim-lsp",
|
||||
"symbols-outline/providers/coc",
|
||||
"symbols-outline/providers/markdown",
|
||||
'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
|
||||
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)
|
||||
for _, value in ipairs(providers) do
|
||||
local provider = require(value)
|
||||
if provider.should_use_provider(0) then
|
||||
_G._symbols_outline_current_provider = provider
|
||||
provider.request_symbols(on_symbols)
|
||||
break
|
||||
end
|
||||
end
|
||||
for _, value in ipairs(providers) do
|
||||
local provider = require(value)
|
||||
if provider.should_use_provider(0) then
|
||||
_G._symbols_outline_current_provider = provider
|
||||
provider.request_symbols(on_symbols)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
local md_parser = require("symbols-outline.markdown")
|
||||
local md_parser = require 'symbols-outline.markdown'
|
||||
|
||||
local M = {}
|
||||
|
||||
-- probably change this
|
||||
function M.should_use_provider(bufnr)
|
||||
return string.match(vim.api.nvim_buf_get_option(bufnr, "ft"), "markdown")
|
||||
return string.match(vim.api.nvim_buf_get_option(bufnr, 'ft'), 'markdown')
|
||||
end
|
||||
|
||||
function M.hover_info(_, _, on_info)
|
||||
on_info(nil, { contents = { kind = "markdown", contents = { "No extra information availaible!" } } })
|
||||
on_info(nil, { contents = { kind = 'markdown', contents = { 'No extra information availaible!' } } })
|
||||
end
|
||||
|
||||
---@param on_symbols function
|
||||
function M.request_symbols(on_symbols)
|
||||
on_symbols(md_parser.handle_markdown())
|
||||
on_symbols(md_parser.handle_markdown())
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
@@ -1,57 +1,57 @@
|
||||
local config = require("symbols-outline.config")
|
||||
local config = require 'symbols-outline.config'
|
||||
|
||||
local M = {}
|
||||
|
||||
local function getParams()
|
||||
return { textDocument = vim.lsp.util.make_text_document_params() }
|
||||
return { textDocument = vim.lsp.util.make_text_document_params() }
|
||||
end
|
||||
|
||||
function M.hover_info(bufnr, params, on_info)
|
||||
local clients = vim.lsp.buf_get_clients(bufnr)
|
||||
local used_client
|
||||
local clients = vim.lsp.buf_get_clients(bufnr)
|
||||
local used_client
|
||||
|
||||
for id, client in pairs(clients) do
|
||||
if config.is_client_blacklisted(id) then
|
||||
goto continue
|
||||
else
|
||||
if client.server_capabilities.hoverProvider then
|
||||
used_client = client
|
||||
break
|
||||
end
|
||||
end
|
||||
::continue::
|
||||
end
|
||||
for id, client in pairs(clients) do
|
||||
if config.is_client_blacklisted(id) then
|
||||
goto continue
|
||||
else
|
||||
if client.server_capabilities.hoverProvider then
|
||||
used_client = client
|
||||
break
|
||||
end
|
||||
end
|
||||
::continue::
|
||||
end
|
||||
|
||||
if not used_client then
|
||||
on_info(nil, { contents = { kind = "markdown", content = { "No extra information availaible!" } } })
|
||||
end
|
||||
if not used_client then
|
||||
on_info(nil, { contents = { kind = 'markdown', content = { 'No extra information availaible!' } } })
|
||||
end
|
||||
|
||||
used_client.request("textDocument/hover", params, on_info, bufnr)
|
||||
used_client.request('textDocument/hover', params, on_info, bufnr)
|
||||
end
|
||||
|
||||
-- probably change this
|
||||
function M.should_use_provider(bufnr)
|
||||
local clients = vim.lsp.buf_get_clients(bufnr)
|
||||
local ret = false
|
||||
local clients = vim.lsp.buf_get_clients(bufnr)
|
||||
local ret = false
|
||||
|
||||
for id, client in pairs(clients) do
|
||||
if config.is_client_blacklisted(id) then
|
||||
goto continue
|
||||
else
|
||||
if client.server_capabilities.documentSymbolProvider then
|
||||
ret = true
|
||||
break
|
||||
end
|
||||
end
|
||||
::continue::
|
||||
end
|
||||
for id, client in pairs(clients) do
|
||||
if config.is_client_blacklisted(id) then
|
||||
goto continue
|
||||
else
|
||||
if client.server_capabilities.documentSymbolProvider then
|
||||
ret = true
|
||||
break
|
||||
end
|
||||
end
|
||||
::continue::
|
||||
end
|
||||
|
||||
return ret
|
||||
return ret
|
||||
end
|
||||
|
||||
---@param on_symbols function
|
||||
function M.request_symbols(on_symbols)
|
||||
vim.lsp.buf_request_all(0, "textDocument/documentSymbol", getParams(), on_symbols)
|
||||
vim.lsp.buf_request_all(0, 'textDocument/documentSymbol', getParams(), on_symbols)
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
Reference in New Issue
Block a user