feat(providers): Inital COC support

Closes #68
Still needs support for code actions/hover/rename etc
This commit is contained in:
simrat39
2021-10-06 12:58:44 -07:00
parent a0d563172d
commit 042c8466a2
6 changed files with 46 additions and 21 deletions

View File

@@ -0,0 +1,24 @@
-- local config = require('symbols-outline.config')
local M = {}
-- probably change this
function M.should_use_provider(_)
local coc_installed = vim.fn.exists("*CocActionAsync")
if not coc_installed then return end
local coc_attached = vim.fn.call('CocAction', {'ensureDocument'})
local has_symbols = vim.fn.call('CocHasProvider', {'documentSymbol'})
return coc_attached and has_symbols;
end
---@param on_symbols function
function M.request_symbols(on_symbols)
vim.fn.call('CocActionAsync', {'documentSymbols', function (_, symbols)
on_symbols{[1000000]={result=symbols}}
end})
end
return M