diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-12-18 04:58:41 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-12-18 04:58:41 +0800 |
commit | 64568027b98a74b3cd5c108d710bfd053d5e129d (patch) | |
tree | 1b825134c2551849ce2f0952ee45f97e277d098f /script/provider/provider.lua | |
parent | 67ccea822c91f8ff2cfd6ebce0c0f8b122fe46b2 (diff) | |
download | lua-language-server-64568027b98a74b3cd5c108d710bfd053d5e129d.zip |
first step for code lens
Diffstat (limited to 'script/provider/provider.lua')
-rw-r--r-- | script/provider/provider.lua | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/script/provider/provider.lua b/script/provider/provider.lua index d19e0040..265b8cc8 100644 --- a/script/provider/provider.lua +++ b/script/provider/provider.lua @@ -918,6 +918,46 @@ m.register 'textDocument/codeAction' { end } +m.register 'textDocument/codeLens' { + capability = { + codeLensProvider = { + resolveProvider = true, + } + }, + ---@async + function (params) + local uri = files.getRealUri(params.textDocument.uri) + workspace.awaitReady(uri) + local state = files.getState(uri) + if not state then + return nil + end + local core = require 'core.code-lens' + local results = core.codeLens(uri) + if not results then + return nil + end + local codeLens = {} + for _, result in ipairs(results) do + codeLens[#codeLens+1] = { + range = converter.packRange(state, result.position, result.position), + data = result.id, + } + end + return codeLens + end +} + +m.register 'codeLens/resolve' { + ---@async + function (codeLen) + local core = require 'core.code-lens' + local command = core.resolve(codeLen.data) + codeLen.command = command + return codeLen + end +} + m.register 'workspace/executeCommand' { capability = { executeCommandProvider = { |