-
-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not call textDocument/documentColor
when LSP server doesn't support it
#117
Comments
Thanks for the report. I know how to do the checks, and I'm doing some of them. It's just that doing something like Promise.all in lua is a bit of a pain, so I've been putting off dealing with it strictly. Most servers don't crash when they are asked to use unsupported methods. |
@simonmandlik |
I just tested |
@lcw |
Good questions. When I updated ccc to the branch with the proposed fix My Lazy config for loading ccc is: {
'uga-rosa/ccc.nvim',
branch = 'fix/117',
config = function()
local ColorInput = require 'ccc.input'
local convert = require 'ccc.utils.convert'
local RgbHslCmykInput = setmetatable({
name = 'RGB/HSL/CMYK',
max = { 1, 1, 1, 360, 1, 1, 1, 1, 1, 1 },
min = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
delta = { 1 / 255, 1 / 255, 1 / 255, 1, 0.01, 0.01, 0.005, 0.005, 0.005, 0.005 },
bar_name = { 'R', 'G', 'B', 'H', 'S', 'L', 'C', 'M', 'Y', 'K' },
}, { __index = ColorInput })
function RgbHslCmykInput.format(n, i)
if i <= 3 then
-- RGB
n = n * 255
elseif i == 5 or i == 6 then
-- S or L of HSL
n = n * 100
elseif i >= 7 then
-- CMYK
return ('%5.1f%%'):format(math.floor(n * 200) / 2)
end
return ('%6d'):format(n)
end
function RgbHslCmykInput.from_rgb(RGB)
local HSL = convert.rgb2hsl(RGB)
local CMYK = convert.rgb2cmyk(RGB)
local R, G, B = unpack(RGB)
local H, S, L = unpack(HSL)
local C, M, Y, K = unpack(CMYK)
return { R, G, B, H, S, L, C, M, Y, K }
end
function RgbHslCmykInput.to_rgb(value)
return { value[1], value[2], value[3] }
end
function RgbHslCmykInput:_set_rgb(RGB)
self.value[1] = RGB[1]
self.value[2] = RGB[2]
self.value[3] = RGB[3]
end
function RgbHslCmykInput:_set_hsl(HSL)
self.value[4] = HSL[1]
self.value[5] = HSL[2]
self.value[6] = HSL[3]
end
function RgbHslCmykInput:_set_cmyk(CMYK)
self.value[7] = CMYK[1]
self.value[8] = CMYK[2]
self.value[9] = CMYK[3]
self.value[10] = CMYK[4]
end
function RgbHslCmykInput:callback(index, new_value)
self.value[index] = new_value
local v = self.value
if index <= 3 then
local RGB = { v[1], v[2], v[3] }
local HSL = convert.rgb2hsl(RGB)
local CMYK = convert.rgb2cmyk(RGB)
self:_set_hsl(HSL)
self:_set_cmyk(CMYK)
elseif index <= 6 then
local HSL = { v[4], v[5], v[6] }
local RGB = convert.hsl2rgb(HSL)
local CMYK = convert.rgb2cmyk(RGB)
self:_set_rgb(RGB)
self:_set_cmyk(CMYK)
else
local CMYK = { v[7], v[8], v[9], v[10] }
local RGB = convert.cmyk2rgb(CMYK)
local HSL = convert.rgb2hsl(RGB)
self:_set_rgb(RGB)
self:_set_hsl(HSL)
end
end
local ccc = require 'ccc'
ccc.setup {
inputs = {
RgbHslCmykInput,
},
-- highlighter = {
-- auto_enable = false,
-- lsp = false,
-- },
}
end,
}, Interestingly, I just tried the following config: {
'uga-rosa/ccc.nvim',
branch = 'fix/117',
}, and I don't see any LS crashes. I don't know if the highlighing is still working. I just use ccc for the color picker. |
I can't try julia lsp because it won't start... |
Have you seen this? |
Request for other features
Some LSP servers do not support
textDocument/documentColor
. This leads to warnings, and, in worse cases, crashes.For example, LS for julia crashes when receiving a request for
textDocument/documentColor
.Would it be possible to not generate these requests when the LSP does not support it? This can be deduced from server capabilities, i.e.
For example, julia LS declares here that it doesn't support
textDocument/documentColor
.Thanks!
The text was updated successfully, but these errors were encountered: