summaryrefslogtreecommitdiff
path: root/script/provider
diff options
context:
space:
mode:
authorKevin Hahn <hahn.kev@gmail.com>2022-07-23 21:17:30 +0700
committerKevin Hahn <hahn.kev@gmail.com>2022-07-23 21:19:50 +0700
commiteecbfae0e6d846f20bc836b5ee8a706501b2db40 (patch)
tree907352ecd34a65dc7b55553f8b502ce1501e7e8a /script/provider
parentbe85f2c855f9075cadae3219f4dc1f3ce1f920ca (diff)
downloadlua-language-server-eecbfae0e6d846f20bc836b5ee8a706501b2db40.zip
add color support
Diffstat (limited to 'script/provider')
-rw-r--r--script/provider/provider.lua34
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)