diff options
Diffstat (limited to 'script/provider/provider.lua')
-rw-r--r-- | script/provider/provider.lua | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/script/provider/provider.lua b/script/provider/provider.lua index b8ea2d9b..e7c27d2c 100644 --- a/script/provider/provider.lua +++ b/script/provider/provider.lua @@ -335,6 +335,35 @@ proto.on('textDocument/definition', function (params) return response end) +proto.on('textDocument/typeDefinition', function (params) + workspace.awaitReady() + local _ <close> = progress.create(lang.script.WINDOW_PROCESSING_TYPE_DEFINITION, 0.5) + local core = require 'core.type-definition' + local uri = params.textDocument.uri + if not files.exists(uri) then + return nil + end + local offset = files.offsetOfWord(uri, 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 + if targetUri then + if files.exists(targetUri) then + response[i] = define.locationLink(targetUri + , files.range(targetUri, info.target.start, info.target.finish) + , files.range(targetUri, info.target.start, info.target.finish) + , files.range(uri, info.source.start, info.source.finish) + ) + end + end + end + return response +end) + proto.on('textDocument/references', function (params) workspace.awaitReady() local _ <close> = progress.create(lang.script.WINDOW_PROCESSING_REFERENCE, 0.5) |