diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-07-01 21:58:04 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-07-01 21:58:04 +0800 |
commit | 384ee42079a801675bf9c00870c9f9dba4135773 (patch) | |
tree | 1a52047ed6d36d1a68922f3b8bb56101a870f1a7 /script/provider/provider.lua | |
parent | f04e62b92b137ac1533f906747060eec31589b0a (diff) | |
download | lua-language-server-384ee42079a801675bf9c00870c9f9dba4135773.zip |
goto `type definition`
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) |