From aabe1f3a8f4236adc9b995b669da02c1cec15b56 Mon Sep 17 00:00:00 2001 From: JuanZoran <1430359574@qq.com> Date: Fri, 17 Mar 2023 09:26:55 +0800 Subject: [PATCH] feat: more icon support --- lua/Trans/core/conf.lua | 18 ++++++++++++------ lua/Trans/frontend/hover/load.lua | 4 ++-- lua/Trans/frontend/hover/offline.lua | 6 +++--- lua/Trans/frontend/hover/youdao.lua | 2 +- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/lua/Trans/core/conf.lua b/lua/Trans/core/conf.lua index 0ff3a76..b26bd53 100644 --- a/lua/Trans/core/conf.lua +++ b/lua/Trans/core/conf.lua @@ -95,12 +95,18 @@ return { ---@type table icon = { -- or use emoji - list = '●', -- ● | ○ | ◉ | ◯ | ◇ | ◆ | ▪ | ▫ | ⬤ | ⬛ | ⬜ | ◻ | ◼ | ◾ | ◽ | ▣ | ▤ | ▥ | ▦ | ▧ | ▨ | ▩ | ▪ | ▫ | ▬ | ▭ | ▮ | ▯ | ◌ | ◍ | ◎ | ● | ◐ | ◑ | ◒ | ◓ | ◔ | ◕ | ◖ | ◗ | ◘ | ◙ | ◚ | ◛ | ◜ | ◝ | ◞ | ◟ | ◠ | ◡ | ◢ | ◣ | ◤ | ◥ | ◦ | ◧ | ◨ | ◩ | ◪ | ◫ | ◬ | ◭ | ◮ | ◯ | ◰ | ◱ | ◲ | ◳ | ◴ | ◵ | ◶ | ◷ | ◸ | ◹ | ◺ | ◻ | ◼ | ◽ | ◾ | ◿ | ☀ | ☁ | ☂ | ☃ | ☄ | ★ | ☆ | ☇ | ☈ | ☉ | ☊ | ☋ | ☌ | ☍ | ☎ | ☏ | ☐ | ☑ | ☒ | ☓ | ☔ | ☕ | ☖ | ☗ | ☘ | ☙ | ☚ | ☛ | ☜ | ☝ | ☞ | ☟ | ☠ | ☡ | ☢ | ☣ | ☤ | ☥ | ☦ | ☧ | ☨ | ☩ | ☪ | ☫ | ☬ | ☭ | ☮ | ☯ | ☰ | ☱ | ☲ | ☳ | ☴ | ☵ | ☶ | ☷ | ☸ | ☹ | ☺ | ☻ | ☼ | ☽ | ☾ | ☿ | ♀ | ♂ | ♁ | ♂ | ♃ | ♄ | ♅ | ♆ | ♇ | ♈ | ♉ | ♊ | ♋ | ♌ | ♍ | ♎ | ♏ | ♐ | ♑ | ♒ | ♓ | ♔ | ♕ | - star = '', -- ⭐ - notfound = ' ', -- ❔ - yes = '✔', -- ✔️ - no = '', -- ❌ - cell = '■', -- ■ | □ | ▇ | ▏ ▎ ▍ ▌ ▋ ▊ ▉ █ + list = '●', -- ● | ○ | ◉ | ◯ | ◇ | ◆ | ▪ | ▫ | ⬤ | 🟢 | 🟡 | 🟣 | 🟤 | 🟦 | 🟨 | 🟧 | 🟥 | 🟪 | 🟫 | 🟩 | 🟠 | 🟦 | 🟨 | 🟧 | 🟥 | 🟪 | 🟫 | 🟩 | 🟠 + star = '', -- ⭐ | ✴ | ✳ | ✲ | ✱ | ✰ | ★ | ☆ | 🌟 | 🌠 | 🌙 | 🌛 | 🌜 | 🌟 | 🌠 | 🌌 | 🌙 | + notfound = ' ', --❔ | ❓ | ❗ | ❕| + yes = '✔', -- ✅ | ✔️ | ☑ + no = '', -- ❌ | ❎ | ✖ | ✘ | ✗ | + cell = '■', -- ■ | □ | ▇ | ▏ ▎ ▍ ▌ ▋ ▊ ▉ █ + web = '󰖟', --🌍 | 🌎 | 🌏 | 🌐 | + tag = ' ', + pos = '', + translation = '󰊿', + definition = '󰗊', + exchange = '✳', }, }, }, diff --git a/lua/Trans/frontend/hover/load.lua b/lua/Trans/frontend/hover/load.lua index 82f45d5..b395017 100644 --- a/lua/Trans/frontend/hover/load.lua +++ b/lua/Trans/frontend/hover/load.lua @@ -28,7 +28,7 @@ local default = { if not translation then return end local buffer = hover.buffer - buffer:setline(conjunction('中文翻译')) + buffer:setline(conjunction(hover.opts.icon.translation .. ' 中文翻译')) for _, value in ipairs(translation) do buffer:setline( @@ -43,7 +43,7 @@ local default = { if not definition then return end local buffer = hover.buffer - buffer:setline(conjunction('英文注释')) + buffer:setline(conjunction(hover.opts.icon.definition .. ' 英文注释')) for _, value in ipairs(definition) do buffer:setline( diff --git a/lua/Trans/frontend/hover/offline.lua b/lua/Trans/frontend/hover/offline.lua index 919395b..776fa2d 100644 --- a/lua/Trans/frontend/hover/offline.lua +++ b/lua/Trans/frontend/hover/offline.lua @@ -42,7 +42,7 @@ function M.tag(hover, result) if not tag then return end local buffer = hover.buffer - buffer:setline(co('标签')) + buffer:setline(co(hover.opts.icon.tag .. ' 标签')) local size = #tag @@ -63,7 +63,7 @@ function M.exchange(hover, result) if not exchange then return end local buffer = hover.buffer - buffer:setline(co('词形变化')) + buffer:setline(co(hover.opts.icon.exchange .. ' 词形变化')) for description, value in pairs(exchange) do buffer:setline( @@ -79,7 +79,7 @@ function M.pos(hover, result) if not pos then return end local buffer = hover.buffer - buffer:setline(co('词性')) + buffer:setline(co(hover.opts.icon.pos .. ' 词性')) for description, value in pairs(pos) do buffer:setline( diff --git a/lua/Trans/frontend/hover/youdao.lua b/lua/Trans/frontend/hover/youdao.lua index a74dfa0..0819524 100644 --- a/lua/Trans/frontend/hover/youdao.lua +++ b/lua/Trans/frontend/hover/youdao.lua @@ -8,7 +8,7 @@ local interval = (' '):rep(4) function M.web(hover, result) if not result.web then return end local buffer = hover.buffer - buffer:setline(co('网络释义')) + buffer:setline(co(hover.opts.icon.web .. ' 网络释义')) local indent = interval .. interval .. hover.opts.icon.list .. ' ' local function remove_duplicate(strs)