fix: improve install.sh and init.lua
This commit is contained in:
parent
92a4b9de91
commit
7772ce55a3
@ -59,7 +59,7 @@ use {
|
||||
- install.sh 下载后会自动将词库解压, 并移动到 `$HOME/.vim/dict`文件夹下
|
||||
- 目前仅在 `Ubuntu22.04`的环境下测试通过
|
||||
> 如果上述条件不符合, 请删掉 `run = 'install.sh'`部分, 考虑手动安装词库
|
||||
> 如果上述条件满足, 仍出现问题, 欢迎在issure里向我反馈,我会及时尝试解决
|
||||
> 如果上述条件满足, 仍出现问题, 欢迎在issue里向我反馈,我会及时尝试解决
|
||||
|
||||
- 下载词典的过程中, 需要能够 `流畅的访问github下载`
|
||||
> 词库文件压缩包大小为: **281M**
|
||||
|
@ -1,6 +1,15 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
if [[ -d "$HOME/.vim" ]]; then
|
||||
if [[ -d "$HOME/.vim/dict" && -f "$HOME/.vim/dict/ultimate.db" ]]; then
|
||||
echo 'db has been installed'
|
||||
exit 0
|
||||
fi
|
||||
else
|
||||
echo '$HOME/.vim not exist'
|
||||
exit 1
|
||||
fi
|
||||
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
|
||||
|
@ -1,5 +1,5 @@
|
||||
local M = {}
|
||||
local dict = require("Trans").dict
|
||||
local dict = require("Trans").db:open(M.conf.db_path)
|
||||
|
||||
function M.query(arg)
|
||||
-- TODO: return type: a result table:
|
||||
|
@ -15,7 +15,16 @@ function M.setup(conf)
|
||||
require("Trans.setup")
|
||||
end
|
||||
|
||||
M.db = require("sqlite.db")
|
||||
M.dict = M.db:open(M.conf.db_path)
|
||||
local res = vim.fn.executable('sqlite3')
|
||||
if res ~= 1 then
|
||||
error('Please check out sqlite3')
|
||||
end
|
||||
|
||||
local status, db = pcall(require, 'sqlite.db')
|
||||
if not status then
|
||||
error('Please check out sqlite.lua')
|
||||
end
|
||||
|
||||
M.db = db
|
||||
|
||||
return M
|
||||
|
Loading…
x
Reference in New Issue
Block a user