diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-07-24 18:51:47 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-24 18:51:47 +0800 |
commit | a2052c12d1b6af794bede00af1806c0ceed3c68e (patch) | |
tree | 53fc1a507c51cc80232aa05f21310cfb16af0fba /script/provider | |
parent | a0128ffcb7a08af6a39c0244616509e55fc104f8 (diff) | |
parent | eecbfae0e6d846f20bc836b5ee8a706501b2db40 (diff) | |
download | lua-language-server-a2052c12d1b6af794bede00af1806c0ceed3c68e.zip |
Merge pull request #1379 from FAForever/add-color-support
add color support
Diffstat (limited to 'script/provider')
-rw-r--r-- | script/provider/provider.lua | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/script/provider/provider.lua b/script/provider/provider.lua index 1af5ea82..239a39d7 100644 --- a/script/provider/provider.lua +++ b/script/provider/provider.lua @@ -1021,6 +1021,40 @@ m.register 'textDocument/foldingRange' { end } +m.register 'textDocument/documentColor' { + capability = { + colorProvider = true + }, + ---@async + function (params) + local color = require 'core.color' + local uri = files.getRealUri(params.textDocument.uri) + workspace.awaitReady(uri) + if not files.exists(uri) then + return nil + end + local colors = color.colors(uri) + if not colors then + return nil + end + local results = {} + for _, colorValue in ipairs(colors) do + results[#results+1] = { + range = converter.packRange(uri, colorValue.start, colorValue.finish), + color = colorValue.color + } + end + return results + end +} + +m.register 'textDocument/colorPresentation' { + function (params) + local color = (require 'core.color').colorToText(params.color) + return {{label = color}} + end +} + m.register 'window/workDoneProgress/cancel' { function (params) log.debug('close proto(cancel):', params.token) |