-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtranslate.lua
66 lines (61 loc) · 1.59 KB
/
translate.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
return {
'uga-rosa/translate.nvim',
commands = function(config)
return {
TranslateTargetLang = {
function(opts)
config.translate.targetLang = opts.args
end,
{
desc = 'Change default target language for translate plugin in runtime',
range = 0,
nargs = '+',
complete = require('translate.command').get_complete_list,
},
},
TranslateCommand = {
function(opts)
require('translate.config').config.default.command = opts.args
end,
{
desc = 'Change default command for translate plugin in runtime',
range = 0,
nargs = '+',
complete = function()
return { 'google', 'translate_shell', 'deepl_free', 'deepl_pro' }
end,
},
},
}
end,
keymaps = function(config)
return {
{
{ 'n', 'x' },
'<M-t>',
function()
vim.cmd.Translate(config.translate.targetLang)
end,
},
}
end,
config = function(config)
require('translate').setup(config.translate)
end,
defaultConfig = {
'translate',
{
targetLang = 'en', -- 'en', 'zh-CN', 'zh-TW'. See the completion list when typing `:Translate `.
default = {
-- (default) 'google': It uses Google Translate. It needs curl installed.
-- 'translate_shell':
-- It needs [trans](https://github.com/soimort/translate-shell) command installed.
-- And it's recommended to set a [config](https://github.com/soimort/translate-shell/wiki/Configuration) file.
-- 'deepl_pro' or 'deepl_free':
-- You need the authorization key for DeepL API Pro/Free.
-- It needs curl installed.
command = 'google',
},
},
},
}