summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server-beta/src/core/reference.lua1
-rw-r--r--server-beta/src/provider/capability.lua2
-rw-r--r--server-beta/src/provider/init.lua25
3 files changed, 26 insertions, 2 deletions
diff --git a/server-beta/src/core/reference.lua b/server-beta/src/core/reference.lua
index 4c47a072..8ce807c3 100644
--- a/server-beta/src/core/reference.lua
+++ b/server-beta/src/core/reference.lua
@@ -74,7 +74,6 @@ return function (uri, offset)
results[#results+1] = {
target = target,
uri = files.getOriginUri(uri),
- source = source,
}
end)
end)
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