From afc09241d9075d73cb76661a02613a6e114df686 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Sun, 27 Sep 2020 17:51:13 +0800 Subject: =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E5=8C=BA=E7=AC=A6=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script-beta/provider/provider.lua | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'script-beta/provider/provider.lua') diff --git a/script-beta/provider/provider.lua b/script-beta/provider/provider.lua index 7c61db14..68c498c6 100644 --- a/script-beta/provider/provider.lua +++ b/script-beta/provider/provider.lua @@ -511,6 +511,7 @@ proto.on('textDocument/documentSymbol', function (params) if symbol.name == '' then symbol.name = lang.script.SYMBOL_ANONYMOUS end + symbol.valueRange = nil if symbol.children then for _, child in ipairs(symbol.children) do convert(child) @@ -549,6 +550,36 @@ proto.on('workspace/executeCommand', function (params) end end) -proto.on('workspaceSymbolProvider', function (params) - +proto.on('workspace/symbol', function (params) + local core = require 'core.workspace-symbol' + + await.close('workspace/symbol') + await.setID('workspace/symbol') + + local symbols = core(params.query) + if not symbols or #symbols == 0 then + return nil + end + + local function convert(symbol) + symbol.location = define.location( + symbol.uri, + define.range( + files.getLines(symbol.uri), + files.getText(symbol.uri), + symbol.range[1], + symbol.range[2] + ) + ) + symbol.uri = nil + symbol.detail = nil + symbol.selectionRange = nil + symbol.valueRange = nil + end + + for _, symbol in ipairs(symbols) do + convert(symbol) + end + + return symbols end) -- cgit v1.2.3