diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-04-16 00:26:13 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-04-16 00:26:13 +0800 |
commit | 8b5c02c49fa397a40f03dc5c27dd6872dee13b2c (patch) | |
tree | e32be7bba8631552620d8e0c9c418749b7985192 /script/provider/provider.lua | |
parent | c4f70450e6727a693586ad7941581ac51014545c (diff) | |
download | lua-language-server-8b5c02c49fa397a40f03dc5c27dd6872dee13b2c.zip |
move inlay-hint to LSP
Diffstat (limited to 'script/provider/provider.lua')
-rw-r--r-- | script/provider/provider.lua | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/script/provider/provider.lua b/script/provider/provider.lua index f5b21c66..f595c6b1 100644 --- a/script/provider/provider.lua +++ b/script/provider/provider.lua @@ -1155,6 +1155,48 @@ m.register '$/requestHint' { end } +m.register 'textDocument/inlayHint' { + capability = { + inlayHintProvider = { + resolveProvider = true, + }, + }, + ---@async + function (params) + local uri = files.getRealUri(params.textDocument.uri) + if not config.get(uri, 'Lua.hint.enable') then + return + end + workspace.awaitReady(uri) + local core = require 'core.hint' + local start, finish = converter.unpackRange(uri, params.range) + local results = core(uri, start, finish) + local hintResults = {} + for i, res in ipairs(results) do + hintResults[i] = { + label = res.text, + position = converter.packPosition(uri, res.offset), + kind = res.kind, + paddingLeft = true, + paddingRight = true, + } + end + return hintResults + end +} + +m.register 'inlayHint/resolve' { + capability = { + inlayHintProvider = { + resolveProvider = true, + }, + }, + ---@async + function (hint) + return hint + end +} + -- Hint do ---@async |