summaryrefslogtreecommitdiff
path: root/server-beta/src/provider
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-11-11 19:39:18 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-11-11 19:39:18 +0800
commitb7742d3bd46bd1ff8d4cce0d6c0f36ea8098a51b (patch)
tree13c52762051a29f202afb45bbc318bed0aad3557 /server-beta/src/provider
parent91af49cdfd292b7e479e6e0327d04c436256ed7b (diff)
downloadlua-language-server-b7742d3bd46bd1ff8d4cce0d6c0f36ea8098a51b.zip
provider 查看引用
Diffstat (limited to 'server-beta/src/provider')
-rw-r--r--server-beta/src/provider/capability.lua2
-rw-r--r--server-beta/src/provider/init.lua25
2 files changed, 26 insertions, 1 deletions
diff --git a/server-beta/src/provider/capability.lua b/server-beta/src/provider/capability.lua
index 71d3bca1..c5762f0b 100644
--- a/server-beta/src/provider/capability.lua
+++ b/server-beta/src/provider/capability.lua
@@ -11,7 +11,7 @@ m.initer = {
hoverProvider = true,
definitionProvider = true,
- --referencesProvider = true,
+ referencesProvider = true,
--renameProvider = true,
--documentSymbolProvider = true,
--documentHighlightProvider = true,
diff --git a/server-beta/src/provider/init.lua b/server-beta/src/provider/init.lua
index 5f3d2db4..5e1a1a2a 100644
--- a/server-beta/src/provider/init.lua
+++ b/server-beta/src/provider/init.lua
@@ -182,6 +182,31 @@ proto.on('textDocument/definition', function (params)
return response
end)
+proto.on('textDocument/references', function (params)
+ local core = require 'core.reference'
+ local uri = params.textDocument.uri
+ if not files.exists(uri) then
+ return nil
+ end
+ local lines = files.getLines(uri)
+ local text = files.getText(uri)
+ local offset = define.offset(lines, text, params.position)
+ local result = core(uri, offset)
+ if not result then
+ return nil
+ end
+ local response = {}
+ for i, info in ipairs(result) do
+ local targetUri = info.uri
+ local targetLines = files.getLines(targetUri)
+ local targetText = files.getText(targetUri)
+ response[i] = define.location(targetUri
+ , define.range(targetLines, targetText, info.target.start, info.target.finish)
+ )
+ end
+ return response
+end)
+
proto.on('textDocument/completion', function (params)
--log.info(util.dump(params))
return nil