refactor: use install.lua instead of install.sh
This commit is contained in:
parent
da1f847bd0
commit
35807247ff
318
README.md
318
README.md
@ -2,50 +2,50 @@
|
||||
|
||||
<!--toc:start-->
|
||||
|
||||
- [Trans.nvim](#transnvim)
|
||||
- [特点](#特点)
|
||||
- [屏幕截图](#屏幕截图)
|
||||
- [演示](#演示)
|
||||
- [主题](#主题)
|
||||
- [安装](#安装)
|
||||
- [配置](#配置)
|
||||
- [快捷键绑定](#快捷键绑定)
|
||||
- [高亮组](#高亮组)
|
||||
- [声明](#声明)
|
||||
- [感谢](#感谢)
|
||||
- [贡献](#贡献)
|
||||
- [待办 (画大饼)](#待办-画大饼)
|
||||
<!--toc:end-->
|
||||
- [Trans.nvim](#transnvim)
|
||||
- [特点](#特点)
|
||||
- [屏幕截图](#屏幕截图)
|
||||
- [演示](#演示)
|
||||
- [主题](#主题)
|
||||
- [安装](#安装)
|
||||
- [配置](#配置)
|
||||
- [快捷键绑定](#快捷键绑定)
|
||||
- [高亮组](#高亮组)
|
||||
- [声明](#声明)
|
||||
- [感谢](#感谢)
|
||||
- [贡献](#贡献)
|
||||
- [待办 (画大饼)](#待办-画大饼)
|
||||
<!--toc:end-->
|
||||
|
||||
## 特点
|
||||
|
||||
- 使用纯 lua 编写, 速度极快
|
||||
- 使用纯 lua 编写, 速度极快
|
||||
|
||||
> `Lazy.nvim`的记录: <font color="#0099FF">`➜ Trans.nvim 0.82ms`</font>
|
||||
> `Lazy.nvim`的记录: <font color="#0099FF">`➜ Trans.nvim 0.82ms`</font>
|
||||
|
||||
- **可以定义快捷键读英文单词**
|
||||
- **可以定义快捷键读英文单词**
|
||||
|
||||
> 见 wiki
|
||||
> 见 wiki
|
||||
|
||||
- 大部分功能可以自定义:
|
||||
- 高亮
|
||||
- 悬浮大小
|
||||
- 排版顺序
|
||||
- 弹窗大小
|
||||
- `舒服窗口动画`
|
||||
- etc (更多可以查看[配置](#配置))
|
||||
- **完全离线** 的单词翻译体验 (可能后面会支持在线翻译)
|
||||
- 支持显示:
|
||||
- 柯林斯星级
|
||||
- 牛津 3000 词汇
|
||||
- 中文翻译
|
||||
- 英文翻译 (不是英译中, 而是用英文解释)
|
||||
- 词根
|
||||
- etc
|
||||
- 舒服的排版和`动画`
|
||||
- 支持 `normal`和 `visual`模式
|
||||
> <font color='#FF9900'>不支持 visual-block mode</font>
|
||||
- 本地词库单词量: `430w`
|
||||
- 大部分功能可以自定义:
|
||||
- 高亮
|
||||
- 悬浮大小
|
||||
- 排版顺序
|
||||
- 弹窗大小
|
||||
- `舒服窗口动画`
|
||||
- etc (更多可以查看[配置](#配置))
|
||||
- **完全离线** 的单词翻译体验 (可能后面会支持在线翻译)
|
||||
- 支持显示:
|
||||
- 柯林斯星级
|
||||
- 牛津 3000 词汇
|
||||
- 中文翻译
|
||||
- 英文翻译 (不是英译中, 而是用英文解释)
|
||||
- 词根
|
||||
- etc
|
||||
- 舒服的排版和`动画`
|
||||
- 支持 `normal`和 `visual`模式
|
||||
> <font color='#FF9900'>不支持 visual-block mode</font>
|
||||
- 本地词库单词量: `430w`
|
||||
|
||||
## 屏幕截图
|
||||
|
||||
@ -63,22 +63,22 @@ https://user-images.githubusercontent.com/107862700/215941500-3293c571-20a1-44e2
|
||||
> 如果你有更美观或者更适合的配色, 欢迎提 PR
|
||||
> 主题配色在: `lua/Trans/theme.lua`文件中,你只需要添加你主题的表就可以了
|
||||
|
||||
- `default`
|
||||

|
||||
- `default`
|
||||

|
||||
|
||||
- `dracula`
|
||||

|
||||
- `dracula`
|
||||

|
||||
|
||||
- `tokyonight`
|
||||

|
||||
- `tokyonight`
|
||||

|
||||
|
||||
## 安装
|
||||
|
||||
_安装之前, 首先需要明确本插件的依赖:_
|
||||
|
||||
- [ECDICT](https://github.com/skywind3000/ECDICT): 插件所用的离线单词数据库
|
||||
- sqlite.lua: 操作数据库所用的库
|
||||
- sqlite3: 数据库
|
||||
- [ECDICT](https://github.com/skywind3000/ECDICT): 插件所用的离线单词数据库
|
||||
- [sqlite.lua](https://github.com/kkharji/sqlite.lua): 操作数据库所用的库
|
||||
- sqlite3: 数据库
|
||||
|
||||
<details>
|
||||
<summary>Packer.nvim</summary>
|
||||
@ -86,8 +86,8 @@ _安装之前, 首先需要明确本插件的依赖:_
|
||||
```lua
|
||||
use {
|
||||
'JuanZoran/Trans.nvim'
|
||||
run = 'bash ./install.sh',
|
||||
requires = 'kkharji/sqlite.lua',
|
||||
run = function() require('Trans').install() end, -- 自动下载使用的本地词库
|
||||
requires = { 'kkharji/sqlite.lua', 'nvim-lua/plenary.nvim' },
|
||||
-- 如果你不需要任何配置的话, 可以直接按照下面的方式启动
|
||||
config = function ()
|
||||
require'Trans'.setup{
|
||||
@ -107,8 +107,8 @@ use {
|
||||
{ {'n', 'x'}, 'mk' },
|
||||
{ 'n', 'mi' },
|
||||
},
|
||||
run = 'bash ./install.sh', -- 自动下载使用的本地词库
|
||||
requires = 'kkharji/sqlite.lua',
|
||||
run = function() require('Trans').install() end, -- 自动下载使用的本地词库
|
||||
requires = { 'kkharji/sqlite.lua', 'nvim-lua/plenary.nvim' },
|
||||
config = function()
|
||||
require("Trans").setup {} -- 启动Trans
|
||||
vim.keymap.set({"n", 'x'}, "mm", '<Cmd>Translate<CR>', { desc = ' Translate' }) -- 自动判断virtual 还是 normal 模式
|
||||
@ -134,7 +134,7 @@ use {
|
||||
-- 目前这个功能的视窗还没有做好,可以在配置里将view.i改成hover
|
||||
{ 'mi', '<Cmd>TranslateInput<CR>', desc = ' Translate From Input' },
|
||||
},
|
||||
dependencies = { 'kkharji/sqlite.lua', lazy = true },
|
||||
dependencies = { 'kkharji/sqlite.lua', 'nvim-lua/plenary.nvim' },
|
||||
opts = {
|
||||
-- your configuration there
|
||||
}
|
||||
@ -145,42 +145,42 @@ use {
|
||||
|
||||
<font color="#FF9900">**注意事项**: </font>
|
||||
|
||||
- `install.sh`
|
||||
- `install.sh`
|
||||
|
||||
- 使用了 `wget`下载词库, 安装请确保你的环境变量中存在 wget
|
||||
- install.sh 下载后会自动将词库解压, 并移动到 `$HOME/.vim/dict`文件夹下
|
||||
- 目前仅在 `Ubuntu22.04`的环境下测试通过
|
||||
> 如果上述条件不符合, 请删掉 `run = 'install.sh'`部分, 考虑手动安装词库
|
||||
> 如果上述条件满足, 仍出现问题, 欢迎在 issue 里向我反馈,我会及时尝试解决
|
||||
- 使用了 `wget`下载词库, 安装请确保你的环境变量中存在 wget
|
||||
- install.sh 下载后会自动将词库解压, 并移动到 `$HOME/.vim/dict`文件夹下
|
||||
- 目前仅在 `Ubuntu22.04`的环境下测试通过
|
||||
> 如果上述条件不符合, 请删掉 `run = 'install.sh'`部分, 考虑手动安装词库
|
||||
> 如果上述条件满足, 仍出现问题, 欢迎在 issue 里向我反馈,我会及时尝试解决
|
||||
|
||||
- 下载词典的过程中, 需要能够 `流畅的访问github下载`
|
||||
- 下载词典的过程中, 需要能够 `流畅的访问github下载`
|
||||
|
||||
> 词库文件压缩包大小为: **281M**
|
||||
> 解压缩后的大小大概为: 1.2G
|
||||
> 词库文件压缩包大小为: **281M**
|
||||
> 解压缩后的大小大概为: 1.2G
|
||||
|
||||
- 安装后如果不能正常运行, 请尝试检查一下问题:
|
||||
- 安装后如果不能正常运行, 请尝试检查一下问题:
|
||||
|
||||
- 本机是否已经安装了 `sqlite3`
|
||||
> Linux 下安装:
|
||||
> `sudo pacman -S sqlite # Arch`
|
||||
> `sudo apt-get install sqlite3 libsqlite3-dev # Ubuntu`
|
||||
- 本机是否已经安装了 `sqlite3`
|
||||
> Linux 下安装:
|
||||
> `sudo pacman -S sqlite # Arch`
|
||||
> `sudo apt-get install sqlite3 libsqlite3-dev # Ubuntu`
|
||||
|
||||
> 后续会增加 `healthcheck` 进行检查
|
||||
> 后续会增加 `healthcheck` 进行检查
|
||||
|
||||
- **`auto_play`** 使用步骤:
|
||||
- **`auto_play`** 使用步骤:
|
||||
|
||||
> linux 只需要安装`festival`
|
||||
> sudo apt-get install festival festvox-kallpc16k
|
||||
> **_如果你想要设置音色,发音可以访问:_** [Festival 官方](https://www.cstr.ed.ac.uk/projects/festival/morevoices.html)
|
||||
> 可以选择英音、美音、男声、女声
|
||||
> linux 只需要安装`festival`
|
||||
> sudo apt-get install festival festvox-kallpc16k
|
||||
> **_如果你想要设置音色,发音可以访问:_** [Festival 官方](https://www.cstr.ed.ac.uk/projects/festival/morevoices.html)
|
||||
> 可以选择英音、美音、男声、女声
|
||||
|
||||
> 其他操作系统
|
||||
> 其他操作系统
|
||||
|
||||
- 需要确保安装了`nodejs`
|
||||
- 进入插件的`tts`目录运行`npm install`
|
||||
> 如果`install.sh`运行正常则自动安装,如果安装失败,请尝试手动安装
|
||||
- 需要确保安装了`nodejs`
|
||||
- 进入插件的`tts`目录运行`npm install`
|
||||
> 如果`install`运行正常则自动安装,如果安装失败,请尝试手动安装
|
||||
|
||||
- `title`的配置,只对`neovim 0.9`版本有效
|
||||
- `title`的配置,只对`neovim 0.9+`版本有效
|
||||
|
||||
<details>
|
||||
<summary>Festival配置(仅针对linux用户)</summary>
|
||||
@ -188,45 +188,45 @@ use {
|
||||
- 全局配置: `/usr/share/festival/siteinit.scm`
|
||||
- 用户配置: `~/.festivalrc`
|
||||
|
||||
- 更改声音
|
||||
- 更改声音
|
||||
|
||||
- 在 festival 的 voices 文件内建立自己的文件夹
|
||||
- 在 festival 的 voices 文件内建立自己的文件夹
|
||||
|
||||
> 一般其默认配置目录在`/usr/share/festival/voices`
|
||||
> 一般其默认配置目录在`/usr/share/festival/voices`
|
||||
|
||||
示例:
|
||||
示例:
|
||||
|
||||
> `sudo mkdir /usr/share/festival/voices/my_voices`
|
||||
> `sudo mkdir /usr/share/festival/voices/my_voices`
|
||||
|
||||
- 下载想要的 voices 文件并解压
|
||||
- 下载想要的 voices 文件并解压
|
||||
|
||||
> 可能需要
|
||||
|
||||
- 试听[在这里](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`
|
||||
|
||||
示例:
|
||||
|
||||
> `cd ~/Downloads && tar -xf festvox_cmu_us_aew_cg.tar.gz`
|
||||
|
||||
- 将音频文件拷贝到 festival 文件夹
|
||||
示例:
|
||||
|
||||
> `sudo cp -r festival/lib/voices/us/cmu_us_aew_cg/ /usr/share/festival/voices/my_voices/`
|
||||
|
||||
- 在配置文件中设置默认的声音
|
||||
示例:
|
||||
|
||||
> 加入`(set! voice_default voice_cmu_indic_hin_ab_cg)`到配置文件
|
||||
|
||||
- 安装完成
|
||||
|
||||
- 相关说明网站
|
||||
> 可能需要
|
||||
|
||||
- 试听[在这里](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`
|
||||
|
||||
示例:
|
||||
|
||||
> `cd ~/Downloads && tar -xf festvox_cmu_us_aew_cg.tar.gz`
|
||||
|
||||
- 将音频文件拷贝到 festival 文件夹
|
||||
示例:
|
||||
|
||||
> `sudo cp -r festival/lib/voices/us/cmu_us_aew_cg/ /usr/share/festival/voices/my_voices/`
|
||||
|
||||
- 在配置文件中设置默认的声音
|
||||
示例:
|
||||
|
||||
> 加入`(set! voice_default voice_cmu_indic_hin_ab_cg)`到配置文件
|
||||
|
||||
- 安装完成
|
||||
|
||||
- 相关说明网站
|
||||
> 可能需要
|
||||
- [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)
|
||||
- [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)
|
||||
|
||||
</details>
|
||||
|
||||
@ -243,7 +243,11 @@ require'Trans'.setup {
|
||||
width = 37,
|
||||
height = 27,
|
||||
border = 'rounded',
|
||||
title = title,
|
||||
title = vim.fn.has('nvim-0.9') == 1 and {
|
||||
{ '', 'TransTitleRound' },
|
||||
{ ' Trans', 'TransTitle' },
|
||||
{ '', 'TransTitleRound' },
|
||||
} or nil,
|
||||
keymap = {
|
||||
pageup = '[[',
|
||||
pagedown = ']]',
|
||||
@ -265,32 +269,10 @@ require'Trans'.setup {
|
||||
'BufLeave',
|
||||
},
|
||||
auto_play = true,
|
||||
timeout = 3000,
|
||||
timeout = 2000,
|
||||
spinner = 'dots', -- 查看所有样式: /lua/Trans/util/spinner
|
||||
-- spinner = 'moon'
|
||||
},
|
||||
float = {
|
||||
width = 0.8,
|
||||
height = 0.8,
|
||||
border = 'rounded',
|
||||
title = title,
|
||||
keymap = {
|
||||
quit = 'q',
|
||||
},
|
||||
animation = {
|
||||
open = 'fold',
|
||||
close = 'fold',
|
||||
interval = 10,
|
||||
},
|
||||
tag = {
|
||||
wait = '#519aba',
|
||||
fail = '#e46876',
|
||||
success = '#10b981',
|
||||
},
|
||||
engine = {
|
||||
'本地',
|
||||
}
|
||||
},
|
||||
order = { -- only work on hover mode
|
||||
'title',
|
||||
'tag',
|
||||
@ -304,8 +286,8 @@ require'Trans'.setup {
|
||||
notfound = ' ',
|
||||
yes = '✔',
|
||||
no = '',
|
||||
-- --- char: ■ | □ | ▇ | ▏ ▎ ▍ ▌ ▋ ▊ ▉ █
|
||||
-- --- ◖■■■■■■■◗▫◻ ▆ ▆ ▇⃞ ▉⃞
|
||||
-- --- char: ■ | □ | ▇ | ▏ ▎ ▍ ▌ ▋ ▊ ▉ █
|
||||
-- --- ◖■■■■■■■◗▫◻ ▆ ▆ ▇⃞ ▉⃞
|
||||
cell = '■',
|
||||
-- star = '⭐',
|
||||
-- notfound = '❔',
|
||||
@ -313,30 +295,26 @@ require'Trans'.setup {
|
||||
-- no = '❌'
|
||||
},
|
||||
theme = 'default',
|
||||
-- theme = 'dracula',
|
||||
-- theme = 'tokyonight',
|
||||
|
||||
db_path = '$HOME/.vim/dict/ultimate.db',
|
||||
|
||||
engine = {
|
||||
-- baidu = {
|
||||
-- appid = '',
|
||||
-- appPasswd = '',
|
||||
-- },
|
||||
-- -- youdao = {
|
||||
-- appkey = '',
|
||||
-- appPasswd = '',
|
||||
-- },
|
||||
},
|
||||
|
||||
-- TODO :
|
||||
-- register word
|
||||
-- history = {
|
||||
-- -- TOOD
|
||||
-- }
|
||||
|
||||
-- TODO :add online translate engine
|
||||
}
|
||||
dir = vim.fn.expand('$HOME/.vim/dict'),
|
||||
-- float = {
|
||||
-- width = 0.8,
|
||||
-- height = 0.8,
|
||||
-- border = 'rounded',
|
||||
-- keymap = {
|
||||
-- quit = 'q',
|
||||
-- },
|
||||
-- animation = {
|
||||
-- open = 'fold',
|
||||
-- close = 'fold',
|
||||
-- interval = 10,
|
||||
-- },
|
||||
-- tag = {
|
||||
-- wait = '#519aba',
|
||||
-- fail = '#e46876',
|
||||
-- success = '#10b981',
|
||||
-- },
|
||||
-- },
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
@ -407,13 +385,13 @@ vim.keymap.set('n', 'mi', '<Cmd>TranslateInput<CR>')
|
||||
|
||||
## 声明
|
||||
|
||||
- 本插件词典基于[ECDICT](https://github.com/skywind3000/ECDICT)
|
||||
- 本插件词典基于[ECDICT](https://github.com/skywind3000/ECDICT)
|
||||
|
||||
## 感谢
|
||||
|
||||
- [ECDICT](https://github.com/skywind3000/ECDICT) 本地词典的提供
|
||||
- [sqlite.lua](https://github.com/kharji/sqlite.lua) 数据库访问
|
||||
- [T.vim](https://github.com/sicong-li/T.vim) 灵感来源
|
||||
- [ECDICT](https://github.com/skywind3000/ECDICT) 本地词典的提供
|
||||
- [sqlite.lua](https://github.com/kharji/sqlite.lua) 数据库访问
|
||||
- [T.vim](https://github.com/sicong-li/T.vim) 灵感来源
|
||||
|
||||
## 贡献
|
||||
|
||||
@ -422,11 +400,11 @@ vim.keymap.set('n', 'mi', '<Cmd>TranslateInput<CR>')
|
||||
|
||||
## 待办 (画大饼)
|
||||
|
||||
- [x] 多风格样式查询
|
||||
- [x] 重新录制屏幕截图示例
|
||||
- [x] 快捷键定义
|
||||
- [x] 自动读音
|
||||
- [ ] 变量命名的支持
|
||||
- [ ] 历史查询结果保存
|
||||
- [ ] 在线多引擎异步查询
|
||||
- [ ] `句子翻译` | `中翻英` 的支持
|
||||
- [x] 多风格样式查询
|
||||
- [x] 重新录制屏幕截图示例
|
||||
- [x] 快捷键定义
|
||||
- [x] 自动读音
|
||||
- [ ] 变量命名的支持
|
||||
- [ ] 历史查询结果保存
|
||||
- [ ] 在线多引擎异步查询
|
||||
- [ ] `句子翻译` | `中翻英` 的支持
|
||||
|
18
install.sh
18
install.sh
@ -1,18 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
if test -e "$HOME/.vim/dict/ultimate.db"; then
|
||||
exit
|
||||
fi
|
||||
|
||||
mkdir -p "$HOME/.vim/dict"
|
||||
|
||||
wget https://github.com/skywind3000/ECDICT-ultimate/releases/download/1.0.0/ecdict-ultimate-sqlite.zip -O /tmp/dict.zip
|
||||
|
||||
unzip /tmp/dict.zip -d "$HOME/.vim/dict" && rm -rf /tmp/dict.zip
|
||||
|
||||
uNames=$(uname -s)
|
||||
osName=${uNames:0:4}
|
||||
if [ "$osName" != "Linux" ]; then
|
||||
cd ./tts/ && npm install
|
||||
fi
|
@ -13,7 +13,8 @@ vim.api.nvim_create_autocmd('VimLeavePre', {
|
||||
M.query = function(data)
|
||||
if data.is_word == false or data.from == 'zh' then return end
|
||||
|
||||
data.path = vim.fn.expand(data.path or require('Trans').conf.dir .. '/ultimate.db')
|
||||
|
||||
data.path = data.path or require('Trans').conf.dir .. '/ultimate.db'
|
||||
data.engine = 'offline'
|
||||
data.formatter = data.formatter or M.formatter
|
||||
data.query_field = data.query_field or M.query_field
|
||||
@ -22,10 +23,10 @@ M.query = function(data)
|
||||
local dict = db:open(data.path)
|
||||
local db_name = data.db_name or 'stardict'
|
||||
local res = dict:select(db_name, {
|
||||
where = { word = data.str, },
|
||||
keys = data.query_field,
|
||||
limit = 1,
|
||||
})[1]
|
||||
where = { word = data.str, },
|
||||
keys = data.query_field,
|
||||
limit = 1,
|
||||
})[1]
|
||||
|
||||
if res then
|
||||
data.result = data.formatter(res)
|
||||
@ -89,16 +90,16 @@ local formatter = {
|
||||
exchange = function(res)
|
||||
if not exist(res.exchange) then return end
|
||||
local exchange_map = {
|
||||
['p'] = '过去式 ',
|
||||
['d'] = '过去分词 ',
|
||||
['i'] = '现在分词 ',
|
||||
['r'] = '比较级 ',
|
||||
['t'] = '最高级 ',
|
||||
['s'] = '复数 ',
|
||||
['0'] = '原型 ',
|
||||
['1'] = '类别 ',
|
||||
['3'] = '第三人称单数',
|
||||
['f'] = '第三人称单数',
|
||||
['p'] = '过去式 ',
|
||||
['d'] = '过去分词 ',
|
||||
['i'] = '现在分词 ',
|
||||
['r'] = '比较级 ',
|
||||
['t'] = '最高级 ',
|
||||
['s'] = '复数 ',
|
||||
['0'] = '原型 ',
|
||||
['1'] = '类别 ',
|
||||
['3'] = '第三人称单数',
|
||||
['f'] = '第三人称单数',
|
||||
}
|
||||
|
||||
local exchange = {}
|
||||
|
@ -60,7 +60,7 @@ return {
|
||||
-- no = '❌'
|
||||
},
|
||||
theme = 'default',
|
||||
dir = '$HOME/.vim/dict',
|
||||
dir = vim.fn.expand('$HOME/.vim/dict'),
|
||||
-- float = {
|
||||
-- width = 0.8,
|
||||
-- height = 0.8,
|
||||
|
@ -0,0 +1,42 @@
|
||||
return function()
|
||||
-- INFO :Chceck ultimate.db exists
|
||||
local dir = require('Trans').conf.dir
|
||||
local path = dir .. '/ultimate.db'
|
||||
if vim.fn.filereadable(path) == 1 then
|
||||
vim.notify('Database already exists', vim.log.WARN)
|
||||
return
|
||||
else
|
||||
vim.notify('Trying to download database', vim.log.INFO)
|
||||
end
|
||||
|
||||
|
||||
-- INFO :Download ultimate.db
|
||||
local uri = 'https://github.com/skywind3000/ECDICT-ultimate/releases/download/1.0.0/ecdict-ultimate-sqlite.zip'
|
||||
local loc = dir .. '/ultimate.zip'
|
||||
require('plenary.curl').get(uri, {
|
||||
output = loc,
|
||||
callback = function(output)
|
||||
if output.exsit == 0 and output.status == 200 then
|
||||
if vim.fn.executable('unzip') == 0 then
|
||||
vim.notify('unzip not found, Please unzip ' .. loc .. 'manually', vim.log.ERROR)
|
||||
return
|
||||
end
|
||||
|
||||
local cmd = string.format('unzip %s -d %s', path, dir)
|
||||
os.execute(cmd)
|
||||
os.remove(path)
|
||||
|
||||
vim.notify('Download database successfully', vim.log.INFO)
|
||||
return
|
||||
end
|
||||
|
||||
local debug_message = 'Download database failed:' .. vim.inspect(output)
|
||||
vim.notify(debug_message, vim.log.ERROR)
|
||||
end,
|
||||
})
|
||||
|
||||
-- INFO : tts dependencies
|
||||
if vim.fn.has('linux') == 0 and vim.fn.has('mac') == 0 then
|
||||
os.execute('cd ./tts/ && npm install')
|
||||
end
|
||||
end
|
@ -1,8 +1,8 @@
|
||||
local check = function()
|
||||
local health = vim.health
|
||||
local ok = health.report_ok
|
||||
local warn = health.report_warn
|
||||
local error = health.report_error
|
||||
local health = vim.health
|
||||
local ok = health.report_ok
|
||||
local warn = health.report_warn
|
||||
local error = health.report_error
|
||||
|
||||
local has = vim.fn.has
|
||||
local executable = vim.fn.executable
|
||||
@ -54,7 +54,7 @@ local check = function()
|
||||
|
||||
|
||||
-- INFO :Check ultimate.db
|
||||
local db_path = vim.fn.expand(require('Trans').conf.dir .. '/ultimate.db')
|
||||
local db_path = require('Trans').conf.dir .. '/ultimate.db'
|
||||
if vim.fn.filereadable(db_path) == 1 then
|
||||
ok [[ultimate database found ]]
|
||||
else
|
||||
|
Loading…
x
Reference in New Issue
Block a user