lua-language-server icon indicating copy to clipboard operation
lua-language-server copied to clipboard

支持RRGGBB的6位颜色格式

Open MrZ626 opened this issue 7 months ago • 4 comments

既然 #3169 增加了"#RRGGBB"格式颜色的支持,那一些项目中有不带井号的6位颜色字符串也一起支持一下吧 顺便把这部分功能做成更容易拓展的了

MrZ626 avatar Jun 07 '25 03:06 MrZ626

那一些项目中有不带井号的6位颜色字符串也一起支持一下吧

不帶井號的 6位/8位長度的 string,不一定就是 color code 吧 😕

  • 隨便舉例:
local dbconf = {
    user = "root",
    pass = "123456",
    database = "test",
}

=> 這樣 "123456" 就被當成 color code 了

  • 還有比如1個 literal data table 其 key 就單純是1個 6位/8位字符長的 short hash 也全都當成 color code 了呢
local DATA = {
    ["000000"] = {
        field = "a",
    },
    ["000001"] = {
        field = "b",
    },
}

沒有 # prefix 也當成 color code,似會造成較多誤判 或者可以考慮增加1個 config,讓 user 有需要時才打開? 🤔

  • 比如說有個 semantic.rgbColorMode
  • 預設是 prefix => 即現有帶 # 號的 detect 方式
  • 可以有個 all => 不帶 # 號也做 detect,你的 use case
  • 最後還可以有個 disable => 完全禁用 (這個是 bonus,或者先不用 implement)

tomlau10 avatar Jun 08 '25 01:06 tomlau10

Sumneko Lua translate bot


Some projects have 6-bit color strings without pound marks, and support them together.

A 6-bit/8-bit length string without a pound mark may not be a color code 😕

  • Give some examples:
local dbconf = {
    user = "root",
    pass = "123456",
    database = "test",
}

=> In this way "123456" is regarded as a color code

  • There is also 1 literal data table The key is simply a short hash with 6-bit/8-bit characters long All of them are considered color codes
local DATA = {
    ["000000"] = {
        field = "a",
    },
    ["000001"] = {
        field = "b",
    },
}

No # prefix is ​​also regarded as a color code, which seems to cause more misjudgments Or can you consider adding 1 config to enable user to open when needed? 🤔

  • For example, there is a semantic.rgbColorMode
  • The preset is prefix =>, that is, the existing detect method with # number
  • You can have a all => detect without the # number, your use case
  • Finally, there can be a disable => completely disabled (this is bonus, or do not use implement for now)

Issues-translate-bot avatar Jun 08 '25 01:06 Issues-translate-bot

啊,那确实是应该加设置,之前八位数字也是会误判成颜色的,只是我运气好没遇见过🤣

MrZ626 avatar Jun 08 '25 02:06 MrZ626

Sumneko Lua translate bot


Ah, that should be set. The previous eight digits would be misjudged as colors, but I was lucky and never met them 🤣

Issues-translate-bot avatar Jun 08 '25 02:06 Issues-translate-bot