2022-12-21 12:36:00 +08:00
|
|
|
|
# Trans.nvim
|
2023-01-16 00:43:17 +08:00
|
|
|
|
|
|
|
|
|
<!--toc:start-->
|
2023-02-04 15:03:02 +08:00
|
|
|
|
|
2023-03-18 19:05:26 +08:00
|
|
|
|
- [Trans.nvim](#transnvim) - [注意: 当前分支目前没有发布, README.md 的描述并不准确, 遇到问题请切换到 `main`分支或者联系我](#注意-当前分支目前没有发布-readmemd-的描述并不准确-遇到问题请切换到-main分支或者联系我)
|
2023-03-10 09:15:53 +08:00
|
|
|
|
- [特点](#特点)
|
|
|
|
|
- [屏幕截图](#屏幕截图)
|
|
|
|
|
- [演示](#演示)
|
|
|
|
|
- [主题](#主题)
|
|
|
|
|
- [安装](#安装)
|
|
|
|
|
- [配置](#配置)
|
|
|
|
|
- [快捷键绑定](#快捷键绑定)
|
|
|
|
|
- [高亮组](#高亮组)
|
|
|
|
|
- [声明](#声明)
|
|
|
|
|
- [感谢](#感谢)
|
|
|
|
|
- [贡献](#贡献)
|
|
|
|
|
- [待办 (画大饼)](#待办-画大饼)
|
2023-03-18 19:05:26 +08:00
|
|
|
|
- [项目情况](#项目情况)
|
2023-03-10 09:15:53 +08:00
|
|
|
|
<!--toc:end-->
|
2022-12-21 22:17:58 +08:00
|
|
|
|
|
2023-03-17 10:17:37 +08:00
|
|
|
|
### 注意: 当前分支目前没有发布, README.md 的描述并不准确, 遇到问题请切换到 `main`分支或者联系我
|
2023-03-17 08:15:10 +08:00
|
|
|
|
|
2022-12-21 12:36:00 +08:00
|
|
|
|
## 特点
|
2023-02-04 15:03:02 +08:00
|
|
|
|
|
2023-03-10 09:15:53 +08:00
|
|
|
|
- 使用纯 lua 编写, 速度极快
|
|
|
|
|
|
|
|
|
|
> `Lazy.nvim`的记录: <font color="#0099FF">`➜ Trans.nvim 0.82ms`</font>
|
|
|
|
|
|
|
|
|
|
- **可以定义快捷键读英文单词**
|
|
|
|
|
|
|
|
|
|
> 见 wiki
|
|
|
|
|
|
|
|
|
|
- 大部分功能可以自定义:
|
|
|
|
|
- 高亮
|
|
|
|
|
- 悬浮大小
|
|
|
|
|
- 排版顺序
|
|
|
|
|
- 弹窗大小
|
|
|
|
|
- `舒服窗口动画`
|
|
|
|
|
- etc (更多可以查看[配置](#配置))
|
|
|
|
|
- **完全离线** 的单词翻译体验 (可能后面会支持在线翻译)
|
|
|
|
|
- 支持显示:
|
|
|
|
|
- 柯林斯星级
|
|
|
|
|
- 牛津 3000 词汇
|
|
|
|
|
- 中文翻译
|
|
|
|
|
- 英文翻译 (不是英译中, 而是用英文解释)
|
|
|
|
|
- 词根
|
|
|
|
|
- etc
|
|
|
|
|
- 舒服的排版和`动画`
|
|
|
|
|
- 支持 `normal`和 `visual`模式
|
|
|
|
|
> <font color='#FF9900'>不支持 visual-block mode</font>
|
|
|
|
|
- 本地词库单词量: `430w`
|
2023-02-04 15:03:02 +08:00
|
|
|
|
|
2022-12-21 12:36:00 +08:00
|
|
|
|
## 屏幕截图
|
2023-02-04 15:03:02 +08:00
|
|
|
|
|
2023-01-25 17:19:07 +08:00
|
|
|
|
### 演示
|
2023-02-04 15:03:02 +08:00
|
|
|
|
|
2023-01-21 00:24:58 +08:00
|
|
|
|
https://user-images.githubusercontent.com/107862700/213752097-2eee026a-ddee-4531-bf80-ba2cbc8b44ef.mp4
|
2022-12-21 12:36:00 +08:00
|
|
|
|
|
2023-01-31 23:17:03 +08:00
|
|
|
|
> 视频演示的在线查询, 查询速度取决于你的网络状况
|
|
|
|
|
> 可以打开音量查看自动读音
|
|
|
|
|
|
|
|
|
|
https://user-images.githubusercontent.com/107862700/215941500-3293c571-20a1-44e2-b202-77079f158ce9.mp4
|
|
|
|
|
|
2023-01-25 17:19:07 +08:00
|
|
|
|
### 主题
|
|
|
|
|
|
2023-02-04 15:03:02 +08:00
|
|
|
|
> 如果你有更美观或者更适合的配色, 欢迎提 PR
|
|
|
|
|
> 主题配色在: `lua/Trans/theme.lua`文件中,你只需要添加你主题的表就可以了
|
2023-01-25 17:19:07 +08:00
|
|
|
|
|
2023-03-10 09:15:53 +08:00
|
|
|
|
- `default`
|
|
|
|
|

|
2023-01-25 17:19:07 +08:00
|
|
|
|
|
2023-03-10 09:15:53 +08:00
|
|
|
|
- `dracula`
|
|
|
|
|

|
2023-01-25 17:19:07 +08:00
|
|
|
|
|
2023-03-10 09:15:53 +08:00
|
|
|
|
- `tokyonight`
|
|
|
|
|

|
2022-12-21 12:36:00 +08:00
|
|
|
|
|
|
|
|
|
## 安装
|
2023-02-04 15:03:02 +08:00
|
|
|
|
|
|
|
|
|
_安装之前, 首先需要明确本插件的依赖:_
|
|
|
|
|
|
2023-03-10 09:15:53 +08:00
|
|
|
|
- [ECDICT](https://github.com/skywind3000/ECDICT): 插件所用的离线单词数据库
|
|
|
|
|
- [sqlite.lua](https://github.com/kkharji/sqlite.lua): 操作数据库所用的库
|
|
|
|
|
- sqlite3: 数据库
|
2022-12-21 12:36:00 +08:00
|
|
|
|
|
2023-01-30 22:00:27 +08:00
|
|
|
|
<details>
|
|
|
|
|
<summary>Packer.nvim</summary>
|
2023-01-21 00:24:58 +08:00
|
|
|
|
|
2022-12-21 12:36:00 +08:00
|
|
|
|
```lua
|
|
|
|
|
use {
|
|
|
|
|
'JuanZoran/Trans.nvim'
|
2023-03-10 09:15:53 +08:00
|
|
|
|
run = function() require('Trans').install() end, -- 自动下载使用的本地词库
|
2023-03-17 10:17:37 +08:00
|
|
|
|
requires = 'kkharji/sqlite.lua', ,
|
2022-12-21 12:36:00 +08:00
|
|
|
|
-- 如果你不需要任何配置的话, 可以直接按照下面的方式启动
|
2023-01-21 00:24:58 +08:00
|
|
|
|
config = function ()
|
|
|
|
|
require'Trans'.setup{
|
|
|
|
|
-- your configuration here
|
|
|
|
|
}
|
|
|
|
|
end
|
2022-12-25 09:02:37 +08:00
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
2023-02-04 15:03:02 +08:00
|
|
|
|
**如果你想要使用 Packer 的惰性加载,这里有一个例子**
|
|
|
|
|
|
2022-12-25 09:02:37 +08:00
|
|
|
|
```lua
|
|
|
|
|
use {
|
|
|
|
|
"JuanZoran/Trans.nvim",
|
|
|
|
|
keys = {
|
2023-02-01 17:03:02 +08:00
|
|
|
|
{ {'n', 'x'}, 'mm' }, -- 换成其他你想用的key即可
|
2023-02-04 15:03:02 +08:00
|
|
|
|
{ {'n', 'x'}, 'mk' },
|
2023-01-16 12:10:09 +08:00
|
|
|
|
{ 'n', 'mi' },
|
2022-12-25 09:02:37 +08:00
|
|
|
|
},
|
2023-03-10 09:15:53 +08:00
|
|
|
|
run = function() require('Trans').install() end, -- 自动下载使用的本地词库
|
2023-03-10 11:35:14 +08:00
|
|
|
|
requires = { 'kkharji/sqlite.lua', },
|
2022-12-25 09:02:37 +08:00
|
|
|
|
config = function()
|
2023-01-16 00:43:17 +08:00
|
|
|
|
require("Trans").setup {} -- 启动Trans
|
2023-02-01 17:03:02 +08:00
|
|
|
|
vim.keymap.set({"n", 'x'}, "mm", '<Cmd>Translate<CR>', { desc = ' Translate' }) -- 自动判断virtual 还是 normal 模式
|
|
|
|
|
vim.keymap.set({'n', 'x'}, 'mk', '<Cmd>TransPlay<CR>', {desc = ' 自动发音'}) -- 自动发音选中或者光标下的单词
|
2022-12-25 09:02:37 +08:00
|
|
|
|
end
|
2022-12-21 12:36:00 +08:00
|
|
|
|
}
|
|
|
|
|
```
|
2023-02-04 15:03:02 +08:00
|
|
|
|
|
2023-01-30 22:00:27 +08:00
|
|
|
|
</details>
|
|
|
|
|
|
|
|
|
|
<details>
|
|
|
|
|
<summary>Lazy.nvim</summary>
|
2022-12-25 09:02:37 +08:00
|
|
|
|
|
2023-01-26 13:18:40 +08:00
|
|
|
|
```lua
|
|
|
|
|
{
|
|
|
|
|
"JuanZoran/Trans.nvim",
|
|
|
|
|
keys = {
|
|
|
|
|
-- 可以换成其他你想映射的键
|
|
|
|
|
{ 'mm', mode = { 'n', 'x' }, '<Cmd>Translate<CR>', desc = ' Translate' },
|
2023-02-01 17:03:02 +08:00
|
|
|
|
{ 'mk', mode = { 'n', 'x' }, '<Cmd>TransPlay<CR>', desc = ' 自动发音' },
|
2023-01-26 13:18:40 +08:00
|
|
|
|
|
|
|
|
|
-- 目前这个功能的视窗还没有做好,可以在配置里将view.i改成hover
|
|
|
|
|
{ 'mi', '<Cmd>TranslateInput<CR>', desc = ' Translate From Input' },
|
|
|
|
|
},
|
2023-03-10 11:35:14 +08:00
|
|
|
|
dependencies = { 'kkharji/sqlite.lua', },
|
2023-01-26 13:18:40 +08:00
|
|
|
|
opts = {
|
|
|
|
|
-- your configuration there
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
```
|
2023-02-04 15:03:02 +08:00
|
|
|
|
|
2023-01-30 22:00:27 +08:00
|
|
|
|
</details>
|
2023-01-26 13:18:40 +08:00
|
|
|
|
|
2023-02-04 15:03:02 +08:00
|
|
|
|
<font color="#FF9900">**注意事项**: </font>
|
|
|
|
|
|
2023-03-10 09:15:53 +08:00
|
|
|
|
- `install.sh`
|
2023-02-04 15:03:02 +08:00
|
|
|
|
|
2023-03-10 09:15:53 +08:00
|
|
|
|
- 使用了 `wget`下载词库, 安装请确保你的环境变量中存在 wget
|
|
|
|
|
- install.sh 下载后会自动将词库解压, 并移动到 `$HOME/.vim/dict`文件夹下
|
|
|
|
|
- 目前仅在 `Ubuntu22.04`的环境下测试通过
|
|
|
|
|
> 如果上述条件不符合, 请删掉 `run = 'install.sh'`部分, 考虑手动安装词库
|
|
|
|
|
> 如果上述条件满足, 仍出现问题, 欢迎在 issue 里向我反馈,我会及时尝试解决
|
2022-12-21 12:36:00 +08:00
|
|
|
|
|
2023-03-10 09:15:53 +08:00
|
|
|
|
- 下载词典的过程中, 需要能够 `流畅的访问github下载`
|
2023-02-04 15:03:02 +08:00
|
|
|
|
|
2023-03-10 09:15:53 +08:00
|
|
|
|
> 词库文件压缩包大小为: **281M**
|
|
|
|
|
> 解压缩后的大小大概为: 1.2G
|
2022-12-21 12:36:00 +08:00
|
|
|
|
|
2023-03-10 09:15:53 +08:00
|
|
|
|
- 安装后如果不能正常运行, 请尝试检查一下问题:
|
2023-02-04 15:03:02 +08:00
|
|
|
|
|
2023-03-10 09:15:53 +08:00
|
|
|
|
- 本机是否已经安装了 `sqlite3`
|
|
|
|
|
> Linux 下安装:
|
|
|
|
|
> `sudo pacman -S sqlite # Arch`
|
|
|
|
|
> `sudo apt-get install sqlite3 libsqlite3-dev # Ubuntu`
|
2023-02-04 15:03:02 +08:00
|
|
|
|
|
2023-03-17 10:17:37 +08:00
|
|
|
|
> **尝试运行 `checkhealth Trans`**
|
2022-12-21 12:36:00 +08:00
|
|
|
|
|
2023-03-10 09:15:53 +08:00
|
|
|
|
- **`auto_play`** 使用步骤:
|
2023-02-04 15:03:02 +08:00
|
|
|
|
|
2023-03-10 09:15:53 +08:00
|
|
|
|
> linux 只需要安装`festival`
|
|
|
|
|
> sudo apt-get install festival festvox-kallpc16k
|
|
|
|
|
> **_如果你想要设置音色,发音可以访问:_** [Festival 官方](https://www.cstr.ed.ac.uk/projects/festival/morevoices.html)
|
|
|
|
|
> 可以选择英音、美音、男声、女声
|
2023-02-04 15:03:02 +08:00
|
|
|
|
|
2023-03-10 09:15:53 +08:00
|
|
|
|
> 其他操作系统
|
2023-02-04 15:03:02 +08:00
|
|
|
|
|
2023-03-10 09:15:53 +08:00
|
|
|
|
- 需要确保安装了`nodejs`
|
|
|
|
|
- 进入插件的`tts`目录运行`npm install`
|
|
|
|
|
> 如果`install`运行正常则自动安装,如果安装失败,请尝试手动安装
|
2023-02-04 15:03:02 +08:00
|
|
|
|
|
2023-03-10 09:15:53 +08:00
|
|
|
|
- `title`的配置,只对`neovim 0.9+`版本有效
|
2022-12-21 12:36:00 +08:00
|
|
|
|
|
2023-01-30 22:00:27 +08:00
|
|
|
|
<details>
|
|
|
|
|
<summary>Festival配置(仅针对linux用户)</summary>
|
2023-01-22 10:15:23 +08:00
|
|
|
|
- 配置文件
|
|
|
|
|
- 全局配置: `/usr/share/festival/siteinit.scm`
|
|
|
|
|
- 用户配置: `~/.festivalrc`
|
|
|
|
|
|
2023-03-10 09:15:53 +08:00
|
|
|
|
- 更改声音
|
2023-01-22 10:15:23 +08:00
|
|
|
|
|
2023-03-10 09:15:53 +08:00
|
|
|
|
- 在 festival 的 voices 文件内建立自己的文件夹
|
2023-02-04 15:03:02 +08:00
|
|
|
|
|
2023-03-10 09:15:53 +08:00
|
|
|
|
> 一般其默认配置目录在`/usr/share/festival/voices`
|
2023-02-04 15:03:02 +08:00
|
|
|
|
|
2023-03-10 09:15:53 +08:00
|
|
|
|
示例:
|
2023-02-04 15:03:02 +08:00
|
|
|
|
|
2023-03-10 09:15:53 +08:00
|
|
|
|
> `sudo mkdir /usr/share/festival/voices/my_voices`
|
2023-01-22 10:15:23 +08:00
|
|
|
|
|
2023-03-10 09:15:53 +08:00
|
|
|
|
- 下载想要的 voices 文件并解压
|
2023-01-22 10:15:23 +08:00
|
|
|
|
|
2023-03-10 09:15:53 +08:00
|
|
|
|
> 可能需要
|
2023-01-22 10:15:23 +08:00
|
|
|
|
|
2023-03-10 09:15:53 +08:00
|
|
|
|
- 试听[在这里](https://www.cstr.ed.ac.uk/projects/festival/morevoices.html))
|
|
|
|
|
- 下载[在这里](http://festvox.org/packed/festival/2.5/voices/))
|
|
|
|
|
> 假设下载的文件在`Downloads`文件夹, 下载的文件为:`festvox_cmu_us_aew_cg.tar.gz`
|
2023-01-22 10:15:23 +08:00
|
|
|
|
|
2023-03-10 09:15:53 +08:00
|
|
|
|
示例:
|
2023-01-22 10:15:23 +08:00
|
|
|
|
|
2023-03-10 09:15:53 +08:00
|
|
|
|
> `cd ~/Downloads && tar -xf festvox_cmu_us_aew_cg.tar.gz`
|
2023-01-22 10:15:23 +08:00
|
|
|
|
|
2023-03-10 09:15:53 +08:00
|
|
|
|
- 将音频文件拷贝到 festival 文件夹
|
|
|
|
|
示例:
|
2023-02-04 15:03:02 +08:00
|
|
|
|
|
2023-03-10 09:15:53 +08:00
|
|
|
|
> `sudo cp -r festival/lib/voices/us/cmu_us_aew_cg/ /usr/share/festival/voices/my_voices/`
|
2023-02-04 15:03:02 +08:00
|
|
|
|
|
2023-03-10 09:15:53 +08:00
|
|
|
|
- 在配置文件中设置默认的声音
|
|
|
|
|
示例:
|
2023-02-04 15:03:02 +08:00
|
|
|
|
|
2023-03-10 09:15:53 +08:00
|
|
|
|
> 加入`(set! voice_default voice_cmu_indic_hin_ab_cg)`到配置文件
|
2023-02-04 15:03:02 +08:00
|
|
|
|
|
2023-03-10 09:15:53 +08:00
|
|
|
|
- 安装完成
|
2023-01-22 10:15:23 +08:00
|
|
|
|
|
2023-03-10 09:15:53 +08:00
|
|
|
|
- 相关说明网站
|
|
|
|
|
> 可能需要
|
|
|
|
|
- [wiki](https://archlinux.org/packages/community/any/festival-us/) 查看更多详细配置
|
|
|
|
|
- [官方网站](http://festvox.org/dbs/index.html)
|
|
|
|
|
- [用户手册](http://www.festvox.org/docs/manual-2.4.0/festival_toc.html)
|
2023-01-22 10:15:23 +08:00
|
|
|
|
|
2023-01-30 22:00:27 +08:00
|
|
|
|
</details>
|
|
|
|
|
|
2022-12-21 12:36:00 +08:00
|
|
|
|
## 配置
|
2023-02-04 15:03:02 +08:00
|
|
|
|
|
2022-12-21 12:36:00 +08:00
|
|
|
|
```lua
|
2023-03-17 10:17:37 +08:00
|
|
|
|
require'Trans'.setup {
|
2023-03-15 19:27:21 +08:00
|
|
|
|
---@type string the directory for database file and password file
|
|
|
|
|
dir = os.getenv('HOME') .. '/.vim/dict',
|
2023-03-17 10:17:37 +08:00
|
|
|
|
query = 'fallback',
|
|
|
|
|
-- backend_order = {},
|
|
|
|
|
---@type 'default' | 'dracula' | 'tokyonight' global Trans theme [see lua/Trans/style/theme.lua]
|
|
|
|
|
theme = 'default', -- default | tokyonight | dracula
|
2023-03-15 19:27:21 +08:00
|
|
|
|
strategy = {
|
2023-03-17 10:17:37 +08:00
|
|
|
|
---@type { frontend:string, backend:string | string[] } fallback strategy for mode
|
2023-03-15 19:27:21 +08:00
|
|
|
|
default = {
|
|
|
|
|
frontend = 'hover',
|
|
|
|
|
backend = '*',
|
|
|
|
|
},
|
2023-01-14 10:37:21 +08:00
|
|
|
|
},
|
2023-03-15 19:27:21 +08:00
|
|
|
|
---@type table frontend options
|
|
|
|
|
frontend = {
|
|
|
|
|
---@class TransFrontendOpts
|
|
|
|
|
---@field keymaps table<string, string>
|
|
|
|
|
default = {
|
|
|
|
|
---@type boolean Whether to auto play the audio
|
|
|
|
|
auto_play = true,
|
|
|
|
|
border = 'rounded',
|
|
|
|
|
title = title, -- need nvim-0.9
|
|
|
|
|
---@type {open: string | boolean, close: string | boolean, interval: integer} Hover Window Animation
|
|
|
|
|
animation = {
|
|
|
|
|
open = 'slid', -- 'fold', 'slid'
|
|
|
|
|
close = 'slid',
|
|
|
|
|
interval = 12,
|
|
|
|
|
},
|
2023-03-17 10:17:37 +08:00
|
|
|
|
timeout = 2000,
|
2023-01-21 21:13:51 +08:00
|
|
|
|
},
|
2023-03-15 19:27:21 +08:00
|
|
|
|
---@class TransHoverOpts : TransFrontendOpts
|
|
|
|
|
hover = {
|
|
|
|
|
---@type integer Max Width of Hover Window
|
|
|
|
|
width = 37,
|
|
|
|
|
---@type integer Max Height of Hover Window
|
|
|
|
|
height = 27,
|
|
|
|
|
---@type string -- see: /lua/Trans/style/spinner
|
|
|
|
|
spinner = 'dots',
|
|
|
|
|
---@type string -- TODO :support replace with {{special word}}
|
2023-03-17 10:17:37 +08:00
|
|
|
|
fallback_message = '{{notfound}} 翻译超时或没有找到相关的翻译',
|
2023-03-15 19:27:21 +08:00
|
|
|
|
auto_resize = true,
|
2023-03-17 10:17:37 +08:00
|
|
|
|
-- strict = false, -- TODO :No Width limit when str is a sentence
|
2023-03-15 19:27:21 +08:00
|
|
|
|
padding = 10, -- padding for hover window width
|
|
|
|
|
keymaps = {
|
|
|
|
|
pageup = '[[',
|
|
|
|
|
pagedown = ']]',
|
|
|
|
|
pin = '<leader>[',
|
|
|
|
|
close = '<leader>]',
|
|
|
|
|
toggle_entry = '<leader>;',
|
2023-03-17 10:17:37 +08:00
|
|
|
|
-- play = '_', -- Deprecated
|
2023-03-15 19:27:21 +08:00
|
|
|
|
},
|
|
|
|
|
---@type string[] auto close events
|
|
|
|
|
auto_close_events = {
|
|
|
|
|
'InsertEnter',
|
|
|
|
|
'CursorMoved',
|
|
|
|
|
'BufLeave',
|
|
|
|
|
},
|
2023-03-17 10:17:37 +08:00
|
|
|
|
---@type table<string, string[]> order to display translate result
|
2023-03-15 19:27:21 +08:00
|
|
|
|
order = {
|
2023-03-17 10:17:37 +08:00
|
|
|
|
default = {
|
|
|
|
|
'str',
|
|
|
|
|
'translation',
|
|
|
|
|
'definition',
|
|
|
|
|
},
|
|
|
|
|
offline = {
|
|
|
|
|
'title',
|
|
|
|
|
'tag',
|
|
|
|
|
'pos',
|
|
|
|
|
'exchange',
|
|
|
|
|
'translation',
|
|
|
|
|
'definition',
|
|
|
|
|
},
|
|
|
|
|
youdao = {
|
|
|
|
|
'title',
|
|
|
|
|
'translation',
|
|
|
|
|
'definition',
|
|
|
|
|
'web',
|
|
|
|
|
}
|
2023-03-15 19:27:21 +08:00
|
|
|
|
},
|
|
|
|
|
---@type table<string, string>
|
|
|
|
|
icon = {
|
|
|
|
|
-- or use emoji
|
2023-03-17 10:17:37 +08:00
|
|
|
|
list = '●', -- ● | ○ | ◉ | ◯ | ◇ | ◆ | ▪ | ▫ | ⬤ | 🟢 | 🟡 | 🟣 | 🟤 | 🟦 | 🟨 | 🟧 | 🟥 | 🟪 | 🟫 | 🟩 | 🟠 | 🟦 | 🟨 | 🟧 | 🟥 | 🟪 | 🟫 | 🟩 | 🟠
|
|
|
|
|
star = '', -- ⭐ | ✴ | ✳ | ✲ | ✱ | ✰ | ★ | ☆ | 🌟 | 🌠 | 🌙 | 🌛 | 🌜 | 🌟 | 🌠 | 🌌 | 🌙 |
|
|
|
|
|
notfound = ' ', --❔ | ❓ | ❗ | ❕|
|
|
|
|
|
yes = '✔', -- ✅ | ✔️ | ☑
|
|
|
|
|
no = '', -- ❌ | ❎ | ✖ | ✘ | ✗ |
|
|
|
|
|
cell = '■', -- ■ | □ | ▇ | ▏ ▎ ▍ ▌ ▋ ▊ ▉ █
|
|
|
|
|
web = '', --🌍 | 🌎 | 🌏 | 🌐 |
|
|
|
|
|
tag = ' ',
|
|
|
|
|
pos = '',
|
|
|
|
|
translation = '',
|
|
|
|
|
definition = '',
|
|
|
|
|
exchange = '✳',
|
2023-03-15 19:27:21 +08:00
|
|
|
|
},
|
2023-01-21 21:13:51 +08:00
|
|
|
|
},
|
2022-12-21 12:36:00 +08:00
|
|
|
|
},
|
2023-03-17 10:17:37 +08:00
|
|
|
|
}p
|
2023-02-04 15:03:02 +08:00
|
|
|
|
|
2022-12-21 12:36:00 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## 快捷键绑定
|
2023-02-04 15:03:02 +08:00
|
|
|
|
|
2022-12-21 16:59:26 +08:00
|
|
|
|
**示例:**
|
2023-02-04 15:03:02 +08:00
|
|
|
|
|
2022-12-21 16:59:26 +08:00
|
|
|
|
> 示例中展示, 将`mm`映射成快捷键
|
2023-02-04 15:03:02 +08:00
|
|
|
|
|
2022-12-21 16:59:26 +08:00
|
|
|
|
```lua
|
2023-02-01 16:47:50 +08:00
|
|
|
|
vim.keymap.set({'n', 'x'}, 'mm', '<Cmd>Translate<CR>')
|
|
|
|
|
vim.keymap.set({'n', 'x'}, 'mk', '<Cmd>TransPlay<CR>') -- 自动发音选中或者光标下的单词
|
2022-12-21 16:59:26 +08:00
|
|
|
|
```
|
2022-12-21 12:36:00 +08:00
|
|
|
|
|
2022-12-21 17:05:28 +08:00
|
|
|
|
## 高亮组
|
2023-02-04 15:03:02 +08:00
|
|
|
|
|
2023-01-21 08:08:01 +08:00
|
|
|
|
> 默认定义
|
2023-02-04 15:03:02 +08:00
|
|
|
|
|
2022-12-21 17:05:28 +08:00
|
|
|
|
```lua
|
2023-01-21 08:08:01 +08:00
|
|
|
|
{
|
2023-03-17 10:17:37 +08:00
|
|
|
|
TransWord = {
|
|
|
|
|
fg = '#7ee787',
|
|
|
|
|
bold = true,
|
|
|
|
|
},
|
|
|
|
|
TransPhonetic = {
|
|
|
|
|
link = 'Linenr'
|
|
|
|
|
},
|
|
|
|
|
TransTitle = {
|
|
|
|
|
fg = '#0f0f15',
|
|
|
|
|
bg = '#75beff',
|
|
|
|
|
bold = true,
|
|
|
|
|
},
|
|
|
|
|
TransTitleRound = {
|
|
|
|
|
fg = '#75beff',
|
|
|
|
|
},
|
|
|
|
|
TransTag = {
|
|
|
|
|
-- fg = '#e5c07b',
|
|
|
|
|
link = '@tag'
|
|
|
|
|
},
|
|
|
|
|
TransExchange = {
|
|
|
|
|
link = 'TransTag',
|
|
|
|
|
},
|
|
|
|
|
TransPos = {
|
|
|
|
|
link = 'TransTag',
|
|
|
|
|
},
|
|
|
|
|
TransTranslation = {
|
|
|
|
|
link = 'TransWord',
|
|
|
|
|
},
|
|
|
|
|
TransDefinition = {
|
|
|
|
|
link = 'Moremsg',
|
|
|
|
|
},
|
|
|
|
|
TransWin = {
|
|
|
|
|
link = 'Normal',
|
|
|
|
|
},
|
|
|
|
|
TransBorder = {
|
|
|
|
|
fg = '#89B4FA',
|
|
|
|
|
},
|
|
|
|
|
TransCollins = {
|
|
|
|
|
fg = '#faf743',
|
|
|
|
|
bold = true,
|
|
|
|
|
},
|
|
|
|
|
TransFailed = {
|
|
|
|
|
fg = '#7aa89f',
|
|
|
|
|
},
|
|
|
|
|
TransWaitting = {
|
|
|
|
|
link = 'MoreMsg'
|
|
|
|
|
},
|
|
|
|
|
TransWeb = {
|
|
|
|
|
-- TODO :
|
|
|
|
|
link = 'MoreMsg',
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-12-21 17:05:28 +08:00
|
|
|
|
```
|
2023-01-30 20:09:57 +08:00
|
|
|
|
|
2022-12-21 12:36:00 +08:00
|
|
|
|
## 声明
|
2023-02-04 15:03:02 +08:00
|
|
|
|
|
2023-03-10 09:15:53 +08:00
|
|
|
|
- 本插件词典基于[ECDICT](https://github.com/skywind3000/ECDICT)
|
2022-12-21 12:36:00 +08:00
|
|
|
|
|
|
|
|
|
## 感谢
|
2023-02-04 15:03:02 +08:00
|
|
|
|
|
2023-03-10 09:15:53 +08:00
|
|
|
|
- [ECDICT](https://github.com/skywind3000/ECDICT) 本地词典的提供
|
|
|
|
|
- [sqlite.lua](https://github.com/kharji/sqlite.lua) 数据库访问
|
|
|
|
|
- [T.vim](https://github.com/sicong-li/T.vim) 灵感来源
|
2022-12-21 12:36:00 +08:00
|
|
|
|
|
2023-02-01 17:03:02 +08:00
|
|
|
|
## 贡献
|
2023-02-04 15:03:02 +08:00
|
|
|
|
|
2023-02-01 17:03:02 +08:00
|
|
|
|
> 更新比较频繁, 文档先鸽了
|
2023-02-04 15:03:02 +08:00
|
|
|
|
> 如果你想要参加这个项目, 可以提 issue, 我会把文档补齐
|
2023-02-01 17:03:02 +08:00
|
|
|
|
|
2023-01-20 17:06:49 +08:00
|
|
|
|
## 待办 (画大饼)
|
2023-02-04 15:03:02 +08:00
|
|
|
|
|
2023-03-10 09:15:53 +08:00
|
|
|
|
- [x] 快捷键定义
|
|
|
|
|
- [x] 自动读音
|
2023-03-17 10:17:37 +08:00
|
|
|
|
- [x] 在线多引擎异步查询
|
|
|
|
|
- [x] `句子翻译` | `中翻英` 的支持
|
|
|
|
|
- [ ] 多风格样式查询
|
|
|
|
|
- [ ] 重新录制屏幕截图示例
|
2023-03-10 09:15:53 +08:00
|
|
|
|
- [ ] 变量命名的支持
|
|
|
|
|
- [ ] 历史查询结果保存
|
2023-03-18 19:05:26 +08:00
|
|
|
|
|
|
|
|
|
## 项目情况
|
|
|
|
|
|
|
|
|
|
[](https://star-history.com/#JuanZoran/Trans.nvim&Date)
|